@Override public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { DummyTile dummy = (DummyTile) world.getTileEntity(x, y, z); AbstractCore core = dummy.getCore(); if (core != null && !world.isRemote) { core.setDirty(); } Block block = dummy.getStoredBlock(); int meta = dummy.getMetadata(); if (world.isAirBlock(x, y, z)) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; float f2 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem = new EntityItem( world, (double) x + f, (double) y + f1, (double) z + f2, new ItemStack(block, 1, meta)); world.spawnEntityInWorld(entityitem); world.func_147453_f(x, y, z, par5); } super.breakBlock(world, x, y, z, par5, par6); }
/** Called when the blocks is activated. We are using it to open our GUI */ @Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (!player.isSneaking()) { DummyTile us = (DummyTile) world.getTileEntity(x, y, z); if (us.getCore() != null) player.openGui( Bookshelf.instance, 0, world, us.getCore().xCoord, us.getCore().yCoord, us.getCore().zCoord); return true; } return true; }
/** * ***************************************************************************************************************** * ******************************************* Tile Methods * ********************************************************* * ***************************************************************************************************************** */ @Override public void updateEntity() { super.updateEntity(); if (!worldObj.isRemote) { lastOutput = currentOutput; currentOutput = 0; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } }
/** * ***************************************************************************************************************** * *********************************************** Waila * ************************************************************ * ***************************************************************************************************************** */ @Override public void returnWailaHead(List<String> tip) { super.returnWailaHead(tip); tip.add("Currently outputting: " + lastOutput + " " + getEnergyTag()); }
@Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setInteger("output", lastOutput); }
@Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); lastOutput = tag.getInteger("output"); }