Should fix robit crash when placed on non-chargepad tileEntities

This commit is contained in:
Ben Spiers 2013-08-01 23:49:38 +01:00
parent f48997a793
commit 534234abb2

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -38,17 +39,18 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory
@Override @Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ)
{ {
TileEntityChargepad tileEntity = (TileEntityChargepad)world.getBlockTileEntity(x, y, z); TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity != null) if(tileEntity instanceof TileEntityChargepad)
{ {
if(!tileEntity.isActive) TileEntityChargepad chargepad = (TileEntityChargepad)tileEntity;
if(!chargepad.isActive)
{ {
if(!world.isRemote) if(!world.isRemote)
{ {
EntityRobit robit = new EntityRobit(world, x+0.5, y+0.1, z+0.5); EntityRobit robit = new EntityRobit(world, x+0.5, y+0.1, z+0.5);
robit.setHome(Object3D.get(tileEntity)); robit.setHome(Object3D.get(chargepad));
robit.setEnergy(getEnergy(itemstack)); robit.setEnergy(getEnergy(itemstack));
robit.setOwner(entityplayer.username); robit.setOwner(entityplayer.username);
robit.setInventory(getInventory(itemstack)); robit.setInventory(getInventory(itemstack));