Skip to content

Commit

Permalink
Fixed Quantum Computer voiding secondary outputs of recipes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroksl committed Sep 14, 2024
1 parent 9ae07a0 commit fb2c518
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ loader_version_range=[4,)
mod_id=advanced_ae
mod_name=Advanced AE
mod_license=LGPL-3.0
mod_version=0.4.4-1.21.1
mod_version=0.4.5-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.
use_Xei=rei
use_Xei=emi
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public CpuSelectionMode getSelectionMode() {
return cluster.getSelectionMode();
}

public boolean isInventoryEmpty() {
return this.getInventory().list.isEmpty();
}

public void markDirty() {
cluster.markDirty();
}
Expand All @@ -109,6 +113,10 @@ public ListCraftingInventory getInventory() {
return craftingLogic.getInventory();
}

public void deactivate() {
cluster.deactivate(plan);
}

public IActionSource getSrc() {
return cluster.getSrc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ public ICraftingSubmitResult submitJob(
}

private void killCpu(ICraftingPlan plan, boolean updateGrid) {
var cpu = this.activeCpus.remove(plan);
var cpu = this.activeCpus.get(plan);
cpu.craftingLogic.cancel();
cpu.craftingLogic.markForDeletion();
recalculateRemainingStorage();
if (updateGrid) {
updateGridForChangedCpu(this);
Expand All @@ -246,14 +247,21 @@ private void killCpu(ICraftingPlan plan) {
killCpu(plan, true);
}

protected void deactivate(ICraftingPlan plan) {
this.activeCpus.remove(plan);
recalculateRemainingStorage();
updateGridForChangedCpu(this);
}

public List<AdvCraftingCPU> getActiveCPUs() {
var list = new ArrayList<AdvCraftingCPU>();
var killList = new ArrayList<ICraftingPlan>();
for (var cpu : activeCpus.entrySet()) {
if (cpu.getValue().craftingLogic.hasJob()) {
list.add(cpu.getValue());
for (var cpuEntry : activeCpus.entrySet()) {
var cpu = cpuEntry.getValue();
if (cpu.craftingLogic.hasJob() || cpu.craftingLogic.isMarkedForDeletion()) {
list.add(cpu);
} else {
killList.add(cpu.getKey());
killList.add(cpuEntry.getKey());
}
}
for (var cpu : killList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class AdvCraftingCPULogic {

private long lastModifiedOnTick = TickHandler.instance().getCurrentTick();

private boolean markedForDeletion = false;

public AdvCraftingCPULogic(AdvCraftingCPU cpu) {
this.cpu = cpu;
}
Expand Down Expand Up @@ -118,6 +120,10 @@ public void tickCraftingLogic(IEnergyService eg, CraftingService cc) {
this.storeItems();
if (!this.inventory.list.isEmpty()) {
cantStoreItems = true;
} else {
if (markedForDeletion) {
cpu.deactivate();
}
}
return;
}
Expand Down Expand Up @@ -308,7 +314,9 @@ private void finishJob(boolean success) {
// TODO: log

// Clear waitingFor list and post all the relevant changes.
job.waitingFor.clear();
if (!success) {
job.waitingFor.clear();
}
// Notify opened menus of cancelled scheduled tasks.
for (var entry : job.tasks.entrySet()) {
for (var output : entry.getKey().getOutputs()) {
Expand Down Expand Up @@ -505,4 +513,12 @@ private void notifyJobOwner(ExecutingCraftingJob job, CraftingJobStatusPacket.St
connectedPlayer.connection.send(message);
}
}

public boolean isMarkedForDeletion() {
return this.markedForDeletion;
}

public void markForDeletion() {
this.markedForDeletion = true;
}
}

0 comments on commit fb2c518

Please sign in to comment.