From bfde470a867b74d177fe1b9a2a3ed5c49cd126c7 Mon Sep 17 00:00:00 2001 From: MC_XiaoHei Date: Wed, 23 Jul 2025 19:05:32 +0800 Subject: [PATCH] fix: revert Configurable-collision-behavior patch (#607) Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> --- ...0139-Configurable-collision-behavior.patch | 54 +++++++++++++++++++ .../org/leavesmc/leaves/LeavesConfig.java | 8 ++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 leaves-server/minecraft-patches/features/0139-Configurable-collision-behavior.patch diff --git a/leaves-server/minecraft-patches/features/0139-Configurable-collision-behavior.patch b/leaves-server/minecraft-patches/features/0139-Configurable-collision-behavior.patch new file mode 100644 index 00000000..4b4ed57b --- /dev/null +++ b/leaves-server/minecraft-patches/features/0139-Configurable-collision-behavior.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Fortern +Date: Thu, 24 Oct 2024 23:10:34 +0800 +Subject: [PATCH] Configurable collision behavior + + +diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..8eb8e1447043498c6a0db1b56e877a91cd5fc438 100644 +--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java ++++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +@@ -101,6 +101,14 @@ public final class CollisionUtil { + (box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON; + } + ++ // Leaves start - Configurable collision behavior ++ public static boolean voxelShapeIntersectVanilla(final AABB box1, final AABB box2) { ++ return box1.minX < box2.maxX && box1.maxX > box2.minX && ++ box1.minY < box2.maxY && box1.maxY > box2.minY && ++ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ; ++ } ++ // Leaves end - Configurable collision behavior ++ + // assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON + public static double collideX(final AABB target, final AABB source, final double source_move) { + if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON && +@@ -2014,7 +2022,9 @@ public final class CollisionUtil { + AABB singleAABB = ((CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation(); + if (singleAABB != null) { + singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ); +- if (!voxelShapeIntersect(aabb, singleAABB)) { ++ // Leaves start - Configurable collision behavior ++ if (shouldSkip(aabb, blockCollision, singleAABB)) { ++ // Leaves end - Configurable collision behavior + continue; + } + +@@ -2067,6 +2077,17 @@ public final class CollisionUtil { + return ret; + } + ++ // Leaves start - Configurable collision behavior ++ private static boolean shouldSkip(net.minecraft.world.phys.AABB aabb, net.minecraft.world.phys.shapes.VoxelShape blockCollision, net.minecraft.world.phys.AABB singleAABB) { ++ boolean isBlockShape = blockCollision == net.minecraft.world.phys.shapes.Shapes.block(); ++ return switch (org.leavesmc.leaves.LeavesConfig.fix.collisionBehavior) { ++ case PAPER -> !voxelShapeIntersect(aabb, singleAABB); ++ case VANILLA -> !voxelShapeIntersectVanilla(aabb, singleAABB); ++ case BLOCK_SHAPE_VANILLA -> isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB); ++ }; ++ } ++ // Leaves end - Configurable collision behavior ++ + public static boolean getEntityHardCollisions(final Level world, final Entity entity, AABB aabb, + final List into, final int collisionFlags, final Predicate predicate) { + final boolean checkOnly = (collisionFlags & COLLISION_FLAG_CHECK_ONLY) != 0; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java index 989bff88..775d2205 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -1178,7 +1178,13 @@ public final class LeavesConfig { @GlobalConfig("vanilla-fluid-pushing") public boolean vanillaFluidPushing = true; - @RemovedConfig(name = "collision-behavior", category = "fix") + @GlobalConfig(value = "collision-behavior") + public CollisionBehavior collisionBehavior = CollisionBehavior.BLOCK_SHAPE_VANILLA; + + public enum CollisionBehavior { + VANILLA, BLOCK_SHAPE_VANILLA, PAPER + } + @RemovedConfig(name = "spigot-EndPlatform-destroy", category = "fix") private final boolean removed = false; }