Yet more TextComponent nonsense

1.16 just keeps on giving
This commit is contained in:
simibubi 2020-10-20 21:03:43 +02:00
parent 41148a5e39
commit 12e5b95157
9 changed files with 825 additions and 768 deletions

File diff suppressed because it is too large Load diff

View file

@ -60,9 +60,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "true", "up": "true",
"down": "false", "down": "false",
"south": "false",
"north": "true" "north": "true"
}, },
"apply": { "apply": {
@ -71,9 +71,9 @@
}, },
{ {
"when": { "when": {
"south": "true",
"up": "true", "up": "true",
"down": "false", "down": "false",
"south": "true",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -82,9 +82,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "false", "up": "false",
"down": "true", "down": "true",
"south": "false",
"north": "true" "north": "true"
}, },
"apply": { "apply": {
@ -93,9 +93,9 @@
}, },
{ {
"when": { "when": {
"south": "true",
"up": "false", "up": "false",
"down": "true", "down": "true",
"south": "true",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -104,9 +104,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "true", "up": "true",
"down": "true", "down": "true",
"south": "false",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -115,9 +115,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "true", "up": "true",
"down": "false", "down": "false",
"south": "false",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -126,9 +126,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "false", "up": "false",
"down": "true", "down": "true",
"south": "false",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -137,9 +137,9 @@
}, },
{ {
"when": { "when": {
"up": "false",
"down": "false",
"south": "true", "south": "true",
"up": "false",
"down": "false",
"north": "true" "north": "true"
}, },
"apply": { "apply": {
@ -148,9 +148,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "false", "up": "false",
"down": "false", "down": "false",
"south": "false",
"north": "true" "north": "true"
}, },
"apply": { "apply": {
@ -159,9 +159,9 @@
}, },
{ {
"when": { "when": {
"south": "true",
"up": "false", "up": "false",
"down": "false", "down": "false",
"south": "true",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -170,9 +170,9 @@
}, },
{ {
"when": { "when": {
"south": "false",
"up": "false", "up": "false",
"down": "false", "down": "false",
"south": "false",
"north": "false" "north": "false"
}, },
"apply": { "apply": {
@ -181,8 +181,8 @@
}, },
{ {
"when": { "when": {
"south": "true",
"west": "true", "west": "true",
"south": "true",
"north": "false", "north": "false",
"east": "false" "east": "false"
}, },
@ -192,8 +192,8 @@
}, },
{ {
"when": { "when": {
"south": "true",
"west": "false", "west": "false",
"south": "true",
"north": "false", "north": "false",
"east": "true" "east": "true"
}, },
@ -203,8 +203,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "true", "west": "true",
"south": "false",
"north": "true", "north": "true",
"east": "false" "east": "false"
}, },
@ -214,8 +214,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "false", "west": "false",
"south": "false",
"north": "true", "north": "true",
"east": "true" "east": "true"
}, },
@ -225,8 +225,8 @@
}, },
{ {
"when": { "when": {
"south": "true",
"west": "false", "west": "false",
"south": "true",
"north": "true", "north": "true",
"east": "false" "east": "false"
}, },
@ -236,8 +236,8 @@
}, },
{ {
"when": { "when": {
"south": "true",
"west": "false", "west": "false",
"south": "true",
"north": "false", "north": "false",
"east": "false" "east": "false"
}, },
@ -247,8 +247,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "false", "west": "false",
"south": "false",
"north": "true", "north": "true",
"east": "false" "east": "false"
}, },
@ -258,8 +258,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "true", "west": "true",
"south": "false",
"north": "false", "north": "false",
"east": "true" "east": "true"
}, },
@ -269,8 +269,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "true", "west": "true",
"south": "false",
"north": "false", "north": "false",
"east": "false" "east": "false"
}, },
@ -280,8 +280,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "false", "west": "false",
"south": "false",
"north": "false", "north": "false",
"east": "true" "east": "true"
}, },
@ -291,8 +291,8 @@
}, },
{ {
"when": { "when": {
"south": "false",
"west": "false", "west": "false",
"south": "false",
"north": "false", "north": "false",
"east": "false" "east": "false"
}, },
@ -303,8 +303,8 @@
{ {
"when": { "when": {
"up": "true", "up": "true",
"down": "false",
"west": "false", "west": "false",
"down": "false",
"east": "true" "east": "true"
}, },
"apply": { "apply": {
@ -314,8 +314,8 @@
{ {
"when": { "when": {
"up": "true", "up": "true",
"down": "false",
"west": "true", "west": "true",
"down": "false",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -325,8 +325,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "true",
"west": "false", "west": "false",
"down": "true",
"east": "true" "east": "true"
}, },
"apply": { "apply": {
@ -336,8 +336,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "true",
"west": "true", "west": "true",
"down": "true",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -347,8 +347,8 @@
{ {
"when": { "when": {
"up": "true", "up": "true",
"down": "true",
"west": "false", "west": "false",
"down": "true",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -358,8 +358,8 @@
{ {
"when": { "when": {
"up": "true", "up": "true",
"down": "false",
"west": "false", "west": "false",
"down": "false",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -369,8 +369,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"west": "false",
"down": "true", "down": "true",
"west": "false",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -380,8 +380,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "false",
"west": "true", "west": "true",
"down": "false",
"east": "true" "east": "true"
}, },
"apply": { "apply": {
@ -391,8 +391,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "false",
"west": "false", "west": "false",
"down": "false",
"east": "true" "east": "true"
}, },
"apply": { "apply": {
@ -402,8 +402,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "false",
"west": "true", "west": "true",
"down": "false",
"east": "false" "east": "false"
}, },
"apply": { "apply": {
@ -413,8 +413,8 @@
{ {
"when": { "when": {
"up": "false", "up": "false",
"down": "false",
"west": "false", "west": "false",
"down": "false",
"east": "false" "east": "false"
}, },
"apply": { "apply": {

View file

@ -29,8 +29,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "true", "axis": "x",
"axis": "x" "sticky_south": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -39,8 +39,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "true", "axis": "y",
"axis": "y" "sticky_south": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky" "model": "create:block/radial_chassis_side_y_sticky"
@ -48,8 +48,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "true", "axis": "z",
"axis": "z" "sticky_south": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -59,8 +59,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "false", "axis": "x",
"axis": "x" "sticky_south": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -69,8 +69,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "false", "axis": "y",
"axis": "y" "sticky_south": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y" "model": "create:block/radial_chassis_side_y"
@ -78,8 +78,8 @@
}, },
{ {
"when": { "when": {
"sticky_south": "false", "axis": "z",
"axis": "z" "sticky_south": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",
@ -149,8 +149,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "true", "axis": "x",
"axis": "x" "sticky_north": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky" "model": "create:block/radial_chassis_side_x_sticky"
@ -158,8 +158,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "true", "axis": "y",
"axis": "y" "sticky_north": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y_sticky", "model": "create:block/radial_chassis_side_y_sticky",
@ -168,8 +168,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "true", "axis": "z",
"axis": "z" "sticky_north": "true"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x_sticky", "model": "create:block/radial_chassis_side_x_sticky",
@ -178,8 +178,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "false", "axis": "x",
"axis": "x" "sticky_north": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x" "model": "create:block/radial_chassis_side_x"
@ -187,8 +187,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "false", "axis": "y",
"axis": "y" "sticky_north": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_y", "model": "create:block/radial_chassis_side_y",
@ -197,8 +197,8 @@
}, },
{ {
"when": { "when": {
"sticky_north": "false", "axis": "z",
"axis": "z" "sticky_north": "false"
}, },
"apply": { "apply": {
"model": "create:block/radial_chassis_side_x", "model": "create:block/radial_chassis_side_x",

View file

@ -383,11 +383,10 @@ public abstract class KineticTileEntity extends SmartTileEntity
if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) { if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) {
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.stressometer.overstressed").formatted(GOLD))); 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");
.getTranslationKey())); List<ITextComponent> cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE);
List<ITextComponent> cutString = TooltipHelper.cutTextComponent(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE);
for (int i = 0; i < cutString.size(); i++) for (int i = 0; i < cutString.size(); i++)
tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i))); tooltip.add(componentSpacing.copy().append(cutString.get(i)));
return true; return true;
} }
@ -395,9 +394,9 @@ public abstract class KineticTileEntity extends SmartTileEntity
tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.speedRequirement").formatted(GOLD))); tooltip.add(componentSpacing.copy().append(Lang.translate("tooltip.speedRequirement").formatted(GOLD)));
ITextComponent hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock() ITextComponent hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.format(getBlockState().getBlock()
.getTranslationKey())); .getTranslationKey()));
List<ITextComponent> cutString = TooltipHelper.cutTextComponent(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE); List<ITextComponent> cutString = TooltipHelper.cutTextComponent(hint, GRAY, TextFormatting.WHITE);
for (int i = 0; i < cutString.size(); i++) for (int i = 0; i < cutString.size(); i++)
tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i))); tooltip.add(componentSpacing.copy().append(cutString.get(i)));
return true; return true;
} }

View file

@ -40,7 +40,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override @Override
public void visitNewPosition(MovementContext context, BlockPos pos) { public void visitNewPosition(MovementContext context, BlockPos pos) {
super.visitNewPosition(context, pos); super.visitNewPosition(context, pos);
Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); Vector3d facingVec = Vector3d.of(context.state.get(SawBlock.FACING).getDirectionVec());
facingVec = context.rotation.apply(facingVec); facingVec = context.rotation.apply(facingVec);
Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z);

View file

@ -21,6 +21,7 @@ import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
//TODO colors get purged with current approach, proper checklist item with UI is needed
public class MaterialChecklist { public class MaterialChecklist {
public Map<Item, Integer> gathered; public Map<Item, Integer> gathered;
@ -92,9 +93,9 @@ public class MaterialChecklist {
Collections.sort(keys, (item1, item2) -> { Collections.sort(keys, (item1, item2) -> {
Locale locale = Locale.ENGLISH; Locale locale = Locale.ENGLISH;
String name1 = String name1 =
new TranslationTextComponent(item1.getTranslationKey()).getUnformattedComponentText().toLowerCase(locale); new TranslationTextComponent(item1.getTranslationKey()).getString().toLowerCase(locale);
String name2 = String name2 =
new TranslationTextComponent(item2.getTranslationKey()).getUnformattedComponentText().toLowerCase(locale); new TranslationTextComponent(item2.getTranslationKey()).getString().toLowerCase(locale);
return name1.compareTo(name2); return name1.compareTo(name2);
}); });
@ -117,7 +118,7 @@ public class MaterialChecklist {
} }
itemsWritten++; itemsWritten++;
string.append(unfinishedEntry(new ItemStack(item), amount)); string.append(unfinishedEntry(new ItemStack(item), amount).getString());
} }
for (Item item : completed) { for (Item item : completed) {
@ -129,7 +130,7 @@ public class MaterialChecklist {
} }
itemsWritten++; itemsWritten++;
string.append(gatheredEntry(new ItemStack(item), getRequiredAmount(item))); string.append(gatheredEntry(new ItemStack(item), getRequiredAmount(item)).getString());
} }
string.append("\"}"); string.append("\"}");
@ -154,8 +155,9 @@ public class MaterialChecklist {
int stacks = amount / 64; int stacks = amount / 64;
int remainder = amount % 64; int remainder = amount % 64;
TranslationTextComponent tc = new TranslationTextComponent(item.getTranslationKey()); TranslationTextComponent tc = new TranslationTextComponent(item.getTranslationKey());
return tc.append(" \\u2714\n x" + amount).formatted(TextFormatting.DARK_GREEN).append(new StringTextComponent(" | " return tc.append(" \\u2714\n " + "---");
+ stacks + "\\u25A4 +" + remainder + "\n").formatted(TextFormatting.GRAY)); //.formatted(TextFormatting.DARK_GREEN).append(new StringTextComponent(" | "
//+ "-" + "\\u25A4 +" + "--" + "\n").formatted(TextFormatting.GRAY));
// return TextFormatting.DARK_GREEN + tc.getFormattedText() + " \\u2714\n x" + amount + TextFormatting.GRAY + " | " // return TextFormatting.DARK_GREEN + tc.getFormattedText() + " \\u2714\n x" + amount + TextFormatting.GRAY + " | "
// + stacks + "\\u25A4 +" + remainder + "\n"; // + stacks + "\\u25A4 +" + remainder + "\n";
} }

View file

@ -1,5 +1,11 @@
package com.simibubi.create.content.schematics.block; package com.simibubi.create.content.schematics.block;
import static com.simibubi.create.foundation.gui.AllGuiTextures.SCHEMATIC_TABLE;
import static com.simibubi.create.foundation.gui.AllGuiTextures.SCHEMATIC_TABLE_PROGRESS;
import java.nio.file.Paths;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
@ -14,6 +20,7 @@ import com.simibubi.create.foundation.gui.widgets.Label;
import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.client.gui.IHasContainer; import net.minecraft.client.gui.IHasContainer;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -22,13 +29,6 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import java.nio.file.Paths;
import java.util.List;
import static com.simibubi.create.foundation.gui.AllGuiTextures.SCHEMATIC_TABLE;
import static com.simibubi.create.foundation.gui.AllGuiTextures.SCHEMATIC_TABLE_PROGRESS;
public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicTableContainer> public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicTableContainer>
implements IHasContainer<SchematicTableContainer> { implements IHasContainer<SchematicTableContainer> {
@ -107,7 +107,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
if (container.getTileEntity().isUploading) if (container.getTileEntity().isUploading)
textRenderer.drawWithShadow(matrixStack, uploading, mainLeft + 11, mainTop + 3, 0xffffff); textRenderer.drawWithShadow(matrixStack, uploading, mainLeft + 11, mainTop + 3, 0xffffff);
else if (container.getSlot(1).getHasStack()) else if (container.getSlot(1)
.getHasStack())
textRenderer.drawWithShadow(matrixStack, finished, mainLeft + 11, mainTop + 3, 0xffffff); textRenderer.drawWithShadow(matrixStack, finished, mainLeft + 11, mainTop + 3, 0xffffff);
else else
textRenderer.drawWithShadow(matrixStack, title, mainLeft + 11, mainTop + 3, 0xffffff); textRenderer.drawWithShadow(matrixStack, title, mainLeft + 11, mainTop + 3, 0xffffff);
@ -125,8 +126,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
* MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress)); * MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress));
int height = SCHEMATIC_TABLE_PROGRESS.height; int height = SCHEMATIC_TABLE_PROGRESS.height;
RenderSystem.disableLighting(); RenderSystem.disableLighting();
drawTexture(matrixStack, mainLeft + 70, mainTop + 58, SCHEMATIC_TABLE_PROGRESS.startX, SCHEMATIC_TABLE_PROGRESS.startY, width, drawTexture(matrixStack, mainLeft + 70, mainTop + 58, SCHEMATIC_TABLE_PROGRESS.startX,
height); SCHEMATIC_TABLE_PROGRESS.startY, width, height);
} }
@ -148,7 +149,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
if (schematicsLabel != null) { if (schematicsLabel != null) {
schematicsLabel.colored(0xCCDDFF); schematicsLabel.colored(0xCCDDFF);
schematicsLabel.text = new StringTextComponent(container.getTileEntity().uploadingSchematic); String uploadingSchematic = container.getTileEntity().uploadingSchematic;
schematicsLabel.text = uploadingSchematic == null ? null : new StringTextComponent(uploadingSchematic);
} }
if (schematicsArea != null) if (schematicsArea != null)
schematicsArea.visible = false; schematicsArea.visible = false;

View file

@ -1,10 +1,14 @@
package com.simibubi.create.foundation.gui.widgets; package com.simibubi.create.foundation.gui.widgets;
import java.util.Objects;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.Create;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.text.IFormattableTextComponent;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
@ -37,6 +41,7 @@ public class Label extends AbstractSimiWidget {
public Label withSuffix(String s) { public Label withSuffix(String s) {
suffix = s; suffix = s;
Create.logger.info("Suffix is now " + Objects.toString(s));
return this; return this;
} }
@ -51,7 +56,7 @@ public class Label extends AbstractSimiWidget {
String trim = "..."; String trim = "...";
int trimWidth = fontRenderer.getStringWidth(trim); int trimWidth = fontRenderer.getStringWidth(trim);
String raw = newText.getUnformattedComponentText(); String raw = newText.getString();
StringBuilder builder = new StringBuilder(raw); StringBuilder builder = new StringBuilder(raw);
int startIndex = trimFront ? 0 : raw.length() - 1; int startIndex = trimFront ? 0 : raw.length() - 1;
int endIndex = !trimFront ? 0 : raw.length() - 1; int endIndex = !trimFront ? 0 : raw.length() - 1;
@ -75,10 +80,14 @@ public class Label extends AbstractSimiWidget {
return; return;
RenderSystem.color4f(1, 1, 1, 1); RenderSystem.color4f(1, 1, 1, 1);
IFormattableTextComponent copy = text.copy();
if (suffix != null && !suffix.isEmpty())
copy.append(suffix);
if (hasShadow) if (hasShadow)
font.drawWithShadow(matrixStack, text.copy().append(suffix), x, y, color); font.drawWithShadow(matrixStack, copy, x, y, color);
else else
font.draw(matrixStack, text.copy().append(suffix), x, y, color); font.draw(matrixStack, copy, x, y, color);
} }
} }

View file

@ -1,7 +1,5 @@
package com.simibubi.create.foundation.item; package com.simibubi.create.foundation.item;
import static net.minecraft.util.text.TextFormatting.DARK_GRAY;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -44,9 +42,8 @@ public class TooltipHelper {
public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) { public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) {
TextFormatting colorFormat = highlighted ? color.hColor : color.color; TextFormatting colorFormat = highlighted ? color.hColor : color.color;
return Lang.translate("tooltip.holdKey", DARK_GRAY) return Lang.translate("tooltip.holdKey", Lang.translate("tooltip.keyShift")
.append(Lang.translate("tooltip.keyShift") .formatted(colorFormat)).formatted(TextFormatting.DARK_GRAY);
.formatted(colorFormat));
} }
public static void referTo(IItemProvider item, Supplier<? extends IItemProvider> itemWithTooltip) { public static void referTo(IItemProvider item, Supplier<? extends IItemProvider> itemWithTooltip) {
@ -103,21 +100,23 @@ public class TooltipHelper {
return lines; return lines;
} }
public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor, TextFormatting highlightColor) { public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor,
TextFormatting highlightColor) {
return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, 0); return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, 0);
} }
public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor, TextFormatting highlightColor) { public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor,
TextFormatting highlightColor) {
return cutTextComponent(c, defaultColor, highlightColor, 0); return cutTextComponent(c, defaultColor, highlightColor, 0);
} }
public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor, TextFormatting highlightColor, public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor,
int indent) { TextFormatting highlightColor, int indent) {
return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, indent); return cutTextComponent(new StringTextComponent(c), defaultColor, highlightColor, indent);
} }
public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor, TextFormatting highlightColor, public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor,
int indent) { TextFormatting highlightColor, int indent) {
IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy(); IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy();
for (int i = 0; i < indent; i++) for (int i = 0; i < indent; i++)
lineStart.append(" "); lineStart.append(" ");
@ -143,7 +142,8 @@ public class TooltipHelper {
firstWord = true; firstWord = true;
} }
currentLine.append(new StringTextComponent((firstWord ? "" : " ") + word.replace("_", "")).formatted(word.matches("_([^_]+)_") ? highlightColor : defaultColor)); currentLine.append(new StringTextComponent((firstWord ? "" : " ") + word.replace("_", ""))
.formatted(word.matches("_([^_]+)_") ? highlightColor : defaultColor));
firstWord = false; firstWord = false;
} }
@ -272,7 +272,8 @@ public class TooltipHelper {
public static String getUnformattedDeepText(ITextComponent component) { public static String getUnformattedDeepText(ITextComponent component) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(component.getString()); b.append(component.getString());
component.getSiblings().forEach(c -> { component.getSiblings()
.forEach(c -> {
b.append(getUnformattedDeepText(c)); b.append(getUnformattedDeepText(c));
}); });
return b.toString(); return b.toString();