diff --git a/build.gradle b/build.gradle index 0d1060e..d7e0dda 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.1.2" +version = "1.7.10-1.0.1.3" group= "com.azanor.baubles" archivesBaseName = "Baubles" diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index 6b20ae7..c36cc4e 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -45,8 +45,13 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { @Override public void updateScreen() { + try { + ((ContainerPlayerExpanded)inventorySlots).baubles.blockEvents=false; + } catch (Exception e) { } } + + /** * Adds the buttons (and other controls) to the screen in question. */ @@ -55,6 +60,7 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { { this.buttonList.clear(); super.initGui(); + } /** diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index 8e44682..ad964a9 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -24,7 +24,7 @@ public class Baubles { public static final String MODID = "Baubles"; public static final String MODNAME = "Baubles"; - public static final String VERSION = "1.0.1.2"; + public static final String VERSION = "1.0.1.3"; @SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy") public static CommonProxy proxy; diff --git a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java index a17070b..4dfbc31 100644 --- a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java +++ b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java @@ -86,6 +86,7 @@ public class ContainerPlayerExpanded extends Container } this.onCraftMatrixChanged(this.craftMatrix); + } /** @@ -264,7 +265,18 @@ public class ContainerPlayerExpanded extends Container } } - protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4, Slot ss) + + + @Override + public void putStacksInSlots(ItemStack[] p_75131_1_) { + baubles.blockEvents=true; + super.putStacksInSlots(p_75131_1_); + } + + + + + protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4, Slot ss) { boolean flag1 = false; int k = par2; diff --git a/src/main/java/baubles/common/container/InventoryBaubles.java b/src/main/java/baubles/common/container/InventoryBaubles.java index e41572d..a5b7143 100644 --- a/src/main/java/baubles/common/container/InventoryBaubles.java +++ b/src/main/java/baubles/common/container/InventoryBaubles.java @@ -22,6 +22,7 @@ public class InventoryBaubles implements IInventory { public ItemStack[] stackList; private Container eventHandler; public WeakReference player; + public boolean blockEvents=false; public InventoryBaubles(EntityPlayer player) { this.stackList = new ItemStack[4]; @@ -95,12 +96,13 @@ public class InventoryBaubles implements IInventory { if (this.stackList[par1].stackSize <= par2) { itemstack = this.stackList[par1]; - this.stackList[par1] = null; if (itemstack != null && itemstack.getItem() instanceof IBauble) { ((IBauble) itemstack.getItem()).onUnequipped(itemstack, player.get()); } + + this.stackList[par1] = null; if (eventHandler != null) this.eventHandler.onCraftMatrixChanged(this); @@ -108,15 +110,16 @@ public class InventoryBaubles implements IInventory { return itemstack; } else { itemstack = this.stackList[par1].splitStack(par2); - - if (this.stackList[par1].stackSize == 0) { - this.stackList[par1] = null; - } - + if (itemstack != null && itemstack.getItem() instanceof IBauble) { ((IBauble) itemstack.getItem()).onUnequipped(itemstack, player.get()); } + + if (this.stackList[par1].stackSize == 0) { + this.stackList[par1] = null; + } + if (eventHandler != null) this.eventHandler.onCraftMatrixChanged(this); syncSlotToClients(par1); @@ -133,11 +136,12 @@ public class InventoryBaubles implements IInventory { */ @Override public void setInventorySlotContents(int par1, ItemStack stack) { - if(this.stackList[par1] != null) { + + if(!blockEvents && this.stackList[par1] != null) { ((IBauble)stackList[par1].getItem()).onUnequipped(stackList[par1], player.get()); } this.stackList[par1] = stack; - if (stack != null && stack.getItem() instanceof IBauble) { + if (!blockEvents && stack != null && stack.getItem() instanceof IBauble) { ((IBauble) stack.getItem()).onEquipped(stack, player.get()); } if (eventHandler != null) diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt index 5a32b3a..d894356 100644 --- a/src/main/resources/changelog.txt +++ b/src/main/resources/changelog.txt @@ -1,3 +1,7 @@ +1.0.1.3 +- created workaround for unnecessary calls to onEquipped and onUneEquipped +- fixed a bug where onUneEquipped wasn't being called if you pick an item up from a slot + 1.0.1.2 - added a simple way to switch between the normal and baubles inventory. Thanks to Vazkii for the idea and permission to port it to base Baubles. - removed the Miners Ring crafting recipe... it is a bit op. I will leave the item in so it is attainable in creative and so it can still serve as an example bauble for devs.