Skip to content

Commit f9ebbe2

Browse files
committed
Small fixes to the quantum crafter
1 parent 82345b9 commit f9ebbe2

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ loader_version_range=[4,)
1414
mod_id=advanced_ae
1515
mod_name=Advanced AE
1616
mod_license=LGPL-3.0
17-
mod_version=0.4.6-1.21.1
17+
mod_version=0.5.1-1.21.1
1818
mod_group_id=net.pedroksl.advanced_ae
1919
mod_authors=Pedroksl
2020
mod_description=This mod aims to expand on the added capabilities of Extended AE.

src/main/java/net/pedroksl/advanced_ae/common/entities/QuantumCrafterEntity.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public class QuantumCrafterEntity extends AENetworkedPoweredBlockEntity
8989

9090
private boolean initialized = false;
9191
private boolean working = false;
92-
private int currentCraftJob = 0;
9392
private YesNo lastRedstoneState;
9493

9594
private final IActionSource mySrc;
@@ -341,7 +340,7 @@ private int maximumCraftableAmount(CraftingJob job) {
341340
}
342341

343342
var producedAmount = job.outputAmountPerCraft(output);
344-
;
343+
345344
int limitByOutput = (int) Math.floor((double) (maxStock - extracted - amountInOutput) / producedAmount);
346345
totalCrafts = Math.max(0, Math.min(totalCrafts, limitByOutput));
347346
if (extracted <= maxStock) {
@@ -428,12 +427,10 @@ public TickRateModulation tickingRequest(IGridNode iGridNode, int i) {
428427
}
429428

430429
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);
435432

436-
if (job == null || !enabledPatternSlots.get(this.currentCraftJob)) {
433+
if (job == null || !enabledPatternSlots.get(x)) {
437434
continue;
438435
}
439436

@@ -535,9 +532,9 @@ private void performCraft(CraftingJob job, int toCraft) {
535532
}
536533
}
537534

538-
private @Nullable CraftingJob getNextJob() {
535+
private @Nullable CraftingJob getNextJob(int jobIndex) {
539536
try {
540-
var job = craftingJobs.get(this.currentCraftJob);
537+
var job = craftingJobs.get(jobIndex);
541538
return job == null || job.pattern == null ? null : job;
542539
} catch (IndexOutOfBoundsException e) {
543540
return null;
@@ -560,13 +557,18 @@ private boolean exportToMe() {
560557
if (this.getGridNode() == null) return false;
561558

562559
var storage = this.getGridNode().getGrid().getStorageService();
560+
var energy = this.getGridNode().getGrid().getEnergyService();
563561
var inventory = storage.getInventory();
564562

565563
var success = false;
566564
for (var x = 0; x < this.outputInv.size(); x++) {
567565
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);
570572
extractStack.setCount(extractStack.getCount() - (int) inserted);
571573
this.outputInv.insertItem(x, extractStack, false);
572574

@@ -977,12 +979,18 @@ public void setMinimumInputToKeep(int inputIndex, long value) {
977979
public long requiredInputTotal(GenericStack input, int toCraft) {
978980
long multiplier = 0;
979981
for (var i : pattern.getInputs()) {
982+
var found = false;
980983
for (var genInput : i.getPossibleInputs()) {
981984
if (input.what().matches(genInput)) {
982985
multiplier = i.getMultiplier() * input.amount();
986+
found = true;
983987
break;
984988
}
985989
}
990+
991+
if (found) {
992+
break;
993+
}
986994
}
987995

988996
if (!isInputConsumed(input)) {
Loading

0 commit comments

Comments
 (0)