Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix infinite loop in TranslationTask #721

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,16 @@ protected void execute() throws InterruptedException, ExecutionException {
MovecraftLocation test = new MovecraftLocation(newHitBox.getMidPoint().getX(), newHitBox.getMinY(),
newHitBox.getMidPoint().getZ());
test = test.translate(0, -1, 0);
while (test.toBukkit(world).getBlock().getType().isAir()) {
// If we are out of bounds, that is technically air, but then we would have an infinite loop, so stay in Y bounds
while (test.toBukkit(world).getBlock().getType().isAir() && world.getMinHeight() >= test.getY() && world.getMaxHeight() <= test.getY()) {
test = test.translate(0, -1, 0);
}
Material testType = test.toBukkit(world).getBlock().getType();
if (craft.getType().getMaterialSetProperty(CraftType.FORBIDDEN_HOVER_OVER_BLOCKS).contains(testType)) {
// Why is there no return here? Shouldnt there be one?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a serious question i have there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it seems i confused the lines when i wrote that comment, but anyway. Once the craft goes over a forbidden hover over block, it can't translate at all. Calling fail also pretty much implies that the result is final at that point, but yet the function would continue, so the return is necessary

fail(String.format(I18nSupport.getInternationalisedString("Translation - Failed Craft over block"),
testType.name().toLowerCase().replace("_", " ")));
return;
}
}
//call event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Translation\ -\ Failed\ Craft\ is\ obstructed=The craft cannot move because its
Translation\ -\ Failed\ Craft\ out\ of\ fuel=The craft is out of fuel\!
Translation\ -\ Failed\ Craft\ hit\ minimum\ height\ limit=Craft has hit the minimum height limit
Translation\ -\ Failed\ Craft\ over\ block=This craft cannot move over %s\!
Translation\ -\ Failed\ Craft\ over\ void=The craft can't go over nonexisting terrain!

Insufficient\ Permissions=Insufficient Permissions
Invalid\ Coordinates=Invalid Coordinates
Expand Down