diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java index 285ed2a0c..147747883 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java @@ -75,41 +75,51 @@ public static Pair findAEFluidFromFilter(MEStorage monitor, @N return null; } - public static List listStacks(MEStorage monitor, ICraftingService service, int flag) { + public static List listStacks(MEStorage monitor, ICraftingService service) { List items = new ArrayList<>(); KeyCounter keyCounter = monitor.getAvailableStacks(); for (Object2LongMap.Entry aeKey : keyCounter) { if (aeKey.getKey() instanceof AEItemKey itemKey) { - if (flag == 1 && aeKey.getLongValue() < 0) { - continue; - } else if (flag == 2 && !service.isCraftable(itemKey)) { - service.getCraftables(AEKeyFilter.none()).forEach(aeKey1 -> { - Map itemObject = getObjectFromStack(Pair.of((long) 0, aeKey1), service); - if (keyCounter.get(aeKey1) == 0 && !items.contains(itemObject)) - items.add(itemObject); - }); - continue; - } - items.add(getObjectFromStack(Pair.of(aeKey.getLongValue(), itemKey), service)); } } return items; } - public static List listFluids(MEStorage monitor, ICraftingService service, int flag) { + public static List listCraftableStacks(MEStorage monitor, ICraftingService service) { + List items = new ArrayList<>(); + KeyCounter keyCounter = monitor.getAvailableStacks(); + Set craftables = service.getCraftables(AEKeyFilter.none()); + for (AEKey aeKey : craftables) { + if (aeKey instanceof AEItemKey) { + items.add(getObjectFromStack(Pair.of(keyCounter.get(aeKey), aeKey), service)); + } + } + return items; + } + + public static List listFluids(MEStorage monitor, ICraftingService service) { List items = new ArrayList<>(); for (Object2LongMap.Entry aeKey : monitor.getAvailableStacks()) { if (aeKey.getKey() instanceof AEFluidKey itemKey) { - if ((flag == 1 && aeKey.getLongValue() < 0) || (flag == 2 && !service.isCraftable(itemKey))) - continue; - items.add(getObjectFromStack(Pair.of(aeKey.getLongValue(), itemKey), service)); } } return items; } + public static List listCraftableFluids(MEStorage monitor, ICraftingService service) { + List items = new ArrayList<>(); + KeyCounter keyCounter = monitor.getAvailableStacks(); + Set craftables = service.getCraftables(AEKeyFilter.none()); + for (AEKey aeKey : craftables) { + if (aeKey instanceof AEFluidKey) { + items.add(getObjectFromStack(Pair.of(keyCounter.get(aeKey), aeKey), service)); + } + } + return items; + } + public static Map getObjectFromStack(Pair stack, @Nullable ICraftingService service) { if (stack.getRight() == null) return Collections.emptyMap(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java index be7392365..3b214fbc7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java @@ -358,7 +358,7 @@ public final MethodResult listItems() { if (!isConnected()) return notConnected(); - return MethodResult.of(AppEngApi.listStacks(AppEngApi.getMonitor(node), getCraftingService(), 0)); + return MethodResult.of(AppEngApi.listStacks(AppEngApi.getMonitor(node), getCraftingService())); } @LuaFunction(mainThread = true) @@ -366,7 +366,7 @@ public final MethodResult listCraftableItems() { if (!isConnected()) return notConnected(); - return MethodResult.of(AppEngApi.listStacks(AppEngApi.getMonitor(node), getCraftingService(), 2)); + return MethodResult.of(AppEngApi.listCraftableStacks(AppEngApi.getMonitor(node), getCraftingService())); } @LuaFunction(mainThread = true) @@ -374,7 +374,7 @@ public final MethodResult listFluid() { if (!isConnected()) return notConnected(); - return MethodResult.of(AppEngApi.listFluids(AppEngApi.getMonitor(node), getCraftingService(), 0)); + return MethodResult.of(AppEngApi.listFluids(AppEngApi.getMonitor(node), getCraftingService())); } @LuaFunction(mainThread = true) @@ -382,7 +382,7 @@ public final MethodResult listCraftableFluid() { if (!isConnected()) return notConnected(); - return MethodResult.of(AppEngApi.listFluids(AppEngApi.getMonitor(node), getCraftingService(), 2)); + return MethodResult.of(AppEngApi.listCraftableFluids(AppEngApi.getMonitor(node), getCraftingService())); } @LuaFunction(mainThread = true)