Skip to content

Commit

Permalink
use storage cache instead of simulated extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkere committed May 13, 2021
1 parent 6d4f794 commit e353efe
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e353efe

Please sign in to comment.