Skip to content

Commit

Permalink
Ported fix for quantum computer voiding secondary outputs from 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroksl committed Sep 16, 2024
1 parent eb152aa commit e2c667d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1
mod_id=advanced_ae
mod_name=Advanced AE
mod_license=LGPL-3.0
mod_version=0.3.2-1.20.1
mod_version=0.3.3-1.20.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.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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 @@ -233,8 +233,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 @@ -245,14 +246,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 @@ -59,6 +59,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 @@ -115,6 +117,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 @@ -498,4 +504,12 @@ private void notifyJobOwner(ExecutingCraftingJob job, CraftingJobStatusPacket.St
connectedPlayer);
}
}

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

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

0 comments on commit e2c667d

Please sign in to comment.