Skip to content

Commit

Permalink
Small fixes to the quantum crafter
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroksl committed Sep 27, 2024
1 parent 82345b9 commit f9ebbe2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ loader_version_range=[4,)
mod_id=advanced_ae
mod_name=Advanced AE
mod_license=LGPL-3.0
mod_version=0.4.6-1.21.1
mod_version=0.5.1-1.21.1
mod_group_id=net.pedroksl.advanced_ae
mod_authors=Pedroksl
mod_description=This mod aims to expand on the added capabilities of Extended AE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public class QuantumCrafterEntity extends AENetworkedPoweredBlockEntity

private boolean initialized = false;
private boolean working = false;
private int currentCraftJob = 0;
private YesNo lastRedstoneState;

private final IActionSource mySrc;
Expand Down Expand Up @@ -341,7 +340,7 @@ private int maximumCraftableAmount(CraftingJob job) {
}

var producedAmount = job.outputAmountPerCraft(output);
;

int limitByOutput = (int) Math.floor((double) (maxStock - extracted - amountInOutput) / producedAmount);
totalCrafts = Math.max(0, Math.min(totalCrafts, limitByOutput));
if (extracted <= maxStock) {
Expand Down Expand Up @@ -428,12 +427,10 @@ public TickRateModulation tickingRequest(IGridNode iGridNode, int i) {
}

private void performCrafts(int maxCrafts) {
this.currentCraftJob = -1;
while (this.currentCraftJob <= craftingJobs.size()) {
this.currentCraftJob++;
var job = getNextJob();
for (var x = 0; x < craftingJobs.size(); x++) {
var job = getNextJob(x);

if (job == null || !enabledPatternSlots.get(this.currentCraftJob)) {
if (job == null || !enabledPatternSlots.get(x)) {
continue;
}

Expand Down Expand Up @@ -535,9 +532,9 @@ private void performCraft(CraftingJob job, int toCraft) {
}
}

private @Nullable CraftingJob getNextJob() {
private @Nullable CraftingJob getNextJob(int jobIndex) {
try {
var job = craftingJobs.get(this.currentCraftJob);
var job = craftingJobs.get(jobIndex);
return job == null || job.pattern == null ? null : job;
} catch (IndexOutOfBoundsException e) {
return null;
Expand All @@ -560,13 +557,18 @@ private boolean exportToMe() {
if (this.getGridNode() == null) return false;

var storage = this.getGridNode().getGrid().getStorageService();
var energy = this.getGridNode().getGrid().getEnergyService();
var inventory = storage.getInventory();

var success = false;
for (var x = 0; x < this.outputInv.size(); x++) {
var extractStack = this.outputInv.extractItem(x, MAX_OUTPUT_INV_SIZE, false);
var inserted = inventory.insert(
AEItemKey.of(extractStack), extractStack.getCount(), Actionable.MODULATE, this.mySrc);
var inserted = StorageHelper.poweredInsert(
energy,
inventory,
Objects.requireNonNull(AEItemKey.of(extractStack)),
extractStack.getCount(),
this.mySrc);
extractStack.setCount(extractStack.getCount() - (int) inserted);
this.outputInv.insertItem(x, extractStack, false);

Expand Down Expand Up @@ -977,12 +979,18 @@ public void setMinimumInputToKeep(int inputIndex, long value) {
public long requiredInputTotal(GenericStack input, int toCraft) {
long multiplier = 0;
for (var i : pattern.getInputs()) {
var found = false;
for (var genInput : i.getPossibleInputs()) {
if (input.what().matches(genInput)) {
multiplier = i.getMultiplier() * input.amount();
found = true;
break;
}
}

if (found) {
break;
}
}

if (!isInputConsumed(input)) {
Expand Down
Binary file modified src/main/resources/assets/ae2/textures/guis/quantum_crafter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f9ebbe2

Please sign in to comment.