57 lines
3.5 KiB
Diff
57 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Wed, 4 Jun 2025 12:51:07 +0800
|
|
Subject: [PATCH] Leaves: Configurable collision behavior
|
|
|
|
Co-authored by: Fortern <blueten.ki@gmail.com>
|
|
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/c5f18b7864206cea4411211b51787f10affbcb9c/leaves-server/minecraft-patches/features/0111-Configurable-collision-behavior.patch)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
|
index 864ce0bd822a2bd6fb39866103dc54b56bf0b63c..b03096b298dbdd35ac0e4d54f96c2ab3b5b4bd21 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 &&
|
|
@@ -2025,7 +2033,7 @@ 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)) {
|
|
+ if (shouldSkip(aabb, blockCollision, singleAABB)) { // Leaves - Configurable collision behavior
|
|
continue;
|
|
}
|
|
|
|
@@ -2078,6 +2086,18 @@ public final class CollisionUtil {
|
|
return ret;
|
|
}
|
|
|
|
+ // Leaves start - Configurable collision behavior
|
|
+ private static boolean shouldSkip(AABB aabb, VoxelShape blockCollision, AABB singleAABB) {
|
|
+ boolean isBlockShape = blockCollision == Shapes.block();
|
|
+ return switch (me.earthme.luminol.config.modules.misc.CollisionBehaviorConfig.behaviorMode) {
|
|
+ case "VANILLA" -> !voxelShapeIntersectVanilla(aabb, singleAABB);
|
|
+ case "PAPER" -> !voxelShapeIntersect(aabb, singleAABB);
|
|
+ default -> isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB);
|
|
+ // All other value as BLOCK_SHAPE_VANILLA to process
|
|
+ };
|
|
+ }
|
|
+ // Leaves end - Configurable collision behavior
|
|
+
|
|
public static boolean getEntityHardCollisions(final Level world, final Entity entity, AABB aabb,
|
|
final List<AABB> into, final int collisionFlags, final Predicate<Entity> predicate) {
|
|
final boolean checkOnly = (collisionFlags & COLLISION_FLAG_CHECK_ONLY) != 0;
|