Add minor safeguard for ItemProxy's in player invs
This commit is contained in:
parent
19c47c1a41
commit
3a8847bdc8
1 changed files with 19 additions and 0 deletions
|
@ -2,9 +2,13 @@ package mekanism.common.item;
|
|||
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemProxy extends Item
|
||||
{
|
||||
|
@ -76,4 +80,19 @@ public class ItemProxy extends Item
|
|||
|
||||
@Override
|
||||
public void registerIcons(IconRegister register) {}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
for (Object o : player.inventoryContainer.inventorySlots)
|
||||
{
|
||||
Slot s = (Slot) o;
|
||||
if (s.getStack() != null && s.getStack().getItem() == this)
|
||||
player.inventory.decrStackSize(s.slotNumber, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue