From 20e1cd82558b08c545bc0d38ce583263ebc9178b Mon Sep 17 00:00:00 2001 From: sisyphussy Date: Sun, 7 Sep 2025 02:26:00 +0200 Subject: [PATCH] Npe fix (#92) --- dependencies.gradle | 12 ++--- .../slot/SlotArcaneCraftingResult.java | 44 ++++++------------- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 099abe2c..ab578958 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,20 +1,20 @@ // Add your dependencies here dependencies { - implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.64-GTNH:dev") - implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.3:dev") - implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-658-GTNH:dev") + implementation("com.github.GTNewHorizons:NotEnoughItems:2.7.80-GTNH:dev") + implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev") + implementation("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-683-GTNH:dev") implementation("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") implementation("curse.maven:thaumcraft-nei-plugin-225095:2241913") { transitive = false } compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false } - compileOnly('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.100-gtnh:dev') { transitive = false } + compileOnly('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.112-gtnh:dev') { transitive = false } compileOnly("com.github.GTNewHorizons:waila:1.8.12:dev") { transitive = false } - compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.390:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.446:dev") { transitive = false } compileOnly("curse.maven:computercraft-67504:2269339") { transitive = false } compileOnly("curse.maven:cofh-lib-220333:2388748") { transitive = false } compileOnly("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") { transitive = false } - runtimeOnlyNonPublishable('com.github.GTNewHorizons:GTNHLib:0.6.38:dev') + runtimeOnlyNonPublishable('com.github.GTNewHorizons:GTNHLib:0.6.39:dev') runtimeOnly("com.github.GTNewHorizons:Baubles:1.0.4:dev") } diff --git a/src/main/java/thaumicenergistics/common/container/slot/SlotArcaneCraftingResult.java b/src/main/java/thaumicenergistics/common/container/slot/SlotArcaneCraftingResult.java index c307a49f..2b826d23 100644 --- a/src/main/java/thaumicenergistics/common/container/slot/SlotArcaneCraftingResult.java +++ b/src/main/java/thaumicenergistics/common/container/slot/SlotArcaneCraftingResult.java @@ -117,28 +117,16 @@ public class SlotArcaneCraftingResult extends SlotCrafting { continue; } - // Checked at the end to see if we need to decrement the slot - boolean shouldDecrement = true; - + // Get the container item + ItemStack slotContainerStack = slotStack.getItem().getContainerItem(slotStack); // Does the item have a container? - if (slotStack.getItem().hasContainerItem(slotStack)) { - // Get the container item - ItemStack slotContainerStack = slotStack.getItem().getContainerItem(slotStack); + if (slotContainerStack != null) { - // Is the container item damage-able? - if (slotContainerStack.isItemStackDamageable()) { - // Did we kill it? - if (slotContainerStack.getItemDamage() >= slotContainerStack.getMaxDamage()) { - // Fire forge event - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, slotContainerStack)); - - // Null the container stack - slotContainerStack = null; - } - } - - // Did we not kill the container item? - if (slotContainerStack != null) { + if (slotContainerStack.isItemStackDamageable() + && slotContainerStack.getItemDamage() >= slotContainerStack.getMaxDamage()) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, slotContainerStack)); + } else { + // Did we not kill the container item? /* * Should the item stay in the crafting grid, or if it is supposed to go back to the players * inventory but can't? @@ -147,15 +135,13 @@ public class SlotArcaneCraftingResult extends SlotCrafting { || !player.inventory.addItemStackToInventory(slotContainerStack)) { // Place it back in the grid this.terminalInventory.setInventorySlotContents(slotIndex, slotContainerStack); - - // Set NOT to decrement - shouldDecrement = false; + continue; } } } // If decrementing it would result in it being empty, ask the ME system for a replenishment. - if (shouldDecrement && (slotStack.stackSize == 1)) { + if (slotStack.stackSize == 1) { // First check if we can replenish it from the ME network ItemStack replenishment = this.hostContianer.requestCraftingReplenishment(slotStack); @@ -166,16 +152,12 @@ public class SlotArcaneCraftingResult extends SlotCrafting { // Set the slot contents to the replenishment this.terminalInventory.setInventorySlotContents(slotIndex, replenishment); } - - // And mark not to decrement - shouldDecrement = false; + continue; } } - // Decrement the stack? - if (shouldDecrement) { - this.terminalInventory.decrStackSize(slotIndex, 1); - } + // Decrement the stack + this.terminalInventory.decrStackSize(slotIndex, 1); } }