From 3a8847bdc8a1cae54580509239d903fe4456ba65 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Mon, 10 Feb 2014 22:48:52 -0500 Subject: [PATCH 1/2] Add minor safeguard for ItemProxy's in player invs --- common/mekanism/common/item/ItemProxy.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/mekanism/common/item/ItemProxy.java b/common/mekanism/common/item/ItemProxy.java index df40e6e77..f3d39e728 100644 --- a/common/mekanism/common/item/ItemProxy.java +++ b/common/mekanism/common/item/ItemProxy.java @@ -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); + } + } + } } From 60664ef71bd212ec30eecb8079bbd205c424fd4c Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Mon, 10 Feb 2014 22:49:40 -0500 Subject: [PATCH 2/2] Formatting derps --- common/mekanism/common/item/ItemProxy.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/common/mekanism/common/item/ItemProxy.java b/common/mekanism/common/item/ItemProxy.java index f3d39e728..882826f70 100644 --- a/common/mekanism/common/item/ItemProxy.java +++ b/common/mekanism/common/item/ItemProxy.java @@ -77,22 +77,22 @@ public class ItemProxy extends Item return stack; } - + @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); - } - } - } + + @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); + } + } + } }