From 42a02bd64c06b9bbf71693292240242be78b15d0 Mon Sep 17 00:00:00 2001 From: 90 Date: Wed, 8 May 2024 22:11:07 +0100 Subject: [PATCH] Restrict EMC item filling to Transmutation Terminal, and fix being able to fill items from higher EMC tiers and wasting too much --- .../appliede/me/strategy/EMCContainerItemStrategy.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/gripe/_90/appliede/me/strategy/EMCContainerItemStrategy.java b/src/main/java/gripe/_90/appliede/me/strategy/EMCContainerItemStrategy.java index b106c70..be13ee8 100644 --- a/src/main/java/gripe/_90/appliede/me/strategy/EMCContainerItemStrategy.java +++ b/src/main/java/gripe/_90/appliede/me/strategy/EMCContainerItemStrategy.java @@ -12,6 +12,7 @@ import appeng.api.stacks.GenericStack; import gripe._90.appliede.me.key.EMCKey; +import gripe._90.appliede.menu.TransmutationTerminalMenu; import moze_intel.projecte.api.capabilities.PECapabilities; import moze_intel.projecte.api.capabilities.block_entity.IEmcStorage; @@ -32,6 +33,10 @@ public GenericStack getContainedStack(ItemStack stack) { @Nullable @Override public ItemStack findCarriedContext(Player player, AbstractContainerMenu menu) { + if (!(menu instanceof TransmutationTerminalMenu)) { + return null; + } + var carried = menu.getCarried(); return carried.getCapability(PECapabilities.EMC_HOLDER_ITEM_CAPABILITY).isPresent() ? carried : null; } @@ -46,6 +51,10 @@ public long extract(ItemStack context, EMCKey what, long amount, Actionable mode @Override public long insert(ItemStack context, EMCKey what, long amount, Actionable mode) { + if (what != EMCKey.BASE) { + return 0; + } + var action = mode.isSimulate() ? IEmcStorage.EmcAction.SIMULATE : IEmcStorage.EmcAction.EXECUTE; return context.getCapability(PECapabilities.EMC_HOLDER_ITEM_CAPABILITY) .map(handler -> handler.insertEmc(context, amount, action))