@Override public void onUpdate() { super.onUpdate(); if (getRunning()) run(); else postRun(); if (Config.useFuel && !worldObj.isRemote) { if (inventory.getStackInSlot(0) != null && TileEntityFurnace.isItemFuel(inventory.getStackInSlot(0)) && (fuel.get() + TileEntityFurnace.getItemBurnTime(inventory.getStackInSlot(0))) <= Config.maxFuelLevel) if (inventory.getStackInSlot(0).getItem().equals(Items.lava_bucket)) { fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1))); inventory.setInventorySlotContents(0, new ItemStack(Items.bucket)); } else { fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1))); } if (fuel.isDirty()) sync(); } lastTickPosX = posX; lastTickPosY = posY; lastTickPosZ = posZ; posX += motionX; posY += motionY; posZ += motionZ; setPosition(posX, posY, posZ); if (getTimeSinceHit() > 0) setTimeSinceHit(getTimeSinceHit() - 1); if (getDamageTaken() > 0) setDamageTaken(getDamageTaken() - 1); }
private boolean placeBlock(BlockCoord coord) { if (worldObj .getBlock(coord.x, coord.y, coord.z) .canPlaceBlockAt(worldObj, coord.x, coord.y, coord.z)) { slot++; if (slot > 9) slot = 1; if (inventory.getStackInSlot(slot) != null) { ItemStack stack = inventory.getStackInSlot(slot); if (!(stack.getItem() instanceof ItemBlock)) return false; stack = inventory.decrStackSize(slot, 1); return worldObj.setBlock( coord.x, coord.y, coord.z, Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 2); } } return false; }
private boolean breakBlock(BlockCoord coord) { Block block = worldObj.getBlock(coord.x, coord.y, coord.z); int blockMetadata = worldObj.getBlockMetadata(coord.x, coord.y, coord.z); if (block.equals(Blocks.obsidian) || block.equals(Blocks.bedrock) || block.equals(Blocks.lava) || block.equals(Blocks.flowing_lava)) { setRunning(false); setMotion(0, 0, 0); } else if (block.isBlockSolid(worldObj, coord.x, coord.y, coord.z, blockMetadata)) { if (!Config.destroyBlocks) { for (int i = 10; i < 37; ++i) { // runs through slots 10-36 (mined inventory) if (block.getItemDropped(blockMetadata, rand, 0) == null) break; // check for beds, doors... ItemStack blockStack = new ItemStack( block.getItemDropped(blockMetadata, rand, 0), block.quantityDropped(rand), blockMetadata); ItemStack stackInSlot = inventory.getStackInSlot(i); if (blockStack.stackSize == 0) break; if (stackInSlot != null) { if (InventoryUtils.areMergeCandidates(blockStack, stackInSlot)) { if (InventoryUtils.tryMergeStacks(blockStack, stackInSlot)) break; } } else { inventory.setInventorySlotContents(i, blockStack); break; } } } return worldObj.setBlockToAir(coord.x, coord.y, coord.z); } return false; }