6262import java .util .Set ;
6363import java .util .stream .Collectors ;
6464
65- public class AppEngApi {
65+ public class AEApi {
6666
6767 public static Pair <Long , AEItemKey > findAEStackFromStack (MEStorage monitor , @ Nullable ICraftingService crafting , ItemStack item ) {
6868 return findAEStackFromFilter (monitor , crafting , ItemFilter .fromStack (item ));
@@ -238,7 +238,7 @@ public static List<IPatternDetails> getPatterns(IGrid grid, Level level) {
238238 }
239239
240240 public static List <Object > listPatterns (IGrid grid , Level level ) {
241- return getPatterns (grid , level ).stream ().map (AppEngApi ::parsePattern ).collect (Collectors .toList ());
241+ return getPatterns (grid , level ).stream ().map (AEApi ::parsePattern ).collect (Collectors .toList ());
242242 }
243243
244244 public static List <Object > listDrives (IGrid grid ) {
@@ -367,8 +367,8 @@ private static Map<String, Object> parseChemStack(Pair<Long, MekanismKey> stack)
367367 public static Map <String , Object > parsePattern (IPatternDetails pattern ) {
368368 Map <String , Object > map = new HashMap <>();
369369
370- map .put ("inputs" , Arrays .stream (pattern .getInputs ()).map (AppEngApi ::parsePatternInput ).collect (Collectors .toList ()));
371- map .put ("outputs" , Arrays .stream (pattern .getOutputs ()).map (AppEngApi ::parseGenericStack ).collect (Collectors .toList ()));
370+ map .put ("inputs" , Arrays .stream (pattern .getInputs ()).map (AEApi ::parsePatternInput ).collect (Collectors .toList ()));
371+ map .put ("outputs" , Arrays .stream (pattern .getOutputs ()).map (AEApi ::parseGenericStack ).collect (Collectors .toList ()));
372372 map .put ("primaryOutput" , parseGenericStack (pattern .getPrimaryOutput ()));
373373 return map ;
374374 }
@@ -378,7 +378,7 @@ public static Map<String, Object> parsePatternInput(IPatternDetails.IInput patte
378378 map .put ("primaryInput" , parseGenericStack (patternInput .getPossibleInputs ()[0 ]));
379379 map .put ("possibleInputs" ,
380380 Arrays .stream (Arrays .copyOfRange (patternInput .getPossibleInputs (), 1 , patternInput .getPossibleInputs ().length ))
381- .map (AppEngApi ::parseGenericStack ));
381+ .map (AEApi ::parseGenericStack ));
382382 map .put ("multiplier" , patternInput .getMultiplier ());
383383 map .put ("remaining" , patternInput .getRemainingKey (patternInput .getPossibleInputs ()[0 ].what ()));
384384 return map ;
@@ -417,14 +417,8 @@ public static MEStorage getMonitor(IGridNode node) {
417417 return node .getGrid ().getService (IStorageService .class ).getInventory ();
418418 }
419419
420- public static boolean isItemCrafting ( MEStorage monitor , ICraftingService grid , ItemFilter filter ,
420+ public static boolean isCrafting ( ICraftingService grid , GenericFilter <?> filter ,
421421 @ Nullable ICraftingCPU craftingCPU ) {
422- Pair <Long , AEItemKey > stack = AppEngApi .findAEStackFromFilter (monitor , grid , filter );
423-
424- // If the item stack does not exist, it cannot be crafted.
425- if (stack == null )
426- return false ;
427-
428422 // If the passed cpu is null, check all cpus
429423 if (craftingCPU == null ) {
430424 // Loop through all crafting cpus and check if the item is being crafted.
@@ -436,45 +430,7 @@ public static boolean isItemCrafting(MEStorage monitor, ICraftingService grid, I
436430 if (jobStatus == null )
437431 continue ;
438432
439- if (jobStatus .crafting ().what ().equals (stack .getRight ()))
440- return true ;
441- }
442- }
443- } else {
444- if (craftingCPU .isBusy ()) {
445- CraftingJobStatus jobStatus = craftingCPU .getJobStatus ();
446-
447- // avoid null pointer exception
448- if (jobStatus == null )
449- return false ;
450-
451- return jobStatus .crafting ().what ().equals (stack .getRight ());
452- }
453- }
454-
455- return false ;
456- }
457-
458- public static boolean isFluidCrafting (MEStorage monitor , ICraftingService grid , FluidFilter filter ,
459- @ Nullable ICraftingCPU craftingCPU ) {
460- Pair <Long , AEFluidKey > stack = AppEngApi .findAEFluidFromFilter (monitor , grid , filter );
461-
462- // If the fluid stack does not exist, it cannot be crafted.
463- if (stack == null )
464- return false ;
465-
466- // If the passed cpu is null, check all cpus
467- if (craftingCPU == null ) {
468- // Loop through all crafting cpus and check if the fluid is being crafted.
469- for (ICraftingCPU cpu : grid .getCpus ()) {
470- if (cpu .isBusy ()) {
471- CraftingJobStatus jobStatus = cpu .getJobStatus ();
472-
473- // avoid null pointer exception
474- if (jobStatus == null )
475- continue ;
476-
477- if (jobStatus .crafting ().what ().equals (stack .getRight ()))
433+ if (filter .testAE (jobStatus .crafting ()))
478434 return true ;
479435 }
480436 }
@@ -486,7 +442,7 @@ public static boolean isFluidCrafting(MEStorage monitor, ICraftingService grid,
486442 if (jobStatus == null )
487443 return false ;
488444
489- return jobStatus . crafting (). what (). equals ( stack . getRight ());
445+ return filter . testAE ( jobStatus . crafting ());
490446 }
491447 }
492448
0 commit comments