make storage block /give safe

This commit is contained in:
Raoul Van den Berge
2016-01-31 17:19:19 +01:00
parent 331052b01d
commit cff3538041

View File

@@ -23,6 +23,8 @@ public class ItemBlockStorage extends ItemBlockBase
{ {
EnumStorageType type = EnumStorageType.getById(stack.getMetadata()); EnumStorageType type = EnumStorageType.getById(stack.getMetadata());
if (type != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileStorage.NBT_STORAGE))
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE); NBTTagCompound tag = stack.getTagCompound().getCompoundTag(TileStorage.NBT_STORAGE);
if (type == EnumStorageType.TYPE_CREATIVE) if (type == EnumStorageType.TYPE_CREATIVE)
@@ -34,6 +36,7 @@ public class ItemBlockStorage extends ItemBlockBase
list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storage.stored_capacity"), NBTStorage.getStored(tag), type.getCapacity())); list.add(String.format(StatCollector.translateToLocal("misc.storagecraft:storage.stored_capacity"), NBTStorage.getStored(tag), type.getCapacity()));
} }
} }
}
@Override @Override
public void onCreated(ItemStack stack, World world, EntityPlayer player) public void onCreated(ItemStack stack, World world, EntityPlayer player)