From 6ce7bf8197a69bac8a1b581618bb3ae71625348f Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:07:20 -0700 Subject: [PATCH] Show "Working Disabled" instead of "Idle" when machine is soft malleted (#3780) Co-authored-by: Martin Robertz --- src/main/java/ggfab/mte/MTEAdvAssLine.java | 1 + .../implementations/MTEBasicMachine.java | 2 ++ .../implementations/MTEMultiBlockBase.java | 13 +++++++++---- src/main/java/gregtech/api/util/GTWaila.java | 13 ++++++++++++- .../implementations/base/MTESteamMultiBase.java | 8 ++++++-- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/ggfab/mte/MTEAdvAssLine.java b/src/main/java/ggfab/mte/MTEAdvAssLine.java index ae0d4c8d306..aef1edb66cd 100644 --- a/src/main/java/ggfab/mte/MTEAdvAssLine.java +++ b/src/main/java/ggfab/mte/MTEAdvAssLine.java @@ -931,6 +931,7 @@ public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDat NBTTagCompound tag = accessor.getNBTData(); String machineProgressString = GTWaila.getMachineProgressString( tag.getBoolean("isActive"), + tag.getBoolean("isAllowedToWork"), tag.getInteger("maxProgress"), tag.getInteger("progress")); currentTip.remove(machineProgressString); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java index 98c27dcd329..4d6d501f145 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java @@ -1225,6 +1225,7 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat currenttip.add( GTWaila.getMachineProgressString( isActive, + tag.getBoolean("isAllowedToWorkSingleBlock"), tag.getInteger("maxProgressSingleBlock"), tag.getInteger("progressSingleBlock"))); } @@ -1255,6 +1256,7 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou final IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); if (tileEntity != null) { tag.setBoolean("isActiveSingleBlock", tileEntity.isActive()); + tag.setBoolean("isAllowedToWorkSingleBlock", tileEntity.isAllowedToWork()); tag.setInteger( "outputFacingSingleBlock", tileEntity.getFrontFacing() diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java index 611e4bd36aa..823576d7cb2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java @@ -1007,7 +1007,7 @@ protected int getMaxBatchSize() { /** * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) - * + * * @param aStack what is in controller */ public int getPollutionPerTick(ItemStack aStack) { @@ -1019,7 +1019,7 @@ public int getPollutionPerTick(ItemStack aStack) { * the code of the multiblock. * * This returns the unmodified raw pollution value, not the one after muffler discounts. - * + * * @param aStack what is in controller */ public int getPollutionPerSecond(ItemStack aStack) { @@ -2049,8 +2049,12 @@ public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDat } } } - currentTip - .add(GTWaila.getMachineProgressString(isActive, tag.getInteger("maxProgress"), tag.getInteger("progress"))); + currentTip.add( + GTWaila.getMachineProgressString( + isActive, + tag.getBoolean("isAllowedToWork"), + tag.getInteger("maxProgress"), + tag.getInteger("progress"))); // Show ns on the tooltip if (GTMod.gregtechproxy.wailaAverageNS && tag.hasKey("averageNS")) { int tAverageTime = tag.getInteger("averageNS"); @@ -2099,6 +2103,7 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou final IGregTechTileEntity tileEntity = getBaseMetaTileEntity(); if (tileEntity != null) { tag.setBoolean("isActive", tileEntity.isActive()); + tag.setBoolean("isAllowedToWork", tileEntity.isAllowedToWork()); if (tileEntity.isActive()) { if (mEUt < 0) tag.setLong("energyUsage", getActualEnergyUsage()); else tag.setLong("energyUsage", (long) -mEUt * mEfficiency / 10000); diff --git a/src/main/java/gregtech/api/util/GTWaila.java b/src/main/java/gregtech/api/util/GTWaila.java index 7639aa02257..a6747f71f60 100644 --- a/src/main/java/gregtech/api/util/GTWaila.java +++ b/src/main/java/gregtech/api/util/GTWaila.java @@ -3,11 +3,22 @@ public abstract class GTWaila { public static String getMachineProgressString(boolean isActive, int maxProgresstime, int progresstime) { - return getMachineProgressString(isActive, maxProgresstime, (long) progresstime); + return getMachineProgressString(isActive, true, maxProgresstime, (long) progresstime); + } + + public static String getMachineProgressString(boolean isActive, boolean isAllowedToWork, int maxProgresstime, + int progresstime) { + return getMachineProgressString(isActive, isAllowedToWork, maxProgresstime, (long) progresstime); } public static String getMachineProgressString(boolean isActive, long maxProgresstime, long progresstime) { + return getMachineProgressString(isActive, true, maxProgresstime, progresstime); + } + + public static String getMachineProgressString(boolean isActive, boolean isAllowedToWork, long maxProgresstime, + long progresstime) { + if (!isAllowedToWork) return "Working Disabled"; if (!isActive) return "Idle"; return "In progress: " + String.format("%,.1f", (double) progresstime / 20) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/MTESteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/MTESteamMultiBase.java index a9076840858..d9235d5e1d6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/MTESteamMultiBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/MTESteamMultiBase.java @@ -393,8 +393,12 @@ public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDat .translateToLocalFormatted("GTPP.waila.steam.use", formatNumbers(actualEnergyUsage * 20))); } } - currentTip - .add(GTWaila.getMachineProgressString(isActive, tag.getInteger("maxProgress"), tag.getInteger("progress"))); + currentTip.add( + GTWaila.getMachineProgressString( + isActive, + tag.getBoolean("isAllowedToWork"), + tag.getInteger("maxProgress"), + tag.getInteger("progress"))); // Show ns on the tooltip if (GTMod.gregtechproxy.wailaAverageNS && tag.hasKey("averageNS")) { int tAverageTime = tag.getInteger("averageNS");