From 9fdfbbea54dd8b39ad04174ca9547d76a4bfda0f Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Thu, 13 Jul 2023 21:57:39 -0300 Subject: [PATCH] more null checks --- gradle.properties | 2 +- .../ContainerCraftConfirm.java | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 346bf5981..25b80b158 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,7 +42,7 @@ modId=appliedenergistics2 modGroup=appeng # Version of your mod. # This field can be left empty if you want your mod's version to be determined by the latest git tag instead. -modVersion=rv6-stable-7-extended_life-v0.55.17 +modVersion=rv6-stable-7-extended_life-v0.55.18 # Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version) includeMCVersionJar=false # The name of your jar when you produce builds, not including any versioning info diff --git a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java index af65f5860..c2fb67792 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java @@ -23,6 +23,7 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGrid; +import appeng.api.networking.IGridNode; import appeng.api.networking.crafting.ICraftingCPU; import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.crafting.ICraftingJob; @@ -125,7 +126,19 @@ public class ContainerCraftConfirm extends AEBaseContainer { return; } - final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); + final IActionHost h = ((IActionHost) this.getTarget()); + if (h == null) { + this.setValidContainer(false); + return; + } + IGridNode node = h.getActionableNode(); + if (node == null) { + this.setValidContainer(false); + return; + } + IGrid grid = node.getGrid(); + + final ICraftingGrid cc = grid.getCache(ICraftingGrid.class); final ImmutableSet cpuSet = cc.getCpus(); int matches = 0; @@ -199,7 +212,7 @@ public class ContainerCraftConfirm extends AEBaseContainer { p.reset(); p.setStackSize(out.getCountRequestable()); - final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class); + final IStorageGrid sg = grid.getCache(IStorageGrid.class); final IMEInventory items = sg.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); IAEItemStack m = null; @@ -252,11 +265,6 @@ public class ContainerCraftConfirm extends AEBaseContainer { this.verifyPermissions(SecurityPermissions.CRAFT, false); } - private IGrid getGrid() { - final IActionHost h = ((IActionHost) this.getTarget()); - return h.getActionableNode().getGrid(); - } - private boolean cpuMatches(final ICraftingCPU c) { return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy(); } @@ -301,12 +309,22 @@ public class ContainerCraftConfirm extends AEBaseContainer { originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL; } + final IActionHost h = ((IActionHost) this.getTarget()); + if (h == null) { + return; + } + IGridNode node = h.getActionableNode(); + if (node == null) { + return; + } + IGrid grid = node.getGrid(); + if (this.result != null && !this.isSimulation()) { - final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); + final ICraftingGrid cc = grid.getCache(ICraftingGrid.class); final ICraftingLink g = cc.submitJob(this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get(this.getSelectedCpu()).getCpu(), true, this.getActionSrc()); this.setAutoStart(false); if (g == null) { - this.setJob(cc.beginCraftingJob(this.getWorld(), this.getGrid(), this.getActionSrc(), this.result.getOutput(), null)); + this.setJob(cc.beginCraftingJob(this.getWorld(), grid, this.getActionSrc(), this.result.getOutput(), null)); } else if (originalGui != null && this.getOpenContext() != null) { final TileEntity te = this.getOpenContext().getTile(); if (te != null) {