Skip to content

Commit fb2c518

Browse files
committed
Fixed Quantum Computer voiding secondary outputs of recipes.
1 parent 9ae07a0 commit fb2c518

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

Diff for: gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ 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.4-1.21.1
17+
mod_version=0.4.5-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.
21-
use_Xei=rei
21+
use_Xei=emi

Diff for: src/main/java/net/pedroksl/advanced_ae/common/cluster/AdvCraftingCPU.java

+8
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public CpuSelectionMode getSelectionMode() {
8585
return cluster.getSelectionMode();
8686
}
8787

88+
public boolean isInventoryEmpty() {
89+
return this.getInventory().list.isEmpty();
90+
}
91+
8892
public void markDirty() {
8993
cluster.markDirty();
9094
}
@@ -109,6 +113,10 @@ public ListCraftingInventory getInventory() {
109113
return craftingLogic.getInventory();
110114
}
111115

116+
public void deactivate() {
117+
cluster.deactivate(plan);
118+
}
119+
112120
public IActionSource getSrc() {
113121
return cluster.getSrc();
114122
}

Diff for: src/main/java/net/pedroksl/advanced_ae/common/cluster/AdvCraftingCPUCluster.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ public ICraftingSubmitResult submitJob(
234234
}
235235

236236
private void killCpu(ICraftingPlan plan, boolean updateGrid) {
237-
var cpu = this.activeCpus.remove(plan);
237+
var cpu = this.activeCpus.get(plan);
238238
cpu.craftingLogic.cancel();
239+
cpu.craftingLogic.markForDeletion();
239240
recalculateRemainingStorage();
240241
if (updateGrid) {
241242
updateGridForChangedCpu(this);
@@ -246,14 +247,21 @@ private void killCpu(ICraftingPlan plan) {
246247
killCpu(plan, true);
247248
}
248249

250+
protected void deactivate(ICraftingPlan plan) {
251+
this.activeCpus.remove(plan);
252+
recalculateRemainingStorage();
253+
updateGridForChangedCpu(this);
254+
}
255+
249256
public List<AdvCraftingCPU> getActiveCPUs() {
250257
var list = new ArrayList<AdvCraftingCPU>();
251258
var killList = new ArrayList<ICraftingPlan>();
252-
for (var cpu : activeCpus.entrySet()) {
253-
if (cpu.getValue().craftingLogic.hasJob()) {
254-
list.add(cpu.getValue());
259+
for (var cpuEntry : activeCpus.entrySet()) {
260+
var cpu = cpuEntry.getValue();
261+
if (cpu.craftingLogic.hasJob() || cpu.craftingLogic.isMarkedForDeletion()) {
262+
list.add(cpu);
255263
} else {
256-
killList.add(cpu.getKey());
264+
killList.add(cpuEntry.getKey());
257265
}
258266
}
259267
for (var cpu : killList) {

Diff for: src/main/java/net/pedroksl/advanced_ae/common/logic/AdvCraftingCPULogic.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public class AdvCraftingCPULogic {
6262

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

65+
private boolean markedForDeletion = false;
66+
6567
public AdvCraftingCPULogic(AdvCraftingCPU cpu) {
6668
this.cpu = cpu;
6769
}
@@ -118,6 +120,10 @@ public void tickCraftingLogic(IEnergyService eg, CraftingService cc) {
118120
this.storeItems();
119121
if (!this.inventory.list.isEmpty()) {
120122
cantStoreItems = true;
123+
} else {
124+
if (markedForDeletion) {
125+
cpu.deactivate();
126+
}
121127
}
122128
return;
123129
}
@@ -308,7 +314,9 @@ private void finishJob(boolean success) {
308314
// TODO: log
309315

310316
// Clear waitingFor list and post all the relevant changes.
311-
job.waitingFor.clear();
317+
if (!success) {
318+
job.waitingFor.clear();
319+
}
312320
// Notify opened menus of cancelled scheduled tasks.
313321
for (var entry : job.tasks.entrySet()) {
314322
for (var output : entry.getKey().getOutputs()) {
@@ -505,4 +513,12 @@ private void notifyJobOwner(ExecutingCraftingJob job, CraftingJobStatusPacket.St
505513
connectedPlayer.connection.send(message);
506514
}
507515
}
516+
517+
public boolean isMarkedForDeletion() {
518+
return this.markedForDeletion;
519+
}
520+
521+
public void markForDeletion() {
522+
this.markedForDeletion = true;
523+
}
508524
}

0 commit comments

Comments
 (0)