Skip to content

Commit

Permalink
Restrict EMC item filling to Transmutation Terminal, and fix being ab…
Browse files Browse the repository at this point in the history
…le to fill items from higher EMC tiers and wasting too much
  • Loading branch information
62832 committed May 8, 2024
1 parent d510b71 commit 42a02bd
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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))
Expand Down

0 comments on commit 42a02bd

Please sign in to comment.