Skip to content

Commit

Permalink
Only accept known items in EMC Interface inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Apr 30, 2024
1 parent 19d40d8 commit fd64afe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import appeng.api.stacks.AEItemKey;
import appeng.api.stacks.AEKey;
import appeng.api.stacks.GenericStack;
import appeng.api.storage.AEKeyFilter;
import appeng.api.storage.MEStorage;
import appeng.capabilities.Capabilities;
import appeng.helpers.externalstorage.GenericStackItemStorage;
Expand Down Expand Up @@ -67,7 +68,7 @@ public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host) {
public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host, int slots) {
this.host = host;
config = ConfigInventory.configStacks(AEItemKey.filter(), slots, this::onConfigRowChanged, false);
storage = ConfigInventory.storage(slots, this::onStorageChanged);
storage = ConfigInventory.storage(new StorageFilter(), slots, this::onStorageChanged);

mainNode = node.setFlags(GridFlags.REQUIRE_CHANNEL).addService(IGridTickable.class, this);
plannedWork = new GenericStack[slots];
Expand Down Expand Up @@ -411,4 +412,14 @@ public int getPriority() {
return priority;
}
}

private class StorageFilter implements AEKeyFilter {
@Override
public boolean matches(AEKey what) {
var grid = mainNode.getGrid();
return grid != null
&& what instanceof AEItemKey item
&& grid.getService(KnowledgeService.class).knowsItem(item);
}
}
}

0 comments on commit fd64afe

Please sign in to comment.