From b179f9dbc0dcdee8a3a1d0e8ff35e957430ab5e1 Mon Sep 17 00:00:00 2001 From: 90 Date: Wed, 26 Jun 2024 00:04:53 +0100 Subject: [PATCH] Do not consume extra power when reinserting leftover EMC-exported items --- .../_90/appliede/me/misc/LearnAllItemsPacket.java | 1 + .../gripe/_90/appliede/me/service/EMCStorage.java | 14 +++++++++++--- .../appliede/menu/TransmutationTerminalMenu.java | 1 + .../gripe/_90/appliede/part/EMCExportBusPart.java | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java b/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java index 259c099..1ed4719 100644 --- a/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java +++ b/src/main/java/gripe/_90/appliede/me/misc/LearnAllItemsPacket.java @@ -43,6 +43,7 @@ public void handle(Supplier context) { Actionable.MODULATE, IActionSource.ofPlayer(sender), true, + true, menu::showLearned); var me = storage.getInventory(); diff --git a/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java b/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java index 156f5e2..35538fa 100644 --- a/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java +++ b/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java @@ -147,7 +147,13 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour } public long insertItem( - AEItemKey what, long amount, Actionable mode, IActionSource source, boolean mayLearn, Runnable onLearn) { + AEItemKey what, + long amount, + Actionable mode, + IActionSource source, + boolean mayLearn, + boolean consumePower, + Runnable onLearn) { if (amount <= 0 || service.getProviders().isEmpty()) { return 0; } @@ -175,7 +181,9 @@ public long insertItem( var itemEmc = BigInteger.valueOf(IEMCProxy.INSTANCE.getSellValue(what.toStack())); var totalEmc = itemEmc.multiply(BigInteger.valueOf(amount)); - amount = getAmountAfterPowerExpenditure(totalEmc, itemEmc); + if (consumePower) { + amount = getAmountAfterPowerExpenditure(totalEmc, itemEmc); + } if (amount == 0) { return 0; @@ -205,7 +213,7 @@ public long insertItem( } public long insertItem(AEItemKey what, long amount, Actionable mode, IActionSource source, boolean mayLearn) { - return insertItem(what, amount, mode, source, mayLearn, () -> {}); + return insertItem(what, amount, mode, source, mayLearn, true, () -> {}); } public long extractItem(AEItemKey what, long amount, Actionable mode, IActionSource source, boolean skipStored) { diff --git a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java index d8bfff6..7e4a9e5 100644 --- a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java +++ b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java @@ -88,6 +88,7 @@ private int transmuteItem(ItemStack stack, boolean singleItem, Player player) { Actionable.MODULATE, IActionSource.ofPlayer(player), true, + true, this::showLearned); } diff --git a/src/main/java/gripe/_90/appliede/part/EMCExportBusPart.java b/src/main/java/gripe/_90/appliede/part/EMCExportBusPart.java index bcccaf1..da7f314 100644 --- a/src/main/java/gripe/_90/appliede/part/EMCExportBusPart.java +++ b/src/main/java/gripe/_90/appliede/part/EMCExportBusPart.java @@ -133,7 +133,8 @@ protected boolean doBusWork(IGrid grid) { if (wasInserted < extracted) { var leftover = extracted - wasInserted; - leftover -= networkEmc.insertItem(item, leftover, Actionable.MODULATE, source, false); + leftover -= networkEmc.insertItem( + item, leftover, Actionable.MODULATE, source, false, false, () -> {}); if (leftover > 0) { LOGGER.error(