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

BlockRay returns wrong location in some directions #2165

Open
SimonCROS opened this issue Jul 13, 2020 · 0 comments
Open

BlockRay returns wrong location in some directions #2165

SimonCROS opened this issue Jul 13, 2020 · 0 comments
Labels
api: 7 (u) version: 1.12 type: bug Something isn't working

Comments

@SimonCROS
Copy link

BlockRay, works only on the X axis. In the others directions, the result location if the block is air is X 0 0, and distanceLimit is not taken into account as long as there is air.

DirectionalData data = optionalData.get();
Vector3d direction = data.get(Keys.DIRECTION).get().asOffset();
Location<World> location = event.getContext().get(key).get().getLocation();

main.getLogger().info("------------------------------------------------------------------------------------");
main.getLogger().info("Base location : " + locToStr(location));
main.getLogger().info("Direction : " + direction.toString());
main.getLogger().info("");

BlockRay<World> blockRay = BlockRay.from(location).direction(direction).distanceLimit(3).build();
while (blockRay.hasNext()) {
    BlockRayHit<World> b = blockRay.next();
    main.getLogger().info(locToStr(b.getLocation()));
}

And the output

------------------------------------------------------------------------------------
Base location : -331 99 270
Direction : (-1.0, 0.0, 0.0)

-332 99 270
-333 99 270
-334 99 270
-335 99 270
------------------------------------------------------------------------------------
Base location : -331 99 268
Direction : (1.0, 0.0, 0.0)

-331 99 268
-330 99 268
-329 99 268
-328 99 268
------------------------------------------------------------------------------------
Base location : -331 99 271
Direction : (0.0, 0.0, 1.0)

(-331 0 0) x 41

Using spongeforge-1.12.2-2838-7.2.3

@ImMorpheus ImMorpheus added api: 7 (u) version: 1.12 type: bug Something isn't working labels Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: 7 (u) version: 1.12 type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants