-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add additional ray trace API #12162
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
base: main
Are you sure you want to change the base?
Add additional ray trace API #12162
Conversation
61dd233
to
7dbd11b
Compare
paper-api/src/main/java/io/papermc/paper/raytrace/BlockCollisionMode.java
Outdated
Show resolved
Hide resolved
9244d76
to
ce89a06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! might be nice to mention something in the ignorePassable jdocs (at least on the builder) that its equivalent to setting the block collision mode to the respective value
040c8b7
to
d4fc780
Compare
d4fc780
to
8245d9d
Compare
The only thing I am not sure about is the whole fluid conditions. |
Checking using the block filter doesn't really work. As an example: Location location = ...;
World world = location.getWorld();
// Hits collidable blocks & lava fluid blocks
world.rayTrace(builder -> builder
.blockCollisionMode(BlockCollisionMode.COLLIDER)
.fluidCollisionMode(FluidCollisionMode.LAVA)
.targets(RayTraceTarget.BLOCK)
);
// Hits non-waterlogged collidable blocks & lava fluid blocks
world.rayTrace(builder -> builder
.blockCollisionMode(BlockCollisionMode.COLLIDER)
.fluidCollisionMode(FluidCollisionMode.ALWAYS)
.blockFilter(block -> {
FluidData data = world.getFluidData(block.getX(), block.getY(), block.getZ());
Fluid fluid = data.getFluidType();
return fluid == Fluid.EMPTY || fluid == Fluid.LAVA || fluid == Fluid.FLOWING_LAVA;
})
.targets(RayTraceTarget.BLOCK)
); The block filter can't really be used to be distinguish hitting the block part of a waterlogged block, or the fluid part. |
Supersedes #11166.
World#rayTrace
andWorld#rayTraceBlocks
, as well as the methodPositionedRayTraceConfigurationBuilder#blockCollisionMode
, that take aBlockCollisionMode
instead of the booleanignorePassableBlocks
to determine block collisions.FluidCollisionMode.WATER
.World#rayTrace
,World#rayTraceBlocks
,PositionedRayTraceConfigurationBuilder#fluidCollisionMode
, andPositionedRayTraceConfigurationBuilder#ignorePassableBlocks
that mention caveats with portal blocks and fluids that no longer exist. Portal blocks are always considered 'passable', and the value ofignorePassableBlocks
has no effect on fluid collisions.