joshuaprince / CoordinateOffset

⛏️ A Minecraft Spigot/Paper plugin that configurably obfuscates players' coordinates.
GNU Affero General Public License v3.0
18 stars 7 forks source link

Movement near Bamboo and Dripstone is buggy when an offset is applied #8

Closed joshuaprince closed 5 months ago

joshuaprince commented 11 months ago

Problem

When an offset is applied to a player, if they try to move through the "empty" part of a bamboo block or a dripstone block where there is no collision box, it sometimes resets movement and prevents the player from passing through it.

Cause

Minecraft calculates a random offset for every block of bamboo and dripstone*. That offset is hashed on the absolute coordinates of the block in the world. Therefore, when the client and server disagree about a block's coordinates, they will expect the block's collision to be in two different places. When the player moves through the space that appears empty, the server-side collision box is actually where they are trying to move, so the server prevents their movement.

*Flowers, tall grass, and others are offset too, but they don't have a collision box so they don't affect movement

Workaround

Geyser has a similar issue because Bedrock edition uses a different offsetting method for these blocks, which Hurricane fixes by disabling collision altogether for them. A modified server that removes these collision checks does indeed fix the issue. However, Hurricane is not updated for 1.20.4. Ideally these options to disable collision checks can be included in CoordinateOffset, but the hackiness of Hurricane's reflection and improved security in recent Java versions make this seem like it will be difficult to package as a drop-in solution.

joshuaprince commented 9 months ago

Workaround Patch

If you are willing and able to patch your server JAR, here is the patch that disables server-side collision checks for Bamboo and Dripstone blocks: 0999-Disable-bamboo-and-dripstone-collision.patch

To apply it:

git clone https://github.com/PaperMC/Paper.git  # or https://github.com/PurpurMC/Purpur.git
cd Paper
cp /path/to/0999-Disable-bamboo-and-dripstone-collision.patch ./patches/server/0999-Disable-bamboo-and-dripstone-collision.patch
./gradlew applyPatches
./gradlew createReobfPaperclipJar
# JAR lands at ./build/libs/paper-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar

I have been using this patch on my server for a while and it fixes the glitchiness around these blocks without any issues. Keep in mind that players with modified clients can phase through bamboo and dripstone blocks with this patch applied.

If anyone has a good way of packaging this into the plugin, I would appreciate the help!

joshuaprince commented 5 months ago

This is fixed in v4 with the fixCollision config, but the fix isn't perfect: standing on a block of bamboo or dripstone and breaking a block in survival mode causes a slight desync (since the client and server disagree whether you are on solid ground). This also may cause false positives in anti-cheat plugins.

The workaround patch linked above still provides a complete fix for this issue if you are able to apply it directly. If you use this patch, be sure to disable fixCollision in your CoordinateOffset config.