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

fix: add hitboxes inside some voxelshapes of cuboids #79

Conversation

2No2Name
Copy link
Member

This PR adds collision boxes inside some blocks (e.g. extended piston base, daylight sensors) as they are in vanilla.
This fixes: Lithium removes hitboxes inside some blocks. #60

The bug was caused by lithium not implementing the weird behavior from vanilla, where SimpleVoxelShapes with BitSetVoxelSets behave as if they have a hitbox at every 1/8th or 1/4th of a block inside them.

The problem is solved by adding a new VoxelShapeCuboidWithCollisionBoxesInside extends VoxelShapeSimpleCube that mimicks the behavior from vanilla. The overwritten VoxelShapes.cuboid(Box box) method now decides whether a VoxelShapeSimpleCube can be used or the more complex VoxelShapeCuboidWithCollisionBoxesInside needs to be used, by testing whether vanilla would create a shape with extra hitboxes inside. This probably costs some runtime, so benchmarks need to be done.

@2No2Name
Copy link
Member Author

The PR also changes a line in VoxelShapeSimpleCube that lead to a only theoretical edge case being very slightly different from vanilla in the past. Entities seem to be able to be moved backwards when colliding with a block by at most 1e-7 if the block is the last block in the iteration of all blocks that can be collided. That does not happen realistically, because vanilla usually checks a lot of blocks around the moving entity (oversized blocks such as moving fence gates have to be considered).

@2No2Name
Copy link
Member Author

After some testing I found some small bugs in the implementation. Changes will come, converting to draft for now.

@2No2Name 2No2Name force-pushed the 1.16.x/pull/fixHitboxesInsideVoxelShapes branch from d322ab6 to 9f335ad Compare July 28, 2020 12:36
@2No2Name 2No2Name marked this pull request as ready for review July 28, 2020 17:30
@2No2Name
Copy link
Member Author

Fixed the differences to vanilla now. Also added a test that compares the behavior of the custom voxel shape implementation to the vanilla one. Besides the VoxelShapeSimpleCube there are now two subclasses that implement the collision boxes inside the shapes and the shape being offset including the collision boxes.

@2No2Name 2No2Name merged commit 0abafdf into CaffeineMC:1.16.x/dev Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant