mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-19 03:49:20 +00:00
Added some more utility to Cuboid/Rotation
This commit is contained in:
1 parent
3c81313a8c
commit
ffc284349e
2 files changed
+65
-4
No files matched your search
@@ -2,11 +2,19 @@ package codechicken.lib.vec;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class CuboidCoord
|
||||
import java.util.Iterator;
|
||||
|
||||
public class CuboidCoord implements Iterable<BlockCoord>
|
||||
{
|
||||
public BlockCoord min;
|
||||
public BlockCoord max;
|
||||
|
||||
|
||||
public CuboidCoord()
|
||||
{
|
||||
min = new BlockCoord();
|
||||
max = new BlockCoord();
|
||||
}
|
||||
|
||||
public CuboidCoord(BlockCoord min, BlockCoord max)
|
||||
{
|
||||
this.min = min;
|
||||
@@ -128,4 +136,37 @@ public class CuboidCoord
|
||||
{
|
||||
return set(ia[0], ia[1], ia[2], ia[3], ia[4], ia[5]);
|
||||
}
|
||||
|
||||
public Iterator<BlockCoord> iterator() {
|
||||
return new Iterator<BlockCoord>() {
|
||||
BlockCoord b = null;
|
||||
|
||||
public boolean hasNext() {
|
||||
return b == null || !b.equals(max);
|
||||
}
|
||||
|
||||
public BlockCoord next() {
|
||||
if(b == null)
|
||||
b = min.copy();
|
||||
else {
|
||||
if(b.z != max.z)
|
||||
b.z++;
|
||||
else {
|
||||
b.z = min.z;
|
||||
if(b.y != max.y)
|
||||
b.y++;
|
||||
else {
|
||||
b.y = min.y;
|
||||
b.x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user