use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BuilderTileEntity method nextLocationQuarry.
private void nextLocationQuarry(int x, int y, int z) {
if (x >= maxBox.getX() || ((x + 1) % 16 == 0)) {
if (z >= maxBox.getZ() || ((z + 1) % 16 == 0)) {
if (y <= minBox.getY()) {
if (x < maxBox.getX()) {
x++;
z = (z >> 4) << 4;
y = maxBox.getY();
scan = new Coordinate(x, y, z);
} else if (z < maxBox.getZ()) {
x = minBox.getX();
z++;
y = maxBox.getY();
scan = new Coordinate(x, y, z);
} else {
restartScan();
}
} else {
scan = new Coordinate((x >> 4) << 4, y - 1, (z >> 4) << 4);
}
} else {
scan = new Coordinate((x >> 4) << 4, y, z + 1);
}
} else {
scan = new Coordinate(x + 1, y, z);
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BuilderTileEntity method createProjection.
private void createProjection(SpaceChamberRepository.SpaceChamberChannel chamberChannel) {
Coordinate minC = rotate(chamberChannel.getMinCorner());
Coordinate maxC = rotate(chamberChannel.getMaxCorner());
Coordinate minCorner = new Coordinate(Math.min(minC.getX(), maxC.getX()), Math.min(minC.getY(), maxC.getY()), Math.min(minC.getZ(), maxC.getZ()));
Coordinate maxCorner = new Coordinate(Math.max(minC.getX(), maxC.getX()), Math.max(minC.getY(), maxC.getY()), Math.max(minC.getZ(), maxC.getZ()));
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
ForgeDirection direction = BlockTools.getOrientationHoriz(meta);
int spanX = maxCorner.getX() - minCorner.getX();
int spanY = maxCorner.getY() - minCorner.getY();
int spanZ = maxCorner.getZ() - minCorner.getZ();
switch(direction) {
case SOUTH:
projDx = xCoord + ForgeDirection.NORTH.offsetX - minCorner.getX() - ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanX : 0);
projDz = zCoord + ForgeDirection.NORTH.offsetZ - minCorner.getZ() - spanZ;
break;
case NORTH:
projDx = xCoord + ForgeDirection.SOUTH.offsetX - minCorner.getX() - spanX + ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanX : 0);
projDz = zCoord + ForgeDirection.SOUTH.offsetZ - minCorner.getZ();
break;
case WEST:
projDx = xCoord + ForgeDirection.EAST.offsetX - minCorner.getX();
projDz = zCoord + ForgeDirection.EAST.offsetZ - minCorner.getZ() - ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanZ : 0);
break;
case EAST:
projDx = xCoord + ForgeDirection.WEST.offsetX - minCorner.getX() - spanX;
projDz = zCoord + ForgeDirection.WEST.offsetZ - minCorner.getZ() - spanZ + ((anchor == ANCHOR_NE || anchor == ANCHOR_SE) ? spanZ : 0);
break;
case DOWN:
case UP:
case UNKNOWN:
break;
}
projDy = yCoord - minCorner.getY() - ((anchor == ANCHOR_NE || anchor == ANCHOR_NW) ? spanY : 0);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BuilderTileEntity method clearSupportBlocksShaped.
private void clearSupportBlocksShaped() {
ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
Coordinate dimension = ShapeCardItem.getClampedDimension(shapeCard, SpaceProjectorConfiguration.maxBuilderDimension);
Coordinate offset = ShapeCardItem.getClampedOffset(shapeCard, SpaceProjectorConfiguration.maxBuilderOffset);
ShapeCardItem.Shape shape = ShapeCardItem.getShape(shapeCard);
List<Coordinate> blocks = new ArrayList<Coordinate>();
ShapeCardItem.composeShape(shape.makeHollow(), worldObj, getCoordinate(), dimension, offset, blocks, SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension * SpaceProjectorConfiguration.maxSpaceChamberDimension, false, null);
for (Coordinate block : blocks) {
if (worldObj.getBlock(block.getX(), block.getY(), block.getZ()) == SpaceProjectorSetup.supportBlock) {
worldObj.setBlockToAir(block.getX(), block.getY(), block.getZ());
}
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BuilderTileEntity method clearSupportBlocks.
public void clearSupportBlocks() {
if (worldObj.isRemote) {
// Don't do anything on the client.
return;
}
if (isShapeCard()) {
clearSupportBlocksShaped();
return;
}
SpaceChamberRepository.SpaceChamberChannel chamberChannel = calculateBox();
if (chamberChannel != null) {
int dimension = chamberChannel.getDimension();
World world = DimensionManager.getWorld(dimension);
for (int x = minBox.getX(); x <= maxBox.getX(); x++) {
for (int y = minBox.getY(); y <= maxBox.getY(); y++) {
for (int z = minBox.getZ(); z <= maxBox.getZ(); z++) {
Coordinate src = new Coordinate(x, y, z);
if (world != null) {
Block srcBlock = world.getBlock(src.getX(), src.getY(), src.getZ());
if (srcBlock == SpaceProjectorSetup.supportBlock) {
world.setBlockToAir(src.getX(), src.getY(), src.getZ());
}
}
Coordinate dest = sourceToDest(src);
Block dstBlock = worldObj.getBlock(dest.getX(), dest.getY(), dest.getZ());
if (dstBlock == SpaceProjectorSetup.supportBlock) {
worldObj.setBlockToAir(dest.getX(), dest.getY(), dest.getZ());
}
}
}
}
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BuilderTileEntity method calculateBoxShaped.
private void calculateBoxShaped() {
ItemStack shapeCard = inventoryHelper.getStackInSlot(BuilderContainer.SLOT_TAB);
if (shapeCard == null) {
return;
}
Coordinate dimension = ShapeCardItem.getClampedDimension(shapeCard, SpaceProjectorConfiguration.maxBuilderDimension);
Coordinate offset = ShapeCardItem.getClampedOffset(shapeCard, SpaceProjectorConfiguration.maxBuilderOffset);
Coordinate minCorner = ShapeCardItem.getMinCorner(getCoordinate(), dimension, offset);
Coordinate maxCorner = ShapeCardItem.getMaxCorner(getCoordinate(), dimension, offset);
if (minCorner.getY() < 0) {
minCorner = new Coordinate(minCorner.getX(), 0, minCorner.getZ());
} else if (minCorner.getY() > 255) {
minCorner = new Coordinate(minCorner.getX(), 255, minCorner.getZ());
}
if (maxCorner.getY() < 0) {
maxCorner = new Coordinate(maxCorner.getX(), 0, maxCorner.getZ());
} else if (maxCorner.getY() > 255) {
maxCorner = new Coordinate(maxCorner.getX(), 255, maxCorner.getZ());
}
if (boxValid) {
// Double check if the box is indeed still valid.
if (minCorner.equals(minBox) && maxCorner.equals(maxBox)) {
return;
}
}
boxValid = true;
cardType = shapeCard.getItemDamage();
cachedBlocks = null;
cachedChunk = null;
cachedVoidableBlocks = null;
minBox = minCorner;
maxBox = maxCorner;
restartScan();
}
Aggregations