Inventories now don't NPE when broken
This commit is contained in:
parent
6a5f5356ce
commit
ddcc1237e8
|
@ -44,7 +44,7 @@ public class BloodAltar {
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier)
|
||||
|
|
|
@ -3,7 +3,6 @@ package WayofTime.bloodmagic.block;
|
|||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.tile.TileInventory;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -88,10 +87,11 @@ public class BlockAltar extends BlockContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
|
||||
{
|
||||
TileInventory tileInventory = (TileInventory) world.getTileEntity(blockPos);
|
||||
if (tileInventory != null) tileInventory.dropItems();
|
||||
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
|
||||
TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos);
|
||||
if (tileAltar != null)
|
||||
tileAltar.dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.tile;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -57,10 +58,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
public void dropItems() {
|
||||
if (inventory != null) {
|
||||
for (ItemStack stack : inventory)
|
||||
getWorld().spawnEntityInWorld(new EntityItem(getWorld(), getPos().getX(), pos.getY(), pos.getZ(), stack));
|
||||
}
|
||||
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
|
||||
}
|
||||
|
||||
// IInventory
|
||||
|
|
Loading…
Reference in a new issue