Fix a crash that sometimes happens when placing down container blocks

Closes #437
This commit is contained in:
Ellpeck 2016-12-03 12:29:49 +01:00
parent 073eb2168a
commit fc4484cc73

View file

@ -23,8 +23,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
@ -216,10 +214,12 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
if(tile instanceof TileEntityBase){ if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile; TileEntityBase base = (TileEntityBase)tile;
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data"); NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data");
if(compound != null){
base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK); base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK);
} }
} }
} }
}
@Override @Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){ public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){