From 81ca498fa8019a9a3d0ab1871e8a896d04520d13 Mon Sep 17 00:00:00 2001 From: abel1502 Date: Fri, 23 May 2025 00:57:21 +0300 Subject: [PATCH] Fix strand caster 2: electric boogaloo Like, only cast if there is anything to cast, duh --- .../TileEntityMachineStrandCaster.java | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java index 56cc4629d..dbc955b2e 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java @@ -74,45 +74,43 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase this.updateConnections(); - ItemMold.Mold mold = this.getInstalledMold(); + int moldsToCast = maxProcessable(); + + // Makes it flush the buffers after 10 seconds of inactivity, or when they're full + if (moldsToCast > 0 && (moldsToCast == 10 || worldObj.getWorldTime() >= lastCastTick + 200)) { - if (mold != null) { - int itemsCasted = maxProcessable(); - - // Makes it flush the buffers after 10 seconds of inactivity, or when they're full - if (itemsCasted == 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); - int remaining = out.stackSize * itemsCasted; - out.stackSize = out.getMaxStackSize(); + ItemStack out = mold.getOutput(type); + int remaining = out.stackSize * moldsToCast; + out.stackSize = out.getMaxStackSize(); - for (int i = 1; i < 7; i++) { - if (remaining <= 0) { - 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; - } + for (int i = 1; i < 7; i++) { + if (remaining <= 0) { + break; } - markChanged(); + if (slots[i] == null) { + slots[i] = new ItemStack(out.getItem(), 0, out.getItemDamage()); + } - water.setFill(water.getFill() - getWaterRequired() * itemsCasted); - steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted); + if (slots[i].isItemEqual(out)) { + 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); } } @@ -134,12 +132,12 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase } } - int itemsCasted = amount / mold.getCost(); - itemsCasted = Math.min(itemsCasted, freeSlots / mold.getOutput(type).stackSize); - itemsCasted = Math.min(itemsCasted, water.getFill() / getWaterRequired()); - itemsCasted = Math.min(itemsCasted, (steam.getMaxFill() - steam.getFill()) / getWaterRequired()); + int moldsToCast = amount / mold.getCost(); + moldsToCast = Math.min(moldsToCast, freeSlots / mold.getOutput(type).stackSize); + moldsToCast = Math.min(moldsToCast, water.getFill() / getWaterRequired()); + moldsToCast = Math.min(moldsToCast, (steam.getMaxFill() - steam.getFill()) / getWaterRequired()); - return itemsCasted; + return moldsToCast; } public DirPos[] getFluidConPos() {