From 0d972e144f9fa47fff855f0b0d7d66ccedef8450 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Tue, 6 Oct 2020 12:21:13 +0200 Subject: [PATCH] Fix some more text components --- .../base/GeneratingKineticTileEntity.java | 10 +++++--- .../contraptions/base/KineticTileEntity.java | 21 ++++++++-------- .../goggles/GoggleConfigScreen.java | 18 +++++++------- .../relays/gauge/StressGaugeTileEntity.java | 5 ++-- .../symmetry/SymmetryWandScreen.java | 5 ++-- .../zapper/blockzapper/BlockzapperScreen.java | 2 +- .../terrainzapper/WorldshaperScreen.java | 5 ++-- .../inventories/AdjustableCrateScreen.java | 3 ++- .../item/filter/AttributeFilterScreen.java | 2 +- .../block/SchematicTableScreen.java | 2 +- .../block/SchematicannonScreen.java | 16 ------------- .../client/SchematicEditScreen.java | 4 ++-- .../create/foundation/gui/widgets/Label.java | 8 +++---- .../foundation/gui/widgets/ScrollInput.java | 12 +++++----- .../gui/widgets/SelectionScrollInput.java | 2 +- .../tileEntity/behaviour/ValueBox.java | 8 +++---- .../filtering/FilteringRenderer.java | 2 +- .../scrollvalue/ScrollValueRenderer.java | 7 +++--- .../create/foundation/utility/Debug.java | 24 ++++++++++--------- 19 files changed, 75 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java index e70acea2b..3e9b6bd25 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/GeneratingKineticTileEntity.java @@ -70,9 +70,13 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity { float stressTotal = stressBase * speed; // FIXME add colours back - String stressString = spacing + "%s" + Lang.translate("generic.unit.stress").getUnformattedComponentText() + " %s"; - tooltip.add(ITextComponent.of(String.format(stressString, IHaveGoggleInformation.format(stressBase), Lang.translate("gui.goggles.base_value").getUnformattedComponentText()))); - tooltip.add(ITextComponent.of(String.format(stressString, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed").getUnformattedComponentText()))); + // String stressString = spacing + "%s" + Lang.translate("generic.unit.stress").getUnformattedComponentText() + " %s"; + // tooltip.add(ITextComponent.of(String.format(stressString, IHaveGoggleInformation.format(stressBase), Lang.translate("gui.goggles.base_value").getUnformattedComponentText()))); + // tooltip.add(ITextComponent.of(String.format(stressString, IHaveGoggleInformation.format(stressTotal), Lang.translate("gui.goggles.at_current_speed").getUnformattedComponentText()))); + tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(stressBase)) + .append(Lang.translate("generic.unit.stress")).append(" ").formatted(TextFormatting.AQUA)).append(Lang.translate("gui.goggles.base_value").formatted(TextFormatting.DARK_GRAY))); + tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(stressTotal)) + .append(Lang.translate("generic.unit.stress")).append(" ").formatted(TextFormatting.GRAY)).append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY))); added = true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index d38d8b860..367ff96c9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -380,19 +380,19 @@ public abstract class KineticTileEntity extends SmartTileEntity tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.overstressed").formatted(GOLD))); ITextComponent hint = Lang.translate("gui.contraptions.network_overstressed", I18n.format(getBlockState().getBlock() .getTranslationKey())); - List cutString = TooltipHelper.cutString(new StringTextComponent(spacing).append(hint), GRAY, TextFormatting.WHITE); + List cutString = TooltipHelper.cutString(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) - tooltip.add(ITextComponent.of((i == 0 ? "" : spacing) + cutString.get(i))); + tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i))); return true; } if (notFastEnough) { - tooltip.add(ITextComponent.of(spacing + GOLD + Lang.translate("tooltip.speedRequirement"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.speedRequirement").formatted(GOLD))); ITextComponent hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock() .getTranslationKey())); - List cutString = TooltipHelper.cutString(new StringTextComponent(spacing).append(hint), GRAY, TextFormatting.WHITE); + List cutString = TooltipHelper.cutString(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE); for (int i = 0; i < cutString.size(); i++) - tooltip.add(ITextComponent.of((i == 0 ? "" : spacing) + cutString.get(i))); + tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i))); return true; } @@ -410,13 +410,12 @@ public abstract class KineticTileEntity extends SmartTileEntity float stressTotal = stressAtBase * Math.abs(getSpeed()); - String stressString = - spacing + "%s%s" + Lang.translate("generic.unit.stress") + " " + TextFormatting.DARK_GRAY + "%s"; + tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(stressAtBase)) + .append(Lang.translate("generic.unit.stress")).append(" ").formatted(TextFormatting.AQUA)).append(Lang.translate("gui.goggles.base_value").formatted(TextFormatting.DARK_GRAY))); + tooltip.add(componentSpacing.copy().append(new StringTextComponent(IHaveGoggleInformation.format(stressTotal)) + .append(Lang.translate("generic.unit.stress")).append(" ").formatted(TextFormatting.GRAY)).append(Lang.translate("gui.goggles.at_current_speed").formatted(TextFormatting.DARK_GRAY))); + - tooltip.add(ITextComponent.of(String.format(stressString, TextFormatting.AQUA, IHaveGoggleInformation.format(stressAtBase), - Lang.translate("gui.goggles.base_value")))); - tooltip.add(ITextComponent.of(String.format(stressString, TextFormatting.GRAY, IHaveGoggleInformation.format(stressTotal), - Lang.translate("gui.goggles.at_current_speed")))); added = true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java index e98f24b03..4d616c511 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleConfigScreen.java @@ -23,19 +23,19 @@ public class GoggleConfigScreen extends AbstractSimiScreen { private final List tooltip; public GoggleConfigScreen() { - ITextComponent spacing = ITextComponent.of(" "); + ITextComponent componentSpacing = ITextComponent.of(" "); tooltip = new ArrayList<>(); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay1"))); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay2").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay1"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay2").formatted(TextFormatting.GRAY))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay3"))); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay4"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay3"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay4"))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay5").formatted(TextFormatting.GRAY))); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay6").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay5").formatted(TextFormatting.GRAY))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay6").formatted(TextFormatting.GRAY))); tooltip.add(StringTextComponent.EMPTY); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay7"))); - tooltip.add(spacing.copy().append(Lang.translate("gui.config.overlay8"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay7"))); + tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay8"))); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java index a3e723ba4..20d6ab474 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/StressGaugeTileEntity.java @@ -70,8 +70,9 @@ public class StressGaugeTileEntity extends GaugeTileEntity { tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.title").formatted(TextFormatting.GRAY))); if (getTheoreticalSpeed() == 0) - tooltip.add(ITextComponent.of(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) - + Lang.translate("gui.stressometer.no_rotation"))); + tooltip.add(new StringTextComponent(ItemDescription.makeProgressBar(3, -1)).append(Lang.translate("gui.stressometer.no_rotation")).formatted(TextFormatting.DARK_GRAY)); + // tooltip.add(ITextComponent.of(TextFormatting.DARK_GRAY + ItemDescription.makeProgressBar(3, -1) + // + Lang.translate("gui.stressometer.no_rotation"))); else { tooltip.add(componentSpacing.copy().append(StressImpact.getFormattedStressText(stressFraction))); diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java index 6e051f50c..5f2dc9740 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/SymmetryWandScreen.java @@ -25,6 +25,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.fml.network.PacketDistributor; public class SymmetryWandScreen extends AbstractSimiScreen { @@ -59,9 +60,9 @@ public class SymmetryWandScreen extends AbstractSimiScreen { AllGuiTextures background = AllGuiTextures.WAND_OF_SYMMETRY; this.setWindowSize(background.width + 50, background.height + 50); - labelType = new Label(guiLeft + 49, guiTop + 26, "").colored(0xFFFFFFFF) + labelType = new Label(guiLeft + 49, guiTop + 26, StringTextComponent.EMPTY).colored(0xFFFFFFFF) .withShadow(); - labelAlign = new Label(guiLeft + 49, guiTop + 48, "").colored(0xFFFFFFFF) + labelAlign = new Label(guiLeft + 49, guiTop + 48, StringTextComponent.EMPTY).colored(0xFFFFFFFF) .withShadow(); int state = diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperScreen.java index 475e113f1..3bdc13ee5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/blockzapper/BlockzapperScreen.java @@ -63,7 +63,7 @@ public class BlockzapperScreen extends ZapperScreen { spreadMaterialIndicator.state = State.ON; spreadMaterialButton.setToolTip(Lang.translate("gui.blockzapper.searchFuzzy")); - spreadRangeLabel = new Label(i + 79, j + 78, "").withShadow().withSuffix("m"); + spreadRangeLabel = new Label(i + 79, j + 78, StringTextComponent.EMPTY).withShadow().withSuffix("m"); spreadRangeInput = new ScrollInput(i + 73, j + 73, 26, 18).withRange(1, BlockzapperItem.getMaxAoe(zapper)) .setState(1).titled(Lang.translate("gui.blockzapper.range")).writingTo(spreadRangeLabel); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java index da6efd39d..5a7c70d7f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; public class WorldshaperScreen extends ZapperScreen { @@ -52,7 +53,7 @@ public class WorldshaperScreen extends ZapperScreen { i = guiLeft - 20; j = guiTop; - brushLabel = new Label(i + 61, j + 23, "").withShadow(); + brushLabel = new Label(i + 61, j + 23, StringTextComponent.EMPTY).withShadow(); brushInput = new SelectionScrollInput(i + 56, j + 18, 77, 18).forOptions(brushOptions) .titled(Lang.translate("gui.terrainzapper.brush")) .writingTo(brushLabel) @@ -115,7 +116,7 @@ public class WorldshaperScreen extends ZapperScreen { Brush currentBrush = TerrainBrushes.values()[brushInput.getState()].get(); for (int index = 0; index < 3; index++) { - Label label = new Label(i + 65 + 20 * index, j + 43, "").withShadow(); + Label label = new Label(i + 65 + 20 * index, j + 43, StringTextComponent.EMPTY).withShadow(); brushParamLabels.add(label); int indexFinal = index; ScrollInput input = new ScrollInput(i + 56 + 20 * index, j + 38, 18, 18) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java index e530b2420..7b3aaab9c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateScreen.java @@ -22,6 +22,7 @@ import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; public class AdjustableCrateScreen extends AbstractSimiContainerScreen { @@ -48,7 +49,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen availableSchematics = CreateClient.schematicSender.getAvailableSchematics(); - schematicsLabel = new Label(mainLeft + 49, mainTop + 26, "").withShadow(); + schematicsLabel = new Label(mainLeft + 49, mainTop + 26, StringTextComponent.EMPTY).withShadow(); schematicsLabel.text = StringTextComponent.EMPTY; if (!availableSchematics.isEmpty()) { schematicsArea = diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java index e2fef7e11..72db94277 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java @@ -133,22 +133,6 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen(4); replaceLevelIndicators = new Vector<>(4); - /* -<<<<<<< HEAD - List icons = ImmutableList - .of(AllIcons.I_DONT_REPLACE, AllIcons.I_REPLACE_SOLID, AllIcons.I_REPLACE_ANY, - AllIcons.I_REPLACE_EMPTY); - List toolTips = ImmutableList - .of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), - Lang.translate("gui.schematicannon.option.replaceWithSolid"), - Lang.translate("gui.schematicannon.option.replaceWithAny"), - Lang.translate("gui.schematicannon.option.replaceWithEmpty")); - - for (int i = 0; i < 4; i++) { - replaceLevelIndicators.add(new Indicator(x + 16 + i * 18, y + 96, StringTextComponent.EMPTY)); - replaceLevelButtons.add(new IconButton(x + 16 + i * 18, y + 101, icons.get(i))); - replaceLevelButtons.get(i).setToolTip(toolTips.get(i)); -=======*/ List icons = ImmutableList.of(AllIcons.I_DONT_REPLACE, AllIcons.I_REPLACE_SOLID, AllIcons.I_REPLACE_ANY, AllIcons.I_REPLACE_EMPTY); List toolTips = ImmutableList.of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java index 855c02498..e9e4b15c1 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java @@ -89,14 +89,14 @@ public class SchematicEditScreen extends AbstractSimiScreen { PlacementSettings settings = handler.getTransformation() .toSettings(); - Label labelR = new Label(x + 50, y + 48, "").withShadow(); + Label labelR = new Label(x + 50, y + 48, StringTextComponent.EMPTY).withShadow(); rotationArea = new SelectionScrollInput(x + 45, y + 43, 118, 18).forOptions(rotationOptions) .titled(rotationLabel.copy()) .setState(settings.getRotation() .ordinal()) .writingTo(labelR); - Label labelM = new Label(x + 50, y + 70, "").withShadow(); + Label labelM = new Label(x + 50, y + 70, StringTextComponent.EMPTY).withShadow(); mirrorArea = new SelectionScrollInput(x + 45, y + 65, 118, 18).forOptions(mirrorOptions) .titled(mirrorLabel.copy()) .setState(settings.getMirror() diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java index 468ec1922..db2e0d0ab 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/Label.java @@ -16,8 +16,8 @@ public class Label extends AbstractSimiWidget { protected int color; protected FontRenderer font; - public Label(int x, int y, String text) { - super(x, y, Minecraft.getInstance().fontRenderer.getStringWidth(text), 10); + public Label(int x, int y, ITextComponent text) { + super(x, y, Minecraft.getInstance().fontRenderer.getWidth(text), 10); font = Minecraft.getInstance().fontRenderer; this.text = ITextComponent.of("Label"); color = 0xFFFFFF; @@ -76,9 +76,9 @@ public class Label extends AbstractSimiWidget { RenderSystem.color4f(1, 1, 1, 1); if (hasShadow) - font.drawWithShadow(matrixStack, text + suffix, x, y, color); + font.drawWithShadow(matrixStack, text.copy().append(suffix), x, y, color); else - font.draw(matrixStack, text + suffix, x, y, color); + font.draw(matrixStack, text.copy().append(suffix), x, y, color); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java index eee8b3968..f807661bf 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/ScrollInput.java @@ -15,9 +15,9 @@ public class ScrollInput extends AbstractSimiWidget { protected Consumer onScroll; protected int state; - protected IFormattableTextComponent title = Lang.translate("gui.scrollInput.defaultTitle"); - protected final IFormattableTextComponent scrollToModify = Lang.translate("gui.scrollInput.scrollToModify"); - protected final IFormattableTextComponent shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster"); + protected ITextComponent title = Lang.translate("gui.scrollInput.defaultTitle"); + protected final ITextComponent scrollToModify = Lang.translate("gui.scrollInput.scrollToModify"); + protected final ITextComponent shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster"); protected Label displayLabel; protected int min, max; @@ -136,9 +136,9 @@ public class ScrollInput extends AbstractSimiWidget { protected void updateTooltip() { toolTip.clear(); - toolTip.add(title.formatted(TextFormatting.BLUE)); - toolTip.add(scrollToModify.formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); - toolTip.add(shiftScrollsFaster.formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); + toolTip.add(title.copy().formatted(TextFormatting.BLUE)); + toolTip.add(scrollToModify.copy().formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); + toolTip.add(shiftScrollsFaster.copy().formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY)); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java b/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java index 6bbfc9b2d..e118400b1 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java +++ b/src/main/java/com/simibubi/create/foundation/gui/widgets/SelectionScrollInput.java @@ -40,7 +40,7 @@ public class SelectionScrollInput extends ScrollInput { @Override protected void updateTooltip() { toolTip.clear(); - toolTip.add(title.formatted(TextFormatting.BLUE)); + toolTip.add(title.copy().formatted(TextFormatting.BLUE)); for (int i = min; i < max; i++) { if (i == state) toolTip.add(StringTextComponent.EMPTY.copy().append("-> ").append(options.get(i)).formatted(TextFormatting.WHITE)); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java index 23306468d..564d440ba 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBox.java @@ -162,9 +162,9 @@ public class ValueBox extends ChasingAABBOutline { } public static class TextValueBox extends ValueBox { - String text; + ITextComponent text; - public TextValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos, String text) { + public TextValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos, ITextComponent text) { super(label, bb, pos); this.text = text; } @@ -177,7 +177,7 @@ public class ValueBox extends ChasingAABBOutline { ms.scale(scale, scale, 1); ms.translate(-4, -4, 5); - int stringWidth = font.getStringWidth(text); + int stringWidth = font.getWidth(text); float numberScale = (float) font.FONT_HEIGHT / stringWidth; boolean singleDigit = stringWidth < 10; if (singleDigit) @@ -187,7 +187,7 @@ public class ValueBox extends ChasingAABBOutline { ms.scale(numberScale, numberScale, numberScale); ms.translate(singleDigit ? stringWidth / 2 : 0, singleDigit ? -verticalMargin : verticalMargin, 0); - renderHoveringText(ms, buffer, ITextComponent.of(text), 0xEDEDED, 0x4f4f4f); + renderHoveringText(ms, buffer, text, 0xEDEDED, 0x4f4f4f); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java index 75e929410..8d0886aae 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java @@ -75,7 +75,7 @@ public class FilteringRenderer { box.offsetLabel(behaviour.textShift) .withColors(0x7A6A2C, 0xB79D64) - .scrollTooltip(ITextComponent.of(showCount ? "[" + Lang.translate("action.scroll").getUnformattedComponentText() + "]" : "")) + .scrollTooltip(showCount ? new StringTextComponent("[").append(Lang.translate("action.scroll")).append("]") : StringTextComponent.EMPTY) .passive(!hit); CreateClient.outliner.showValueBox(Pair.of("filter", pos), box.transform(behaviour.slotPositioning)) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java index cd3079937..8eb5e66f9 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java @@ -19,6 +19,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; public class ScrollValueRenderer { @@ -62,12 +63,12 @@ public class ScrollValueRenderer { if (behaviour instanceof ScrollOptionBehaviour) { box = new IconValueBox(label, ((ScrollOptionBehaviour) behaviour).getIconForSelected(), bb, pos); } else { - box = new TextValueBox(label, bb, pos, behaviour.formatValue()); + box = new TextValueBox(label, bb, pos, new StringTextComponent(behaviour.formatValue())); if (behaviour.unit != null) - box.subLabel(ITextComponent.of("(" + behaviour.unit.apply(behaviour.scrollableValue) + ")")); + box.subLabel(new StringTextComponent("(").append(behaviour.unit.apply(behaviour.scrollableValue)).append(")")); } - box.scrollTooltip(ITextComponent.of("[" + Lang.translate("action.scroll").getUnformattedComponentText() + "]")); + box.scrollTooltip(new StringTextComponent("[").append(Lang.translate("action.scroll")).append("]")); box.offsetLabel(behaviour.textShift.add(20, -10, 0)) .withColors(0x5A5D5A, 0xB5B7B6) .passive(!highlight); diff --git a/src/main/java/com/simibubi/create/foundation/utility/Debug.java b/src/main/java/com/simibubi/create/foundation/utility/Debug.java index f42e7bd27..e83ced50c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Debug.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Debug.java @@ -1,6 +1,8 @@ package com.simibubi.create.foundation.utility; import net.minecraft.client.Minecraft; +import net.minecraft.util.text.IFormattableTextComponent; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; @@ -12,22 +14,22 @@ import net.minecraftforge.fml.common.thread.EffectiveSide; public class Debug { @Deprecated - public static void debugChat(String message) { + public static void debugChat(ITextComponent message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), false); + Minecraft.getInstance().player.sendStatusMessage(message, false); } @Deprecated - public static void debugChatAndShowStack(String message, int depth) { + public static void debugChatAndShowStack(ITextComponent message, int depth) { if (Minecraft.getInstance().player != null) Minecraft.getInstance().player - .sendStatusMessage(new StringTextComponent(message + " @" + debugStack(depth)), false); + .sendStatusMessage(message.copy().append("@").append(debugStack(depth)), false); } @Deprecated - public static void debugMessage(String message) { + public static void debugMessage(ITextComponent message) { if (Minecraft.getInstance().player != null) - Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(message), true); + Minecraft.getInstance().player.sendStatusMessage(message, true); } @Deprecated @@ -36,19 +38,19 @@ public class Debug { } @Deprecated - public static String debugStack(int depth) { + public static ITextComponent debugStack(int depth) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); - String text = "[" + TextFormatting.GOLD + getLogicalSide() + TextFormatting.WHITE + "] "; + IFormattableTextComponent text = new StringTextComponent("[").append(new StringTextComponent(getLogicalSide()).formatted(TextFormatting.GOLD)).append("] "); for (int i = 1; i < depth + 2 && i < stackTraceElements.length; i++) { StackTraceElement e = stackTraceElements[i]; if (e.getClassName().equals(Debug.class.getName())) continue; - text = text + TextFormatting.YELLOW + e.getMethodName() + TextFormatting.WHITE + ", "; + text.append(new StringTextComponent(e.getMethodName()).formatted(TextFormatting.YELLOW)).append(", "); } - return text + TextFormatting.GRAY + " ..."; + return text.append(new StringTextComponent(" ...").formatted(TextFormatting.GRAY)); } @Deprecated - public static void markTemporary() {}; + public static void markTemporary() {} }