|
1 | 1 | package dev.compactmods.spatial.aabb; |
2 | 2 |
|
| 3 | +import net.minecraft.core.BlockPos; |
3 | 4 | import net.minecraft.world.phys.AABB; |
4 | 5 | import net.minecraft.world.phys.Vec3; |
5 | 6 |
|
| 7 | +import java.util.stream.Stream; |
| 8 | + |
6 | 9 | public abstract class AABBHelper { |
7 | 10 |
|
| 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 | + |
8 | 28 | public static Vec3 minCorner(AABB aabb) { |
9 | 29 | return new Vec3(aabb.minX, aabb.minY, aabb.minZ); |
10 | 30 | } |
|
0 commit comments