if (thing instanceof BlockManipulator) {
BlockAction action = ((BlockManipulator) thing)
.getBlockAction();
if (action instanceof AddBlock) {
AddBlock addBlockAction = (AddBlock) action;
Block original = this.chunks.getBlock(addBlockAction.x, addBlockAction.y, addBlockAction.z, tmp, (Chunk)null);
this.chunks.setBlock(addBlockAction.x, addBlockAction.y, addBlockAction.z, addBlockAction.block, tmp, tmp2, null);
if (thing instanceof Volumetric) {
if (thing instanceof Cuboid) {
Vector3d offset = Resources.vector3dResourcePool.aquire();
offset.x = 0;
offset.y = 0;
offset.z = 0;
if (this.thingTools.fixOffset((Cuboid) thing,
offset, false, this.fixOffsetTmps) != null)
this.chunks.setBlock(addBlockAction.x,
addBlockAction.y, addBlockAction.z,
original, tmp, tmp2, null);
else {
if (thing instanceof InventoryOwner) {
InventoryOwner inventoryOwner = (InventoryOwner) thing;
inventoryOwner.rmBlock(addBlockAction.block);
}
}
Resources.vector3dResourcePool.recycle(offset);
}
}
} else if (action instanceof RemoveBlock) {
RemoveBlock rmBlockAction = (RemoveBlock) action;
Block b = this.chunks.getBlock(rmBlockAction.x, rmBlockAction.y, rmBlockAction.z, tmp, (Chunk)null);
if (b.getHealth() < 0) {
this.chunks.setBlock(rmBlockAction.x, rmBlockAction.y, rmBlockAction.z, BlockEmpty.Make(0), tmp, tmp2, null);
if (thing instanceof InventoryOwner) {
InventoryOwner inventoryOwner = (InventoryOwner) thing;
inventoryOwner.addBlock(b);
}
} else {
Block newB = BlockTools.updateHealth(b, b.getHealth()-1);
this.chunks.setBlock(rmBlockAction.x, rmBlockAction.y, rmBlockAction.z, newB, tmp, tmp2, null);
}
}
}
}