Skip to content

Commit 748e92c

Browse files
committed
Fix Incorrect Collision Behavior for Block Shape (#344)
1 parent 9d90760 commit 748e92c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Fortern <[email protected]>
3+
Date: Thu, 24 Oct 2024 23:10:34 +0800
4+
Subject: [PATCH] Fix Incorrect Collision Behavior for Block Shape
5+
6+
7+
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
8+
index 748ab4d637ce463272bae4fdbab6842a27385126..1de40570caed06942d6aba638ee4fa1acb2ecfd1 100644
9+
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
10+
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
11+
@@ -56,6 +56,14 @@ public final class CollisionUtil {
12+
(box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON;
13+
}
14+
15+
+ // Leaves start
16+
+ public static boolean voxelShapeIntersectVanilla(final net.minecraft.world.phys.AABB box1, final net.minecraft.world.phys.AABB box2) {
17+
+ return box1.minX < box2.maxX && box1.maxX > box2.minX &&
18+
+ box1.minY < box2.maxY && box1.maxY > box2.minY &&
19+
+ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ;
20+
+ }
21+
+ // Leaves end
22+
+
23+
// assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON
24+
public static double collideX(final net.minecraft.world.phys.AABB target, final net.minecraft.world.phys.AABB source, final double source_move) {
25+
if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON &&
26+
@@ -1700,7 +1708,10 @@ public final class CollisionUtil {
27+
net.minecraft.world.phys.AABB singleAABB = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation();
28+
if (singleAABB != null) {
29+
singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ);
30+
- if (!voxelShapeIntersect(aabb, singleAABB)) {
31+
+ // Leaves start - Fix incorrect collision behavior for block shape
32+
+ boolean isBlockShape = blockCollision == net.minecraft.world.phys.shapes.Shapes.block();
33+
+ if (isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB)) {
34+
+ // Leaves end - Fix incorrect collision behavior for block shape
35+
continue;
36+
}
37+

0 commit comments

Comments
 (0)