@@ -89,7 +89,6 @@ public class QuantumCrafterEntity extends AENetworkedPoweredBlockEntity
89
89
90
90
private boolean initialized = false ;
91
91
private boolean working = false ;
92
- private int currentCraftJob = 0 ;
93
92
private YesNo lastRedstoneState ;
94
93
95
94
private final IActionSource mySrc ;
@@ -341,7 +340,7 @@ private int maximumCraftableAmount(CraftingJob job) {
341
340
}
342
341
343
342
var producedAmount = job .outputAmountPerCraft (output );
344
- ;
343
+
345
344
int limitByOutput = (int ) Math .floor ((double ) (maxStock - extracted - amountInOutput ) / producedAmount );
346
345
totalCrafts = Math .max (0 , Math .min (totalCrafts , limitByOutput ));
347
346
if (extracted <= maxStock ) {
@@ -428,12 +427,10 @@ public TickRateModulation tickingRequest(IGridNode iGridNode, int i) {
428
427
}
429
428
430
429
private void performCrafts (int maxCrafts ) {
431
- this .currentCraftJob = -1 ;
432
- while (this .currentCraftJob <= craftingJobs .size ()) {
433
- this .currentCraftJob ++;
434
- var job = getNextJob ();
430
+ for (var x = 0 ; x < craftingJobs .size (); x ++) {
431
+ var job = getNextJob (x );
435
432
436
- if (job == null || !enabledPatternSlots .get (this . currentCraftJob )) {
433
+ if (job == null || !enabledPatternSlots .get (x )) {
437
434
continue ;
438
435
}
439
436
@@ -535,9 +532,9 @@ private void performCraft(CraftingJob job, int toCraft) {
535
532
}
536
533
}
537
534
538
- private @ Nullable CraftingJob getNextJob () {
535
+ private @ Nullable CraftingJob getNextJob (int jobIndex ) {
539
536
try {
540
- var job = craftingJobs .get (this . currentCraftJob );
537
+ var job = craftingJobs .get (jobIndex );
541
538
return job == null || job .pattern == null ? null : job ;
542
539
} catch (IndexOutOfBoundsException e ) {
543
540
return null ;
@@ -560,13 +557,18 @@ private boolean exportToMe() {
560
557
if (this .getGridNode () == null ) return false ;
561
558
562
559
var storage = this .getGridNode ().getGrid ().getStorageService ();
560
+ var energy = this .getGridNode ().getGrid ().getEnergyService ();
563
561
var inventory = storage .getInventory ();
564
562
565
563
var success = false ;
566
564
for (var x = 0 ; x < this .outputInv .size (); x ++) {
567
565
var extractStack = this .outputInv .extractItem (x , MAX_OUTPUT_INV_SIZE , false );
568
- var inserted = inventory .insert (
569
- AEItemKey .of (extractStack ), extractStack .getCount (), Actionable .MODULATE , this .mySrc );
566
+ var inserted = StorageHelper .poweredInsert (
567
+ energy ,
568
+ inventory ,
569
+ Objects .requireNonNull (AEItemKey .of (extractStack )),
570
+ extractStack .getCount (),
571
+ this .mySrc );
570
572
extractStack .setCount (extractStack .getCount () - (int ) inserted );
571
573
this .outputInv .insertItem (x , extractStack , false );
572
574
@@ -977,12 +979,18 @@ public void setMinimumInputToKeep(int inputIndex, long value) {
977
979
public long requiredInputTotal (GenericStack input , int toCraft ) {
978
980
long multiplier = 0 ;
979
981
for (var i : pattern .getInputs ()) {
982
+ var found = false ;
980
983
for (var genInput : i .getPossibleInputs ()) {
981
984
if (input .what ().matches (genInput )) {
982
985
multiplier = i .getMultiplier () * input .amount ();
986
+ found = true ;
983
987
break ;
984
988
}
985
989
}
990
+
991
+ if (found ) {
992
+ break ;
993
+ }
986
994
}
987
995
988
996
if (!isInputConsumed (input )) {
0 commit comments