diff --git a/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/grid/CraftingGridBehavior.java b/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/grid/CraftingGridBehavior.java index c11ed9b9a..c9d7e27fc 100644 --- a/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/grid/CraftingGridBehavior.java +++ b/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/grid/CraftingGridBehavior.java @@ -195,9 +195,12 @@ public class CraftingGridBehavior implements ICraftingGridBehavior { if (recipe[i] != null) { ItemStack[] possibilities = recipe[i]; - if (network != null && grid.isGridActive()) { + if (network != null && grid.isGridActive() && network.getItemStorageCache() != null) { // sort by the number of items in storage - Arrays.sort(possibilities, Comparator.comparingInt((ItemStack a) -> network.extractItem(a, Integer.MAX_VALUE, IComparer.COMPARE_NBT, Action.SIMULATE).getCount()).reversed()); + Arrays.sort(possibilities, Comparator.comparingInt((ItemStack a) -> { + ItemStack stack = network.getItemStorageCache().getList().get(a); + return stack == null ? 0 : stack.getCount(); + }).reversed()); } // If we are a crafting grid