Posted June 28, 201411 yr I have a problem with my mod (find it at https://github.com/rhbvkleef/requiredstuffz) When breakBlock is called on my block (tk.yteditors.requiredstuffz.block.BlockOven) the TileEntity I get from the coordinates, is NOT an instance of TileEntityOven (tk.yteditors.requiredstuffz.tileentity.TileEntityOven) or even IInventory. What's happening here!? Check out my mod!
June 28, 201411 yr super.breakBlock(world, x, y, z, par5, par6); That removes the tile entity. Call it after you are done.
June 28, 201411 yr proper way to break a block and it's respective tile entity: @Override public void breakBlock(World world, int x, int y, int z, Block oldblock, int oldMetadata) { TileEntityOven tileentity = (TileEntityOven) world.getTileEntity(x, y, z); if(tileentity != null) { for(int i = 0; i < tileentity.getSizeInventory(); i++) { ItemStack itemstack = tileentity.getStackInSlot(i); if(itemstack != null) { float f = this.rand.nextFloat() * 0.8F + 0.1F; float f1 = this.rand.nextFloat() * 0.8F + 0.1F; float f2 = this.rand.nextFloat() * 0.8F + 0.1F; while(itemstack.stackSize > 0) { int j = this.rand.nextInt(21) + 10; if(j > itemstack.stackSize) j = itemstack.stackSize; itemstack.stackSize -= j; EntityItem item = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); if(itemstack.hasTagCompound()) item.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); world.spawnEntityInWorld(item); } } } //world.func_147453_f(x, y, z, oldblock); } super.breakBlock(world, x, y, z, oldblock, oldMetadata); }
June 29, 201411 yr I would not classify that code as "proper". ye, you're right, I should of called it, the way the furnace does it..
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.