Skip to content

Commit

Permalink
Implement minY and maxY for collision shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Dec 2, 2024
1 parent eaedc2f commit abbd6ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.List;

@SuppressWarnings("unused")
public record BlockShapeGroup(int id, List<AABB> blockShapes, double highestY, List<Direction> fullFaceDirections) {
public record BlockShapeGroup(int id, List<AABB> blockShapes, double minY, double maxY, List<Direction> fullFaceDirections) {
public static final Int2ObjectMap<BlockShapeGroup> FROM_ID = new Int2ObjectOpenHashMap<>();
public static final BlockShapeGroup EMPTY;

Expand Down Expand Up @@ -73,6 +73,7 @@ public record BlockShapeGroup(int id, List<AABB> 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));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit abbd6ae

Please sign in to comment.