Skip to content

Commit 0a67916

Browse files
committed
Add blocksInside and allCorners methods to AABBHelper
1 parent d4aadd7 commit 0a67916

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/dev/compactmods/spatial/aabb/AABBHelper.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
package dev.compactmods.spatial.aabb;
22

3+
import net.minecraft.core.BlockPos;
34
import net.minecraft.world.phys.AABB;
45
import net.minecraft.world.phys.Vec3;
56

7+
import java.util.stream.Stream;
8+
69
public abstract class AABBHelper {
710

11+
public static Stream<BlockPos> blocksInside(AABB bounds) {
12+
return BlockPos.betweenClosedStream(bounds.contract(1, 1, 1));
13+
}
14+
15+
public static Stream<BlockPos> allCorners(AABB bounds) {
16+
Stream.Builder<BlockPos> stream = Stream.builder();
17+
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.maxY - 1, bounds.maxZ - 1));
18+
stream.add(BlockPos.containing(bounds.minX, bounds.maxY - 1, bounds.maxZ - 1));
19+
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.minY, bounds.maxZ - 1));
20+
stream.add(BlockPos.containing(bounds.minX, bounds.minY, bounds.maxZ - 1));
21+
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.maxY - 1, bounds.minZ));
22+
stream.add(BlockPos.containing(bounds.minX, bounds.maxY - 1, bounds.minZ));
23+
stream.add(BlockPos.containing(bounds.maxX - 1, bounds.minY, bounds.minZ));
24+
stream.add(BlockPos.containing(bounds.minX, bounds.minY, bounds.minZ));
25+
return stream.build();
26+
}
27+
828
public static Vec3 minCorner(AABB aabb) {
929
return new Vec3(aabb.minX, aabb.minY, aabb.minZ);
1030
}

0 commit comments

Comments
 (0)