From e353efe95c0ef83df452a0553accc3566eab5a29 Mon Sep 17 00:00:00 2001 From: Darkere Date: Thu, 13 May 2021 15:14:02 +0200 Subject: [PATCH] use storage cache instead of simulated extraction --- .../apiimpl/network/grid/CraftingGridBehavior.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 c11ed9b9a0..c9d7e27fc5 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 void onRecipeTransfer(INetworkAwareGrid grid, PlayerEntity player, ItemSt 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