add a bit of delay on every constructor / destructor operation

This commit is contained in:
Raoul Van den Berge
2015-12-24 22:08:19 +01:00
parent 0e0c6eb5b9
commit 1c8f63e51b
2 changed files with 26 additions and 20 deletions

View File

@@ -28,17 +28,20 @@ public class TileConstructor extends TileMachine implements IInventory, ISidedIn
@Override @Override
public void updateMachine() public void updateMachine()
{ {
int frontX = xCoord + getDirection().offsetX; if (ticks % 10 == 0)
int frontY = yCoord + getDirection().offsetY;
int frontZ = zCoord + getDirection().offsetZ;
if (worldObj.getBlock(frontX, frontY, frontZ) == Blocks.air && inventory.getStackInSlot(0) != null)
{ {
ItemStack took = getController().take(inventory.getStackInSlot(0).copy(), compare); int frontX = xCoord + getDirection().offsetX;
int frontY = yCoord + getDirection().offsetY;
int frontZ = zCoord + getDirection().offsetZ;
if (took != null) if (worldObj.getBlock(frontX, frontY, frontZ) == Blocks.air && inventory.getStackInSlot(0) != null)
{ {
worldObj.setBlock(frontX, frontY, frontZ, ((ItemBlock) took.getItem()).field_150939_a, took.getItemDamage(), 1 | 2); ItemStack took = getController().take(inventory.getStackInSlot(0).copy(), compare);
if (took != null)
{
worldObj.setBlock(frontX, frontY, frontZ, ((ItemBlock) took.getItem()).field_150939_a, took.getItemDamage(), 1 | 2);
}
} }
} }
} }

View File

@@ -17,23 +17,26 @@ public class TileDestructor extends TileMachine
@Override @Override
public void updateMachine() public void updateMachine()
{ {
int frontX = xCoord + getDirection().offsetX; if (ticks % 10 == 0)
int frontY = yCoord + getDirection().offsetY;
int frontZ = zCoord + getDirection().offsetZ;
Block front = worldObj.getBlock(frontX, frontY, frontZ);
if (front != Blocks.air)
{ {
List<ItemStack> drops = front.getDrops(worldObj, frontX, frontY, frontZ, worldObj.getBlockMetadata(frontX, frontY, frontZ), 0); int frontX = xCoord + getDirection().offsetX;
int frontY = yCoord + getDirection().offsetY;
int frontZ = zCoord + getDirection().offsetZ;
worldObj.setBlockToAir(frontX, frontY, frontZ); Block front = worldObj.getBlock(frontX, frontY, frontZ);
for (ItemStack drop : drops) if (front != Blocks.air)
{ {
if (!getController().push(drop)) List<ItemStack> drops = front.getDrops(worldObj, frontX, frontY, frontZ, worldObj.getBlockMetadata(frontX, frontY, frontZ), 0);
worldObj.setBlockToAir(frontX, frontY, frontZ);
for (ItemStack drop : drops)
{ {
InventoryUtils.dropStack(worldObj, drop, frontX, frontY, frontZ); if (!getController().push(drop))
{
InventoryUtils.dropStack(worldObj, drop, frontX, frontY, frontZ);
}
} }
} }
} }