More complete Javadoc

This commit is contained in:
2024-12-22 23:44:46 +01:00
parent 3d92c3afb6
commit 8f5f880754
14 changed files with 517 additions and 94 deletions

View File

@@ -12,11 +12,25 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.util.BoundingBox;
// simplified version of https://github.com/Camotoy/BambooCollisionFix/tree/c7d7d5327791cbb416d106de0b9eb0bf2461acbd/src/main/java/net/camotoy/bamboocollisionfix
// we remove the bamboo bounding box due to bedrock clients not having the same placement for bamboos
// simplified version of
/**
* Disables the server-side bounding box of the bamboo stalk blocks.
* Bamboo stalks are the thin bamboo plants that are shifted differently, depending on the X and Z coordinate.
* This X/Z dependent shift is different between Java and Bedrock implementation.
* But since this block as a collision box and players cannot go through them, Bedrock players are often rolled back
* when they are walking around bamboo stalk due to the server being in Java Edition and thinking the player tries to
* move through the bamboo.
* To avoid this issue, we reduce to 0 the size of the bounding box on the server.
* <br>
* See <a href="https://github.com/Camotoy/BambooCollisionFix/tree/c7d7d5327791cbb416d106de0b9eb0bf2461acbd/src/main/java/net/camotoy/bamboocollisionfix">the original implementation</a>.
*/
public final class BedrockBambooCollisionFixer implements Listener {
private final BoundingBox originalBambooBoundingBox = new BoundingBox(6.5D / 16D, 0.0D, 6.5D / 16.0D, 9.5D / 16.0D, 1D, 9.5D / 16.0D);
/**
* Creates a new {@link BedrockBambooCollisionFixer}. There is no need for multiple instances.
*/
public BedrockBambooCollisionFixer() {
// Make the bamboo block have zero collision.
try {
@@ -34,7 +48,7 @@ public final class BedrockBambooCollisionFixer implements Listener {
* our ability.
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlockPlaced().getBlockData().getMaterial().equals(Material.BAMBOO)) {
BoundingBox currentBambooBoundingBox = originalBambooBoundingBox.clone().shift(event.getBlockPlaced().getLocation());
for (LivingEntity e : event.getBlock().getLocation().getNearbyLivingEntities(5)) {