use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class LiquidAbsorberTileEntity method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
int[] x = tagCompound.getIntArray("toscanx");
int[] y = tagCompound.getIntArray("toscany");
int[] z = tagCompound.getIntArray("toscanz");
toscan.clear();
for (int i = 0; i < x.length; i++) {
toscan.add(new Coordinate(x[i], y[i], z[i]));
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class MaterialAbsorberTileEntity method checkStateServer.
@Override
protected void checkStateServer() {
if (absorbing > 0 || blockID == -1) {
timer--;
if (timer <= 0) {
timer = ABSORB_SPEED;
Block b = isValidSourceBlock(new Coordinate(xCoord, yCoord - 1, zCoord));
if (b != null) {
int id = Block.blockRegistry.getIDForObject(b);
if (blockID == -1) {
absorbing = DimletConstructionConfiguration.maxBlockAbsorbtion;
blockID = id;
meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord);
toscan.clear();
}
toscan.add(new Coordinate(xCoord, yCoord - 1, zCoord));
}
if (!toscan.isEmpty()) {
int r = worldObj.rand.nextInt(toscan.size());
Iterator<Coordinate> iterator = toscan.iterator();
Coordinate c = null;
for (int i = 0; i <= r; i++) {
c = iterator.next();
}
toscan.remove(c);
checkBlock(c, ForgeDirection.DOWN);
checkBlock(c, ForgeDirection.UP);
checkBlock(c, ForgeDirection.EAST);
checkBlock(c, ForgeDirection.WEST);
checkBlock(c, ForgeDirection.SOUTH);
checkBlock(c, ForgeDirection.NORTH);
Block block = blockMatches(c);
if (block != null) {
RFToolsTools.playSound(worldObj, block.stepSound.getBreakSound(), xCoord, yCoord, zCoord, 1.0f, 1.0f);
worldObj.setBlockToAir(c.getX(), c.getY(), c.getZ());
absorbing--;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
markDirty();
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BlockProtectors method readDestinationsFromNBT.
private void readDestinationsFromNBT(NBTTagCompound tagCompound) {
NBTTagList lst = tagCompound.getTagList("blocks", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < lst.tagCount(); i++) {
NBTTagCompound tc = lst.getCompoundTagAt(i);
Coordinate c = new Coordinate(tc.getInteger("x"), tc.getInteger("y"), tc.getInteger("z"));
int dim = tc.getInteger("dim");
GlobalCoordinate gc = new GlobalCoordinate(c, dim);
int id = tc.getInteger("id");
protectorById.put(id, gc);
protectorIdByCoordinate.put(gc, id);
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BlockProtectorTileEntity method updateDestination.
/**
* This method is called after putting down a protector that was earlier wrenched. We need to fix the data in
* the destination.
*/
public void updateDestination() {
BlockProtectors protectors = BlockProtectors.getProtectors(worldObj);
GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
if (id == -1) {
id = protectors.getNewId(gc);
markDirty();
} else {
protectors.assignId(gc, id);
}
protectors.save(worldObj);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class BlockProtectorTileEntity method toggleCoordinate.
// Toggle a coordinate to be protected or not. The coordinate given here is absolute.
public void toggleCoordinate(GlobalCoordinate c) {
if (c.getDimension() != worldObj.provider.dimensionId) {
// Wrong dimension. Don't do anything.
return;
}
Coordinate relative = absoluteToRelative(c.getCoordinate());
if (protectedBlocks.contains(relative)) {
protectedBlocks.remove(relative);
} else {
protectedBlocks.add(relative);
}
markDirty();
notifyBlockUpdate();
}
Aggregations