Skip to content

Commit

Permalink
Icon changed and small logic tweak to always filter inputs if filtere…
Browse files Browse the repository at this point in the history
…d input is set
  • Loading branch information
pedroksl committed Jan 10, 2025
1 parent 1955ccf commit 2d37b57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.pedroksl.advanced_ae.api.AAESettings;
import net.pedroksl.advanced_ae.common.logic.AdvPatternProviderLogic;

import java.util.HashSet;
import java.util.Set;

public class AdvPatternProviderReturnInventory extends PatternProviderReturnInventory {
Expand All @@ -15,15 +16,18 @@ public AdvPatternProviderReturnInventory(Runnable listener, AdvPatternProviderLo
this.setFilter((slot, what) -> {
var filter = logic.getConfigManager().getSetting(AAESettings.FILTERED_IMPORT);
if (filter != YesNo.YES) return true;
Set<AEKey> tracked = logic.getTrackedCrafts();
if (tracked.isEmpty()) return true;

for (AEKey craft : tracked) {
if (what.equals(craft)) {
return true;
Set<AEKey> tracked = logic.getTrackedCrafts();
if (!tracked.isEmpty()) {
for (AEKey craft : tracked) {
if (what.equals(craft)) {
return true;
}
}
}
return false;

HashSet<AEKey> cached = logic.getOutputCache();
return cached.stream().anyMatch(what::equals);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class AdvPatternProviderLogic implements InternalInventoryHost, ICrafting
private final PatternProviderReturnInventory returnInv;

private final AdvPatternProviderTargetCache[] targetCaches = new AdvPatternProviderTargetCache[6];
private final HashSet<AEKey> outputCache = new HashSet<>();

private YesNo redstoneState = YesNo.UNDECIDED;

Expand Down Expand Up @@ -291,6 +292,7 @@ public boolean isClientSide() {
public void updatePatterns() {
patterns.clear();
patternInputs.clear();
outputCache.clear();
if (craftingWatcher != null) {
craftingWatcher.reset();
}
Expand All @@ -305,6 +307,7 @@ public void updatePatterns() {
if (craftingWatcher != null) {
for (var output : details.getOutputs()) {
craftingWatcher.add(output.what());
outputCache.add(output.what());
}
}

Expand Down Expand Up @@ -819,6 +822,10 @@ public Set<AEKey> getTrackedCrafts() {
return trackedCrafts;
}

public HashSet<AEKey> getOutputCache() {
return outputCache;
}

private class Ticker implements IGridTickable {

@Override
Expand Down

0 comments on commit 2d37b57

Please sign in to comment.