From b1398e0dc65919258abae30b0a22a896f15b20b9 Mon Sep 17 00:00:00 2001 From: Gegy Date: Mon, 11 Nov 2024 18:10:53 +0100 Subject: [PATCH] Expand BlockBox utilities --- src/main/java/com/lovetropics/lib/BlockBox.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lovetropics/lib/BlockBox.java b/src/main/java/com/lovetropics/lib/BlockBox.java index 7a3f7aa..5406095 100644 --- a/src/main/java/com/lovetropics/lib/BlockBox.java +++ b/src/main/java/com/lovetropics/lib/BlockBox.java @@ -14,6 +14,8 @@ import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; import javax.annotation.Nullable; import java.util.Iterator; @@ -145,13 +147,24 @@ public BlockBox intersection(BlockBox other) { return new BlockBox(min, max); } - public AABB asAabb() { - return new AABB( + public BlockBox encompassing(BlockBox other) { + return new BlockBox( + BlockPos.min(this.min, other.min), + BlockPos.max(this.min, other.min) + ); + } + + public VoxelShape asShape() { + return Shapes.create( this.min.getX(), this.min.getY(), this.min.getZ(), this.max.getX() + 1.0, this.max.getY() + 1.0, this.max.getZ() + 1.0 ); } + public AABB asAabb() { + return AABB.encapsulatingFullBlocks(min, max); + } + @Override public Iterator iterator() { return BlockPos.betweenClosed(this.min, this.max).iterator();