Skip to content

Commit

Permalink
Prevent the Transmutation Interface from accepting items into network…
Browse files Browse the repository at this point in the history
… storage when missing a channel
  • Loading branch information
62832 committed May 14, 2024
1 parent 1fa3b15 commit e8f198c
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions src/main/java/gripe/_90/appliede/me/misc/EMCInterfaceLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host, Item

config = ConfigInventory.configStacks(AEItemKey.filter(), slots, this::onConfigRowChanged, false);
storage = ConfigInventory.storage(this::storageFilter, slots, this::onStorageChanged);
upgrades = UpgradeInventories.forMachine(is, 1, this::onUpgradesChanged);
upgrades = UpgradeInventories.forMachine(is, 1, host::saveChanges);

localInvHandler = new DelegatingMEInventory(storage);
plannedWork = new GenericStack[slots];
Expand Down Expand Up @@ -126,7 +126,7 @@ private boolean storageFilter(AEKey what) {

var knowledge = grid.getService(KnowledgeService.class);
return knowledge.knowsItem(item)
|| (upgrades.isInstalled(AppliedE.LEARNING_CARD.get())
|| (isUpgradedWith(AppliedE.LEARNING_CARD.get())
&& IEMCProxy.INSTANCE.hasValue(item.toStack())
&& knowledge.getProviderFor(uuid) != null);
}
Expand Down Expand Up @@ -253,11 +253,7 @@ private boolean tryUsePlan(int slot, AEKey what, int amount) {
var depositedItems = grid.getService(KnowledgeService.class)
.getStorage()
.insertItem(
item,
amount,
Actionable.MODULATE,
source,
upgrades.isInstalled(AppliedE.LEARNING_CARD.get()));
item, amount, Actionable.MODULATE, source, isUpgradedWith(AppliedE.LEARNING_CARD.get()));

if (depositedItems > 0) {
storage.extract(slot, what, depositedItems, Actionable.MODULATE);
Expand Down Expand Up @@ -311,14 +307,6 @@ private void onStorageChanged() {
updatePlan();
}

private void onUpgradesChanged() {
if (emcStorage != null) {
emcStorage.setMayLearn(upgrades.isInstalled(AppliedE.LEARNING_CARD.get()));
}

host.saveChanges();
}

public void notifyNeighbours() {
mainNode.ifPresent((grid, node) -> {
if (node.isActive()) {
Expand Down Expand Up @@ -377,23 +365,18 @@ public void invalidateCaps() {
localInvHolder.invalidate();
}

private static class WrappedEMCStorage implements MEStorage {
private class WrappedEMCStorage implements MEStorage {
private final EMCStorage storage;
private boolean mayLearn;

private WrappedEMCStorage(EMCStorage storage) {
this.storage = storage;
}

private void setMayLearn(boolean mayLearn) {
this.mayLearn = mayLearn;
}

@Override
public long insert(AEKey what, long amount, Actionable mode, IActionSource source) {
return what instanceof AEItemKey item
? storage.insertItem(item, amount, mode, source, mayLearn)
: storage.insert(what, amount, mode, source);
return what instanceof AEItemKey item && mainNode.isActive()
? storage.insertItem(item, amount, mode, source, isUpgradedWith(AppliedE.LEARNING_CARD.get()))
: localInvHandler.insert(what, amount, mode, source);
}

@Override
Expand Down

0 comments on commit e8f198c

Please sign in to comment.