Skip to content

Commit

Permalink
Expand BlockBox utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Nov 11, 2024
1 parent 94fee33 commit b1398e0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/com/lovetropics/lib/BlockBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BlockPos> iterator() {
return BlockPos.betweenClosed(this.min, this.max).iterator();
Expand Down

0 comments on commit b1398e0

Please sign in to comment.