From abbd6ae4f9cbd93a8f2ae287a2b78467cf6c70c3 Mon Sep 17 00:00:00 2001 From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Mon, 2 Dec 2024 08:54:31 +0100 Subject: [PATCH] Implement minY and maxY for collision shapes --- .../main/java/com/soulfiremc/server/data/BlockShapeGroup.java | 3 ++- .../src/main/java/com/soulfiremc/server/util/VectorHelper.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/soulfiremc/server/data/BlockShapeGroup.java b/server/src/main/java/com/soulfiremc/server/data/BlockShapeGroup.java index 5b1fccfbb..1c1ac098b 100644 --- a/server/src/main/java/com/soulfiremc/server/data/BlockShapeGroup.java +++ b/server/src/main/java/com/soulfiremc/server/data/BlockShapeGroup.java @@ -28,7 +28,7 @@ import java.util.List; @SuppressWarnings("unused") -public record BlockShapeGroup(int id, List blockShapes, double highestY, List fullFaceDirections) { +public record BlockShapeGroup(int id, List blockShapes, double minY, double maxY, List fullFaceDirections) { public static final Int2ObjectMap FROM_ID = new Int2ObjectOpenHashMap<>(); public static final BlockShapeGroup EMPTY; @@ -73,6 +73,7 @@ public record BlockShapeGroup(int id, List blockShapes, double highestY, L new BlockShapeGroup( id, blockShapes, + blockShapes.stream().mapToDouble(a -> a.minY).min().orElse(0), blockShapes.stream().mapToDouble(a -> a.maxY).max().orElse(0), fullFaceDirections)); }); diff --git a/server/src/main/java/com/soulfiremc/server/util/VectorHelper.java b/server/src/main/java/com/soulfiremc/server/util/VectorHelper.java index 72a0364a5..025e0d599 100644 --- a/server/src/main/java/com/soulfiremc/server/util/VectorHelper.java +++ b/server/src/main/java/com/soulfiremc/server/util/VectorHelper.java @@ -40,7 +40,7 @@ public static Vector3d topMiddleOfBlock(Vector3d vector, BlockState blockState) } public static Vector3d topMiddleOfBlock(Vector3d vector, BlockShapeGroup blockShapeGroup) { - return vector.floor().add(0.5, blockShapeGroup.highestY(), 0.5); + return vector.floor().add(0.5, blockShapeGroup.maxY(), 0.5); } public static Vector3d xRot(Vector3d base, float pitch) {