1212
1313import appeng .api .behaviors .ExternalStorageStrategy ;
1414import appeng .api .config .Actionable ;
15+ import appeng .api .config .BlockingMode ;
1516import appeng .api .config .Settings ;
1617import appeng .api .networking .security .IActionSource ;
1718import appeng .api .stacks .AEKey ;
2324import appeng .util .BlockApiCache ;
2425import appeng .util .ConfigManager ;
2526
26- public class PatternProviderTargetCache {
27+ class PatternProviderTargetCache {
2728 private final BlockApiCache <MEStorage > cache ;
2829 private final Direction direction ;
2930 private final IActionSource src ;
3031 private final Map <AEKeyType , ExternalStorageStrategy > strategies ;
3132 private final ConfigManager configManager ;
33+ private BlockingMode blockingMode ;
34+
35+ PatternProviderTargetCache (ServerLevel l , BlockPos pos , Direction direction , IActionSource src ) {
36+ this (l , pos , direction , src , null );
37+ }
3238
3339 PatternProviderTargetCache (ServerLevel l , BlockPos pos , Direction direction , IActionSource src ,
3440 ConfigManager configManager ) {
@@ -73,7 +79,11 @@ public long insert(AEKey what, long amount, Actionable type) {
7379
7480 @ Override
7581 public boolean containsPatternInput (Set <AEKey > patternInputs ) {
76- switch (configManager .getSetting (Settings .BLOCKING_MODE_EXTRA )) {
82+ var mode = blockingMode == null
83+ ? (configManager == null ? BlockingMode .DEFAULT
84+ : configManager .getSetting (Settings .BLOCKING_MODE_EXTRA ))
85+ : blockingMode ;
86+ switch (mode ) {
7787 case ALL -> {
7888 for (var stack : storage .getAvailableStacks ()) {
7989 if (stack .getKey ().getId ().equals (programmedCircuit ))
@@ -91,15 +101,20 @@ public boolean containsPatternInput(Set<AEKey> patternInputs) {
91101 }
92102 case SMART -> {
93103 for (var stack : storage .getAvailableStacks ()) {
94- if (patternInputs .contains (stack .getKey ().dropSecondary ())
95- || stack .getKey ().getId ().equals (programmedCircuit ))
104+ if (stack .getKey ().getId ().equals (programmedCircuit ))
96105 continue ;
97- return true ;
106+ if (!patternInputs .contains (stack .getKey ().dropSecondary ()))
107+ return true ;
98108 }
99109 }
100110 }
101111 return false ;
102112 }
113+
114+ @ Override
115+ public void setBlockingMode (BlockingMode mode ) {
116+ blockingMode = mode ;
117+ }
103118 };
104119 }
105120}
0 commit comments