Fix strand caster 2: electric boogaloo

Like, only cast if there is anything to cast, duh
This commit is contained in:
abel1502 2025-05-23 00:57:21 +03:00
parent 93638c3889
commit 81ca498fa8
No known key found for this signature in database
GPG Key ID: 076926596A536338

View File

@ -74,45 +74,43 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
this.updateConnections(); this.updateConnections();
ItemMold.Mold mold = this.getInstalledMold(); int moldsToCast = maxProcessable();
if (mold != null) { // Makes it flush the buffers after 10 seconds of inactivity, or when they're full
int itemsCasted = maxProcessable(); if (moldsToCast > 0 && (moldsToCast == 10 || worldObj.getWorldTime() >= lastCastTick + 200)) {
// Makes it flush the buffers after 10 seconds of inactivity, or when they're full ItemMold.Mold mold = this.getInstalledMold();
if (itemsCasted == 10 || worldObj.getWorldTime() >= lastCastTick + 200) {
this.amount -= itemsCasted * mold.getCost(); this.amount -= moldsToCast * mold.getCost();
ItemStack out = mold.getOutput(type); ItemStack out = mold.getOutput(type);
int remaining = out.stackSize * itemsCasted; int remaining = out.stackSize * moldsToCast;
out.stackSize = out.getMaxStackSize(); out.stackSize = out.getMaxStackSize();
for (int i = 1; i < 7; i++) { for (int i = 1; i < 7; i++) {
if (remaining <= 0) { if (remaining <= 0) {
break; break;
}
if (slots[i] == null) {
slots[i] = new ItemStack(out.getItem(), 0, out.getItemDamage());
}
if (slots[i].isItemEqual(out)) {
int toDeposit = Math.min(remaining, out.stackSize - slots[i].stackSize);
slots[i].stackSize += toDeposit;
remaining -= toDeposit;
}
} }
markChanged(); if (slots[i] == null) {
slots[i] = new ItemStack(out.getItem(), 0, out.getItemDamage());
}
water.setFill(water.getFill() - getWaterRequired() * itemsCasted); if (slots[i].isItemEqual(out)) {
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted); int toDeposit = Math.min(remaining, out.stackSize - slots[i].stackSize);
slots[i].stackSize += toDeposit;
remaining -= toDeposit;
}
} }
lastCastTick = worldObj.getWorldTime(); markChanged();
water.setFill(water.getFill() - getWaterRequired() * moldsToCast);
steam.setFill(steam.getFill() + getWaterRequired() * moldsToCast);
} }
lastCastTick = worldObj.getWorldTime();
networkPackNT(150); networkPackNT(150);
} }
} }
@ -134,12 +132,12 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
} }
} }
int itemsCasted = amount / mold.getCost(); int moldsToCast = amount / mold.getCost();
itemsCasted = Math.min(itemsCasted, freeSlots / mold.getOutput(type).stackSize); moldsToCast = Math.min(moldsToCast, freeSlots / mold.getOutput(type).stackSize);
itemsCasted = Math.min(itemsCasted, water.getFill() / getWaterRequired()); moldsToCast = Math.min(moldsToCast, water.getFill() / getWaterRequired());
itemsCasted = Math.min(itemsCasted, (steam.getMaxFill() - steam.getFill()) / getWaterRequired()); moldsToCast = Math.min(moldsToCast, (steam.getMaxFill() - steam.getFill()) / getWaterRequired());
return itemsCasted; return moldsToCast;
} }
public DirPos[] getFluidConPos() { public DirPos[] getFluidConPos() {