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,18 +74,17 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
this.updateConnections(); this.updateConnections();
ItemMold.Mold mold = this.getInstalledMold(); int moldsToCast = maxProcessable();
if (mold != null) {
int itemsCasted = maxProcessable();
// Makes it flush the buffers after 10 seconds of inactivity, or when they're full // Makes it flush the buffers after 10 seconds of inactivity, or when they're full
if (itemsCasted == 10 || worldObj.getWorldTime() >= lastCastTick + 200) { if (moldsToCast > 0 && (moldsToCast == 10 || worldObj.getWorldTime() >= lastCastTick + 200)) {
this.amount -= itemsCasted * mold.getCost(); ItemMold.Mold mold = this.getInstalledMold();
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++) {
@ -106,12 +105,11 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
markChanged(); markChanged();
water.setFill(water.getFill() - getWaterRequired() * itemsCasted); water.setFill(water.getFill() - getWaterRequired() * moldsToCast);
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted); steam.setFill(steam.getFill() + getWaterRequired() * moldsToCast);
} }
lastCastTick = worldObj.getWorldTime(); 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() {