From 75e4a0a51b7cbbecda517d8f866ccb91b7638cb4 Mon Sep 17 00:00:00 2001 From: Darkere Date: Sun, 5 Nov 2023 18:26:07 +0100 Subject: [PATCH] fix: rare autocrafting crash (cherry picked from commit ca4199c2105d25aa6394a440208aaffc93448a1f) --- .../task/v6/node/CraftingNode.java | 16 ++++++++++-- .../task/v6/node/NodeRequirements.java | 4 +-- .../task/v6/node/ProcessingNode.java | 26 ++++++++++++++++--- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/CraftingNode.java b/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/CraftingNode.java index 7687bb58ed..e73491f5d4 100644 --- a/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/CraftingNode.java +++ b/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/CraftingNode.java @@ -47,8 +47,20 @@ public void update(INetwork network, int ticks, NodeList nodes, IStorageDisk getSingleItemRequirementSet(boolean simulate) { } } } else { - throw new IllegalStateException("Bad!"); + return null; } } @@ -137,7 +137,7 @@ public List getSingleFluidRequirementSet(boolean simulate) { } } } else { - throw new IllegalStateException("Bad!"); + return null; } } diff --git a/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/ProcessingNode.java b/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/ProcessingNode.java index f6bdfc0410..09b865e4ab 100644 --- a/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/ProcessingNode.java +++ b/src/main/java/com/refinedmods/refinedstorage/apiimpl/autocrafting/task/v6/node/ProcessingNode.java @@ -121,10 +121,20 @@ public void update(INetwork network, int ticks, NodeList nodes, IStorageDisk extractedItems = IoUtil.extractFromInternalItemStorage(requirements.getSingleItemRequirementSet(true), internalStorage, Action.SIMULATE); + var simulatedRequirements = requirements.getSingleItemRequirementSet(true); + if(simulatedRequirements == null) { + return; + } + + List extractedItems = IoUtil.extractFromInternalItemStorage(simulatedRequirements, internalStorage, Action.SIMULATE); List extractedFluids = null; if (extractedItems != null) { - extractedFluids = IoUtil.extractFromInternalFluidStorage(requirements.getSingleFluidRequirementSet(true), internalFluidStorage, Action.SIMULATE); + var simulatedFluidRequirements = requirements.getSingleFluidRequirementSet(true); + if(simulatedFluidRequirements == null) { + return; + } + + extractedFluids = IoUtil.extractFromInternalFluidStorage(simulatedFluidRequirements, internalFluidStorage, Action.SIMULATE); if (extractedFluids != null) { hasAllRequirements = true; } @@ -151,9 +161,17 @@ public void update(INetwork network, int ticks, NodeList nodes, IStorageDisk