use storage cache instead of simulated extraction

This commit is contained in:
Darkere
2021-05-13 15:14:02 +02:00
parent 6d4f794325
commit e353efe95c

View File

@@ -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