Fixed some text component stuff i messed up earlier

This commit is contained in:
grimmauld 2020-10-04 10:35:58 +02:00
parent bc4418a929
commit fdf9fdcd78
12 changed files with 42 additions and 39 deletions

View file

@ -377,7 +377,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0; boolean notFastEnough = !isSpeedRequirementFulfilled() && getSpeed() != 0;
if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) { if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) {
tooltip.add(ITextComponent.of(spacing + GOLD + Lang.translate("gui.stressometer.overstressed"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.overstressed").formatted(GOLD)));
ITextComponent hint = Lang.translate("gui.contraptions.network_overstressed", I18n.format(getBlockState().getBlock() ITextComponent hint = Lang.translate("gui.contraptions.network_overstressed", I18n.format(getBlockState().getBlock()
.getTranslationKey())); .getTranslationKey()));
List<String> cutString = TooltipHelper.cutString(new StringTextComponent(spacing).append(hint), GRAY, TextFormatting.WHITE); List<String> cutString = TooltipHelper.cutString(new StringTextComponent(spacing).append(hint), GRAY, TextFormatting.WHITE);
@ -405,8 +405,8 @@ public abstract class KineticTileEntity extends SmartTileEntity
float stressAtBase = calculateStressApplied(); float stressAtBase = calculateStressApplied();
if (calculateStressApplied() != 0 && StressImpact.isEnabled()) { if (calculateStressApplied() != 0 && StressImpact.isEnabled()) {
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.goggles.kinetic_stats"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.goggles.kinetic_stats")));
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("tooltip.stressImpact"))); tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.stressImpact").formatted(TextFormatting.GRAY)));
float stressTotal = stressAtBase * Math.abs(getSpeed()); float stressTotal = stressAtBase * Math.abs(getSpeed());

View file

@ -13,6 +13,7 @@ import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
public class GoggleConfigScreen extends AbstractSimiScreen { public class GoggleConfigScreen extends AbstractSimiScreen {
@ -22,19 +23,19 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
private final List<ITextComponent> tooltip; private final List<ITextComponent> tooltip;
public GoggleConfigScreen() { public GoggleConfigScreen() {
String spacing = " "; ITextComponent spacing = ITextComponent.of(" ");
tooltip = new ArrayList<>(); tooltip = new ArrayList<>();
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.config.overlay1"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay1")));
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay2"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay2").formatted(TextFormatting.GRAY)));
tooltip.add(ITextComponent.of("")); tooltip.add(StringTextComponent.EMPTY);
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.config.overlay3"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay3")));
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.config.overlay4"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay4")));
tooltip.add(ITextComponent.of("")); tooltip.add(StringTextComponent.EMPTY);
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay5"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay5").formatted(TextFormatting.GRAY)));
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.config.overlay6"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay6").formatted(TextFormatting.GRAY)));
tooltip.add(ITextComponent.of("")); tooltip.add(StringTextComponent.EMPTY);
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.config.overlay7"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay7")));
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.config.overlay8"))); tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay8")));
} }
@Override @Override

View file

