Skip to content

Commit 293feb2

Browse files
[Bugfix] Fix infinite loop in TranslationTask (#741)
* fix infinite loop and missing return (cherry picked from commit 13ce56c) * fix build error (missing semicolon) (cherry picked from commit 6f0b401) * add translation * change loop condition instead * dont check max y * Clean up --------- Co-authored-by: DerToaster98 <38782719+DerToaster98@users.noreply.github.com>
1 parent dc773dc commit 293feb2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,15 @@ protected void execute() throws InterruptedException, ExecutionException {
229229
MovecraftLocation test = new MovecraftLocation(newHitBox.getMidPoint().getX(), newHitBox.getMinY(),
230230
newHitBox.getMidPoint().getZ());
231231
test = test.translate(0, -1, 0);
232-
while (test.toBukkit(world).getBlock().getType().isAir()) {
232+
// If we are out of bounds, that is technically air, but then we would have an infinite loop, so stay in Y bounds
233+
while (test.toBukkit(world).getBlock().getType().isAir() && world.getMinHeight() >= test.getY()) {
233234
test = test.translate(0, -1, 0);
234235
}
235236
Material testType = test.toBukkit(world).getBlock().getType();
236237
if (craft.getType().getMaterialSetProperty(CraftType.FORBIDDEN_HOVER_OVER_BLOCKS).contains(testType)) {
237238
fail(String.format(I18nSupport.getInternationalisedString("Translation - Failed Craft over block"),
238239
testType.name().toLowerCase().replace("_", " ")));
240+
return;
239241
}
240242
}
241243
//call event

0 commit comments

Comments
 (0)