Rule of blips

- Tweaked boiler tooltip presentation
This commit is contained in:
simibubi 2022-05-04 17:37:26 +02:00
parent 70bbf94e00
commit 6ae6c4878f

View file

@ -14,6 +14,7 @@ import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.animation.LerpedFloat; import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import joptsimple.internal.Strings;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -125,19 +126,23 @@ public class BoilerData {
int forBoilerSize = getMaxHeatLevelForBoilerSize(boilerSize); int forBoilerSize = getMaxHeatLevelForBoilerSize(boilerSize);
int forWaterSupply = getMaxHeatLevelForWaterSupply(); int forWaterSupply = getMaxHeatLevelForWaterSupply();
int actualHeat = Math.min(activeHeat, Math.min(forWaterSupply, forBoilerSize)); int boilerLevel = Math.min(activeHeat, Math.min(forWaterSupply, forBoilerSize));
int minValue = Math.min(passiveHeat ? 1 : activeHeat, Math.min(forWaterSupply, forBoilerSize));
int maxValue = Math.max(passiveHeat ? 1 : activeHeat, Math.max(forWaterSupply, forBoilerSize));
TextComponent heatLevel = isPassive(boilerSize) ? new TextComponent("Passive") TextComponent heatLevel = isPassive(boilerSize) ? new TextComponent("Passive")
: (actualHeat == 0 ? new TextComponent("Idle") : (boilerLevel == 0 ? new TextComponent("Idle")
: new TextComponent("Lvl " + IHaveGoggleInformation.format(actualHeat))); : boilerLevel == 18 ? new TextComponent("Max")
: new TextComponent("Lvl " + IHaveGoggleInformation.format(boilerLevel)));
tooltip.add(componentSpacing.plainCopy() tooltip.add(componentSpacing.plainCopy()
.append(new TextComponent("Boiler Status: ").append(heatLevel.withStyle(ChatFormatting.GREEN)))); .append(new TextComponent("Boiler Status: ").append(heatLevel.withStyle(ChatFormatting.GREEN))));
Component h = levelComponent("Temperature: ", "No heat", passiveHeat ? -1 : activeHeat); Component h = levelComponent("Heat ...... ", passiveHeat ? 1 : activeHeat, minValue, maxValue);
Component w = levelComponent("Water supply: ", "Too slow", forWaterSupply); Component w = levelComponent("Water ... ", forWaterSupply, minValue, maxValue);
Component s = levelComponent("Boiler size: ", "Too small", forBoilerSize); Component s = levelComponent("Size ....... ", forBoilerSize, minValue, maxValue);
double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(actualHeat, attachedEngines) double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(boilerLevel, attachedEngines)
* BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get()); * BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get());
Component capacity = Component capacity =
new TextComponent(IHaveGoggleInformation.format(totalSU)).append(Lang.translate("generic.unit.stress")) new TextComponent(IHaveGoggleInformation.format(totalSU)).append(Lang.translate("generic.unit.stress"))
@ -148,12 +153,12 @@ public class BoilerData {
Component indent = new TextComponent(spacing); Component indent = new TextComponent(spacing);
Component indent2 = new TextComponent(spacing + " "); Component indent2 = new TextComponent(spacing + " ");
tooltip.add(indent.plainCopy() tooltip.add(indent2.plainCopy()
.append(w));
tooltip.add(indent.plainCopy()
.append(h));
tooltip.add(indent.plainCopy()
.append(s)); .append(s));
tooltip.add(indent2.plainCopy()
.append(w));
tooltip.add(indent2.plainCopy()
.append(h));
tooltip.add(indent); tooltip.add(indent);
tooltip.add(indent.plainCopy() tooltip.add(indent.plainCopy()
@ -166,12 +171,24 @@ public class BoilerData {
return true; return true;
} }
private MutableComponent levelComponent(String text, String whenZero, int level) { private MutableComponent levelComponent(String text, int level, int min, int max) {
return new TextComponent(text).withStyle(ChatFormatting.GRAY) int indexOf = text.indexOf(".");
.append(level == 0 ? new TextComponent(whenZero).withStyle(ChatFormatting.RED) String label = text.substring(0, indexOf);
: new TextComponent( String dots = text.substring(indexOf);
level == -1 ? "Passive" : level == 18 ? "Max" : "Lvl " + IHaveGoggleInformation.format(level)) MutableComponent c = new TextComponent(label).withStyle(ChatFormatting.GRAY)
.withStyle(ChatFormatting.GOLD)); .append(new TextComponent(dots).withStyle(ChatFormatting.DARK_GRAY));
c.append(bars(Math.max(0, min - 1), ChatFormatting.DARK_GREEN));
c.append(bars(min > 0 ? 1 : 0, ChatFormatting.GREEN));
c.append(bars(Math.max(0, level - min), ChatFormatting.DARK_GREEN));
c.append(bars(Math.max(0, max - level), ChatFormatting.DARK_RED));
c.append(bars(Math.max(0, 18 - max), ChatFormatting.DARK_GRAY));
return c;
}
private MutableComponent bars(int level, ChatFormatting format) {
return new TextComponent(Strings.repeat('|', level)).withStyle(format);
} }
public boolean evaluate(FluidTankTileEntity controller) { public boolean evaluate(FluidTankTileEntity controller) {