@ -18,6 +18,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
@ -62,7 +63,7 @@ public class GoggleOverlayRenderer {
if (hoveringInformation) { if (hoveringInformation) {
boolean goggleAddedInformation = !tooltip.isEmpty(); boolean goggleAddedInformation = !tooltip.isEmpty();
if (goggleAddedInformation) if (goggleAddedInformation)
tooltip.add(ITextComponent.of("")); tooltip.add(StringTextComponent.EMPTY);
IHaveHoveringInformation hte = (IHaveHoveringInformation) te; IHaveHoveringInformation hte = (IHaveHoveringInformation) te;
if (!hte.addToTooltip(tooltip, mc.player.isSneaking())) if (!hte.addToTooltip(tooltip, mc.player.isSneaking()))
hoveringInformation = false; hoveringInformation = false;

View file

@ -12,6 +12,7 @@ public interface IHaveGoggleInformation {
DecimalFormat decimalFormat = new DecimalFormat("#.##"); DecimalFormat decimalFormat = new DecimalFormat("#.##");
String spacing = " "; String spacing = " ";
ITextComponent componentSpacing = ITextComponent.of(spacing);
/** /**
* this method will be called when looking at a TileEntity that implemented this interface * this method will be called when looking at a TileEntity that implemented this interface

View file

@ -47,7 +47,7 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf
@Override @Override
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
tooltip.add(ITextComponent.of(spacing + Lang.translate("gui.gauge.info_header"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.gauge.info_header")));
return true; return true;
} }

View file

@ -50,10 +50,10 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity{
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
super.addToGoggleTooltip(tooltip, isPlayerSneaking); super.addToGoggleTooltip(tooltip, isPlayerSneaking);
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.speedometer.title"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.speedometer.title").formatted(TextFormatting.GRAY)));
tooltip.add(ITextComponent.of(spacing + SpeedLevel.getFormattedSpeedText(speed, overStressed))); tooltip.add(componentSpacing.copy().append(SpeedLevel.getFormattedSpeedText(speed, overStressed)));
if (overStressed) if (overStressed)
tooltip.add(ITextComponent.of(spacing + TextFormatting.DARK_RED + Lang.translate("gui.stressometer.overstressed"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.overstressed").formatted(TextFormatting.DARK_RED)));
return true; return true;
} }

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
public class StressGaugeTileEntity extends GaugeTileEntity { public class StressGaugeTileEntity extends GaugeTileEntity {
@ -66,27 +67,26 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
double capacity = getNetworkCapacity(); double capacity = getNetworkCapacity();
double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity); double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity);
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.stressometer.title"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.title").formatted(TextFormatting.GRAY)));
if (getTheoreticalSpeed() == 0) if (getTheoreticalSpeed() == 0)
tooltip.add(ITextComponent.of(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) tooltip.add(ITextComponent.of(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1)
+ Lang.translate("gui.stressometer.no_rotation"))); + Lang.translate("gui.stressometer.no_rotation")));
else { else {
tooltip.add(ITextComponent.of(spacing + StressImpact.getFormattedStressText(stressFraction))); tooltip.add(componentSpacing.copy().append(StressImpact.getFormattedStressText(stressFraction)));
tooltip.add(ITextComponent.of(spacing + TextFormatting.GRAY + Lang.translate("gui.stressometer.capacity"))); tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.capacity").formatted(TextFormatting.GRAY)));
double remainingCapacity = capacity - getNetworkStress(); double remainingCapacity = capacity - getNetworkStress();
double remainingCapacityAtBase = remainingCapacity / Math.abs(getTheoreticalSpeed()); double remainingCapacityAtBase = remainingCapacity / Math.abs(getTheoreticalSpeed());
String capacityString = spacing + StressImpact.of(stressFraction).getRelativeColor() + "%s" tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(remainingCapacityAtBase))
+ Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s"; .append(Lang.translate("generic.unit.stress")).append(" ").formatted(StressImpact.of(stressFraction).getRelativeColor()))
.append(Lang.translate("gui.goggles.base_value").formatted(TextFormatting.DARK_GRAY)));
tooltip.add(ITextComponent.of(String.format(capacityString, IHaveGoggleInformation.format(remainingCapacityAtBase),
Lang.translate("gui.goggles.base_value"))));
tooltip.add(ITextComponent.of(String.format(capacityString, IHaveGoggleInformation.format(remainingCapacity),
Lang.translate("gui.goggles.at_current_speed"))));
tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(remainingCapacity))
.append(Lang.translate("generic.unit.stress")).append(" ").formatted(StressImpact.of(stressFraction).getRelativeColor()))
.append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY)));
} }
return true; return true;

View file

@ -45,6 +45,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
@ -632,9 +633,9 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
@Override @Override
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
tooltip.add(ITextComponent.of(spacing + TextFormatting.GOLD + "Pull: " + TextFormatting.WHITE + pull)); tooltip.add(componentSpacing.copy().append(new StringTextComponent("Pull: ").formatted(TextFormatting.GOLD).append(new StringTextComponent(String.valueOf(pull)).formatted(TextFormatting.WHITE))));
tooltip.add(ITextComponent.of(spacing + TextFormatting.GOLD + "Push: " + TextFormatting.WHITE + push)); tooltip.add(componentSpacing.copy().append(new StringTextComponent("Push: ").formatted(TextFormatting.GOLD).append(new StringTextComponent(String.valueOf(push)).formatted(TextFormatting.WHITE))));
tooltip.add(ITextComponent.of(TextFormatting.YELLOW + "-> Item Motion: " + TextFormatting.WHITE + getItemMotion())); tooltip.add(new StringTextComponent("-> Item Motion: ").formatted(TextFormatting.YELLOW).append(new StringTextComponent(String.valueOf(getItemMotion())).formatted(TextFormatting.WHITE)));
return true; return true;
} }

View file

@ -70,7 +70,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
@Override @Override
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) { public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
tooltip.add(ITextComponent.of(spacing).copy().append(Lang.translate("tooltip.analogStrength", this.state))); tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.analogStrength", this.state)));
return true; return true;
} }

View file

@ -1,7 +1,5 @@
package com.simibubi.create.content.schematics.client; package com.simibubi.create.content.schematics.client;
import static com.simibubi.create.foundation.gui.AllGuiTextures.ADJUSTABLE_CRATE;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;

View file

@ -7,13 +7,14 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
public abstract class AbstractSimiWidget extends Widget { public abstract class AbstractSimiWidget extends Widget {
protected List<ITextComponent> toolTip; protected List<ITextComponent> toolTip;
public AbstractSimiWidget(int xIn, int yIn, int widthIn, int heightIn) { public AbstractSimiWidget(int xIn, int yIn, int widthIn, int heightIn) {
super(xIn, yIn, widthIn, heightIn, ITextComponent.of("")); super(xIn, yIn, widthIn, heightIn, StringTextComponent.EMPTY);
toolTip = new LinkedList<>(); toolTip = new LinkedList<>();
} }

View file

@ -23,8 +23,8 @@ import net.minecraft.util.text.StringTextComponent;
public class ValueBox extends ChasingAABBOutline { public class ValueBox extends ChasingAABBOutline {
protected ITextComponent label = ITextComponent.of("Value Box"); protected ITextComponent label;
protected ITextComponent sublabel = ITextComponent.of(""); protected ITextComponent sublabel = StringTextComponent.EMPTY;
protected ITextComponent scrollTooltip = StringTextComponent.EMPTY; protected ITextComponent scrollTooltip = StringTextComponent.EMPTY;
protected Vector3d labelOffset = Vector3d.ZERO; protected Vector3d labelOffset = Vector3d.ZERO;