@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityUberTable) {
TileEntityUberTable tileentityiubertable = (TileEntityUberTable) tileentity;
if (!tileentityiubertable.isEmpty()) {
ItemStack itemstack = new ItemStack(Item.getItemFromBlock(this), 1, 0);
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound.setTag("BlockEntityTag", ((TileEntityUberTable) tileentity).writeToNBT(nbttagcompound1));
itemstack.setTagCompound(nbttagcompound);
if (tileentityiubertable.hasCustomName()) {
itemstack.setStackDisplayName(tileentityiubertable.getName());
tileentityiubertable.setCustomName("Uber Table");
}
spawnAsEntity(worldIn, pos, itemstack);
worldIn.updateComparatorOutputLevel(pos, state.getBlock());
}
super.breakBlock(worldIn, pos, state);
}
}
This is a chest, if it's empty and I break it, it drops only 1 item(the chest itself) but if I put something inside it, it drops two items, one has nbt(It's a chest with the items saved in it), the other one doesn't, it's just an empty chest