Skip to content

Commit 8076602

Browse files
committed
Fix fluid level maintainer deadlock and remove console spam
1 parent 4149c35 commit 8076602

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/main/java/com/glodblock/github/common/tile/TileFluidLevelMaintainer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class TileFluidLevelMaintainer extends AENetworkTile implements ICrafting
4646
public static final int MAX_FLUID = 5;
4747
private int tick = 0;
4848

49+
public boolean forceNextTick = false;
50+
4951
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, MAX_FLUID) {
5052
@Override
5153
public int getSlotLimit(int slot) {
@@ -128,7 +130,7 @@ public void doWork() {
128130
if (remain == null || remain.getStackSize() < fluid.amount) {
129131
FluidStack copy = fluid.copy();
130132
copy.amount = (int) request[i];
131-
System.out.print(this.craftingTracker.handleCrafting(i, request[i], ItemFluidDrop.newAeStack(copy), DummyInvAdaptor.INSTANCE, getWorld(), getProxy().getGrid(), getProxy().getCrafting(), this.source) + "\n");
133+
this.craftingTracker.handleCrafting(i, request[i], ItemFluidDrop.newAeStack(copy), DummyInvAdaptor.INSTANCE, getWorld(), getProxy().getGrid(), getProxy().getCrafting(), this.source);
132134
}
133135
}
134136
}
@@ -257,7 +259,11 @@ public void onChangeInventory(IItemHandler iItemHandler, int i, InvOperation inv
257259
public void update() {
258260
if (!getWorld().isRemote) {
259261
tick ++;
260-
if (tick > 1200) {
262+
if (forceNextTick) {
263+
forceNextTick = false;
264+
doWork();
265+
}
266+
else if (tick > 1200) {
261267
tick = 0;
262268
doWork();
263269
}

src/main/java/com/glodblock/github/util/MultiCraftingTracker.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import appeng.api.storage.data.IAEItemStack;
88
import appeng.helpers.NonNullArrayIterator;
99
import appeng.util.InventoryAdaptor;
10+
import com.glodblock.github.common.tile.TileFluidLevelMaintainer;
1011
import com.google.common.collect.ImmutableSet;
1112
import net.minecraft.item.ItemStack;
1213
import net.minecraft.nbt.NBTTagCompound;
@@ -63,34 +64,39 @@ public boolean handleCrafting(int x, long itemToCraft, IAEItemStack ais, Invento
6364

6465
if (remaining.isEmpty()) {
6566
ais.setCachedItemStack(inputStack);
66-
Future<ICraftingJob> craftingJob = this.getJob(x);
67+
Future<ICraftingJob> jobCalculation = this.getJob(x);
6768

6869
if (this.getLink(x) != null) {
6970
return false;
7071
}
7172

72-
if (craftingJob == null && this.getLink(x) == null) {
73+
if (jobCalculation == null && this.getLink(x) == null) {
7374
IAEItemStack aisC = ais.copy();
7475
aisC.setStackSize(itemToCraft);
7576
this.setJob(x, cg.beginCraftingJob(w, g, mySrc, aisC, null));
76-
craftingJob = this.getJob(x);
77+
jobCalculation = this.getJob(x);
7778
}
7879

79-
if (craftingJob == null) {
80+
if (jobCalculation == null) {
8081
return false;
8182
}
8283

8384
try {
84-
ICraftingJob job = craftingJob.get();
85-
86-
if (job != null) {
87-
ICraftingLink link = cg.submitJob(job, this.owner, null, false, mySrc);
88-
this.setJob(x, null);
89-
if (link != null) {
90-
this.setLink(x, link);
91-
return true;
85+
if (jobCalculation.isDone()) {
86+
ICraftingJob job = jobCalculation.get();
87+
88+
if (job != null) {
89+
ICraftingLink link = cg.submitJob(job, this.owner, null, false, mySrc);
90+
this.setJob(x, null);
91+
if (link != null) {
92+
this.setLink(x, link);
93+
return true;
94+
}
9295
}
9396
}
97+
else {
98+
((TileFluidLevelMaintainer)this.owner).forceNextTick = true;
99+
}
94100
} catch (InterruptedException | ExecutionException ignored) {
95101
}
96102
} else {

0 commit comments

Comments
 (0)