mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 12:32:05 +01:00
Fix even more text components, now in tooltips
This commit is contained in:
parent
0d972e144f
commit
e8c458f2ad
11 changed files with 192 additions and 161 deletions
|
@ -132,7 +132,7 @@ fc652317e03b57c76e23a805da16a28d15254029 assets/create/blockstates/fancy_scoria_
|
|||
fc9ac0a7e7191b93516719455a17177fa6524ecc assets/create/blockstates/fancy_weathered_limestone_bricks_slab.json
|
||||
b2a7c321b1795f20e7433f81a55ce4683de081b8 assets/create/blockstates/fancy_weathered_limestone_bricks_stairs.json
|
||||
8e532856c3c2b4e4e59c65a2a81a694e35d14658 assets/create/blockstates/fancy_weathered_limestone_bricks_wall.json
|
||||
5ba9fc9e7b29c76040329367cfb45affdd473404 assets/create/blockstates/fluid_pipe.json
|
||||
3d97226b5e8d8f70ed08e45e78db1faf78d5e28b assets/create/blockstates/fluid_pipe.json
|
||||
f0eaab18e16c4f3f65ebf3b55b08f0dc445720fe assets/create/blockstates/fluid_tank.json
|
||||
5408d92ab02af86539ac42971d4033545970bb3a assets/create/blockstates/fluid_valve.json
|
||||
e9da1794b6ece7f9aa8bcb43d42c23a55446133b assets/create/blockstates/flywheel.json
|
||||
|
@ -312,7 +312,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
|
|||
469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets/create/blockstates/pulse_repeater.json
|
||||
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
|
||||
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json
|
||||
5d1b30c2bab556f57c78e7780fd445b08f541a50 assets/create/blockstates/radial_chassis.json
|
||||
4439fc83a8c7370ab44b211a3fd48abde20a4728 assets/create/blockstates/radial_chassis.json
|
||||
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
|
||||
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json
|
||||
8929677f2cc5354aa19ef182af69f9f0b41eb242 assets/create/blockstates/redstone_contact.json
|
||||
|
|
|
@ -60,10 +60,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"down": "false",
|
||||
"south": "false",
|
||||
"north": "true"
|
||||
"north": "true",
|
||||
"up": "true",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lu_x"
|
||||
|
@ -71,10 +71,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"down": "false",
|
||||
"south": "true",
|
||||
"north": "false"
|
||||
"north": "false",
|
||||
"up": "true",
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ru_x"
|
||||
|
@ -82,10 +82,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "true",
|
||||
"south": "false",
|
||||
"north": "true"
|
||||
"north": "true",
|
||||
"up": "false",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ld_x"
|
||||
|
@ -93,10 +93,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "true",
|
||||
"south": "true",
|
||||
"north": "false"
|
||||
"north": "false",
|
||||
"up": "false",
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/rd_x"
|
||||
|
@ -104,21 +104,21 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"down": "true",
|
||||
"south": "false",
|
||||
"north": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_x"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"north": "false",
|
||||
"up": "true",
|
||||
"down": "false",
|
||||
"south": "false",
|
||||
"north": "false"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_x"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"down": "false",
|
||||
"north": "false",
|
||||
"up": "true",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_x"
|
||||
|
@ -126,10 +126,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "true",
|
||||
"south": "false",
|
||||
"north": "false"
|
||||
"north": "false",
|
||||
"up": "false",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_x"
|
||||
|
@ -137,10 +137,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "false",
|
||||
"south": "true",
|
||||
"north": "true"
|
||||
"north": "true",
|
||||
"up": "false",
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_x"
|
||||
|
@ -148,10 +148,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "false",
|
||||
"south": "false",
|
||||
"north": "true"
|
||||
"north": "true",
|
||||
"up": "false",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_x"
|
||||
|
@ -159,10 +159,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "false",
|
||||
"south": "true",
|
||||
"north": "false"
|
||||
"north": "false",
|
||||
"up": "false",
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_x"
|
||||
|
@ -170,10 +170,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"down": "false",
|
||||
"south": "false",
|
||||
"north": "false"
|
||||
"north": "false",
|
||||
"up": "false",
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/none_x"
|
||||
|
@ -182,9 +182,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "true",
|
||||
"south": "true",
|
||||
"east": "false",
|
||||
"north": "false",
|
||||
"east": "false"
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lu_y"
|
||||
|
@ -193,9 +193,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "true",
|
||||
"east": "true",
|
||||
"north": "false",
|
||||
"east": "true"
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ru_y"
|
||||
|
@ -204,9 +204,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "true",
|
||||
"south": "false",
|
||||
"east": "false",
|
||||
"north": "true",
|
||||
"east": "false"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ld_y"
|
||||
|
@ -215,9 +215,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "false",
|
||||
"east": "true",
|
||||
"north": "true",
|
||||
"east": "true"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/rd_y"
|
||||
|
@ -226,9 +226,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "true",
|
||||
"east": "false",
|
||||
"north": "true",
|
||||
"east": "false"
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_y"
|
||||
|
@ -237,9 +237,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "true",
|
||||
"east": "false",
|
||||
"north": "false",
|
||||
"east": "false"
|
||||
"south": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_y"
|
||||
|
@ -248,9 +248,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "false",
|
||||
"east": "false",
|
||||
"north": "true",
|
||||
"east": "false"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_y"
|
||||
|
@ -259,9 +259,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "true",
|
||||
"south": "false",
|
||||
"east": "true",
|
||||
"north": "false",
|
||||
"east": "true"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_y"
|
||||
|
@ -270,9 +270,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "true",
|
||||
"south": "false",
|
||||
"east": "false",
|
||||
"north": "false",
|
||||
"east": "false"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_y"
|
||||
|
@ -281,9 +281,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "false",
|
||||
"east": "true",
|
||||
"north": "false",
|
||||
"east": "true"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_y"
|
||||
|
@ -292,9 +292,9 @@
|
|||
{
|
||||
"when": {
|
||||
"west": "false",
|
||||
"south": "false",
|
||||
"east": "false",
|
||||
"north": "false",
|
||||
"east": "false"
|
||||
"south": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/none_y"
|
||||
|
@ -302,10 +302,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"west": "false",
|
||||
"down": "false",
|
||||
"east": "true"
|
||||
"east": "true",
|
||||
"up": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lu_z"
|
||||
|
@ -313,10 +313,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"west": "true",
|
||||
"down": "false",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ru_z"
|
||||
|
@ -324,10 +324,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "false",
|
||||
"down": "true",
|
||||
"east": "true"
|
||||
"east": "true",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ld_z"
|
||||
|
@ -335,10 +335,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "true",
|
||||
"down": "true",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/rd_z"
|
||||
|
@ -346,10 +346,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"west": "false",
|
||||
"down": "true",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_z"
|
||||
|
@ -357,10 +357,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "true",
|
||||
"west": "false",
|
||||
"down": "false",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_z"
|
||||
|
@ -368,10 +368,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "false",
|
||||
"down": "true",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/ud_z"
|
||||
|
@ -379,10 +379,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "true",
|
||||
"down": "false",
|
||||
"east": "true"
|
||||
"east": "true",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_z"
|
||||
|
@ -390,10 +390,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "false",
|
||||
"down": "false",
|
||||
"east": "true"
|
||||
"east": "true",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_z"
|
||||
|
@ -401,10 +401,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "true",
|
||||
"down": "false",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/lr_z"
|
||||
|
@ -412,10 +412,10 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "false",
|
||||
"west": "false",
|
||||
"down": "false",
|
||||
"east": "false"
|
||||
"east": "false",
|
||||
"up": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/fluid_pipe/none_z"
|
||||
|
|
|
@ -207,8 +207,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x_sticky",
|
||||
|
@ -217,8 +217,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y_sticky",
|
||||
|
@ -227,8 +227,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "true",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_east": "true"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z_sticky"
|
||||
|
@ -236,8 +236,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "x"
|
||||
"axis": "x",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_x",
|
||||
|
@ -246,8 +246,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "y"
|
||||
"axis": "y",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_y",
|
||||
|
@ -256,8 +256,8 @@
|
|||
},
|
||||
{
|
||||
"when": {
|
||||
"sticky_east": "false",
|
||||
"axis": "z"
|
||||
"axis": "z",
|
||||
"sticky_east": "false"
|
||||
},
|
||||
"apply": {
|
||||
"model": "create:block/radial_chassis_side_z"
|
||||
|
|
|
@ -380,7 +380,7 @@ 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<String> cutString = TooltipHelper.cutString(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE);
|
||||
List<ITextComponent> cutString = TooltipHelper.cutTextComponent(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE);
|
||||
for (int i = 0; i < cutString.size(); i++)
|
||||
tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i)));
|
||||
return true;
|
||||
|
@ -390,7 +390,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
|||
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<String> cutString = TooltipHelper.cutString(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE);
|
||||
List<ITextComponent> cutString = TooltipHelper.cutTextComponent(componentSpacing.copy().append(hint), GRAY, TextFormatting.WHITE);
|
||||
for (int i = 0; i < cutString.size(); i++)
|
||||
tooltip.add((i == 0 ? StringTextComponent.EMPTY : componentSpacing).copy().append(cutString.get(i)));
|
||||
return true;
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.minecraft.util.math.RayTraceContext.BlockMode;
|
|||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
@ -67,7 +68,7 @@ public class BlockzapperItem extends ZapperItem {
|
|||
ITextComponent componentName =
|
||||
Lang.translate("blockzapper.component." + Lang.asId(c.name())).formatted(TextFormatting.GRAY);
|
||||
ITextComponent tierName = Lang.translate("blockzapper.componentTier." + Lang.asId(tier.name())).formatted(tier.color);
|
||||
ItemDescription.add(tooltip, "> " + componentName + ": " + tierName);
|
||||
ItemDescription.add(tooltip, new StringTextComponent("> ").append(componentName).append(": ").append(tierName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
|
|||
if (!button.isHovered())
|
||||
return;
|
||||
List<ITextComponent> tip = button.getToolTip();
|
||||
TooltipHelper.cutString(tooltip, GRAY, GRAY).stream().map(ITextComponent::of).forEachOrdered(tip::add);
|
||||
tip.addAll(TooltipHelper.cutTextComponent(tooltip, GRAY, GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,7 +74,7 @@ public class FilterItem extends Item implements INamedContainerProvider {
|
|||
List<ITextComponent> makeSummary = makeSummary(stack);
|
||||
if (makeSummary.isEmpty())
|
||||
return;
|
||||
ItemDescription.add(tooltip, " ");
|
||||
ItemDescription.add(tooltip, ITextComponent.of(" "));
|
||||
ItemDescription.add(tooltip, makeSummary);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
boolean enabled = indicator.state == State.ON;
|
||||
List<ITextComponent> tip = button.getToolTip();
|
||||
tip.add((enabled ? optionEnabled : optionDisabled).copy().formatted(TextFormatting.BLUE));
|
||||
TooltipHelper.cutString(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY, GRAY).forEach(s -> tip.add(new StringTextComponent(s).formatted(GRAY)));
|
||||
tip.addAll(TooltipHelper.cutTextComponent(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY, GRAY));
|
||||
|
||||
}
|
||||
|
||||
|
@ -325,15 +325,15 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
|
|||
if (hoveredSlot != null && !hoveredSlot.getHasStack()) {
|
||||
if (hoveredSlot.getSlotIndex() == 0)
|
||||
renderTooltip(matrixStack,
|
||||
TooltipHelper.cutStringToComponents(Lang.translate(_slotSchematic), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
TooltipHelper.cutTextComponent(Lang.translate(_slotSchematic), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
mouseX, mouseY);
|
||||
if (hoveredSlot.getSlotIndex() == 2)
|
||||
renderTooltip(matrixStack,
|
||||
TooltipHelper.cutStringToComponents(Lang.translate(_slotListPrinter), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
TooltipHelper.cutTextComponent(Lang.translate(_slotListPrinter), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
mouseX, mouseY);
|
||||
if (hoveredSlot.getSlotIndex() == 4)
|
||||
renderTooltip(matrixStack,
|
||||
TooltipHelper.cutStringToComponents(Lang.translate(_slotGunpowder), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
TooltipHelper.cutTextComponent(Lang.translate(_slotGunpowder), TextFormatting.GRAY, TextFormatting.BLUE),
|
||||
mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
package com.simibubi.create.foundation.item;
|
||||
|
||||
import static com.simibubi.create.foundation.item.TooltipHelper.cutString;
|
||||
import static net.minecraft.util.text.TextFormatting.AQUA;
|
||||
import static net.minecraft.util.text.TextFormatting.BLUE;
|
||||
import static net.minecraft.util.text.TextFormatting.DARK_GRAY;
|
||||
import static net.minecraft.util.text.TextFormatting.DARK_GREEN;
|
||||
import static net.minecraft.util.text.TextFormatting.DARK_PURPLE;
|
||||
import static net.minecraft.util.text.TextFormatting.DARK_RED;
|
||||
import static net.minecraft.util.text.TextFormatting.GOLD;
|
||||
import static net.minecraft.util.text.TextFormatting.GRAY;
|
||||
import static net.minecraft.util.text.TextFormatting.GREEN;
|
||||
import static net.minecraft.util.text.TextFormatting.LIGHT_PURPLE;
|
||||
import static net.minecraft.util.text.TextFormatting.RED;
|
||||
import static net.minecraft.util.text.TextFormatting.STRIKETHROUGH;
|
||||
import static net.minecraft.util.text.TextFormatting.WHITE;
|
||||
import static net.minecraft.util.text.TextFormatting.YELLOW;
|
||||
import static com.simibubi.create.foundation.item.TooltipHelper.*;
|
||||
import static net.minecraft.util.text.TextFormatting.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -83,8 +70,8 @@ public class ItemDescription {
|
|||
}
|
||||
|
||||
public ItemDescription withSummary(ITextComponent summary) {
|
||||
addStrings(linesOnShift, cutString(summary, palette.color, palette.hColor));
|
||||
add(linesOnShift, "");
|
||||
addStrings(linesOnShift, cutTextComponent(summary, palette.color, palette.hColor));
|
||||
add(linesOnShift, StringTextComponent.EMPTY);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -109,11 +96,10 @@ public class ItemDescription {
|
|||
if (hasSpeedRequirement) {
|
||||
List<ITextComponent> speedLevels = Lang.translatedOptions("tooltip.speedRequirement", "none", "medium", "high");
|
||||
int index = minimumRequiredSpeedLevel.ordinal();
|
||||
String level =
|
||||
minimumRequiredSpeedLevel.getTextColor() + makeProgressBar(3, index) + speedLevels.get(index);
|
||||
IFormattableTextComponent level = new StringTextComponent(makeProgressBar(3, index)).append(speedLevels.get(index)).formatted(minimumRequiredSpeedLevel.getTextColor());
|
||||
|
||||
if (hasGlasses)
|
||||
level += " (" + minimumRequiredSpeedLevel.getSpeedValue() + rpmUnit + "+)";
|
||||
level.append(" (" + minimumRequiredSpeedLevel.getSpeedValue()).append(rpmUnit).append("+)");
|
||||
|
||||
add(linesOnShift, Lang.translate("tooltip.speedRequirement").formatted(GRAY));
|
||||
add(linesOnShift, level);
|
||||
|
@ -127,11 +113,10 @@ public class ItemDescription {
|
|||
StressImpact impactId = impact >= config.highStressImpact.get() ? StressImpact.HIGH
|
||||
: (impact >= config.mediumStressImpact.get() ? StressImpact.MEDIUM : StressImpact.LOW);
|
||||
int index = impactId.ordinal();
|
||||
String level = impactId.getAbsoluteColor() + makeProgressBar(3, index) + stressLevels.get(index);
|
||||
IFormattableTextComponent level = new StringTextComponent(makeProgressBar(3, index)).append(stressLevels.get(index)).formatted(impactId.getAbsoluteColor());
|
||||
|
||||
if (hasGlasses)
|
||||
level += " (" + impacts.get(id)
|
||||
.get() + stressUnit + ")";
|
||||
level.append(" (" + impacts.get(id).get()).append(stressUnit).append(")");
|
||||
|
||||
add(linesOnShift, Lang.translate("tooltip.stressImpact").formatted(GRAY));
|
||||
add(linesOnShift, level);
|
||||
|
@ -145,25 +130,24 @@ public class ItemDescription {
|
|||
StressImpact impactId = capacity >= config.highCapacity.get() ? StressImpact.LOW
|
||||
: (capacity >= config.mediumCapacity.get() ? StressImpact.MEDIUM : StressImpact.HIGH);
|
||||
int index = StressImpact.values().length - 2 - impactId.ordinal();
|
||||
String level = impactId.getAbsoluteColor() + makeProgressBar(3, index) + stressCapacityLevels.get(index);
|
||||
IFormattableTextComponent level = new StringTextComponent(makeProgressBar(3, index)).append(stressCapacityLevels.get(index)).formatted(impactId.getAbsoluteColor());
|
||||
|
||||
if (hasGlasses)
|
||||
level += " (" + capacity + stressUnit + ")";
|
||||
level.append(" (" + capacity).append(stressUnit).append(")");
|
||||
if (!isEngine && ((IRotate) block).showCapacityWithAnnotation())
|
||||
level +=
|
||||
" " + DARK_GRAY + TextFormatting.ITALIC + Lang.translate("tooltip.capacityProvided.asGenerator");
|
||||
level.append(" ").append(Lang.translate("tooltip.capacityProvided.asGenerator").formatted(DARK_GRAY, ITALIC));
|
||||
|
||||
add(linesOnShift, Lang.translate("tooltip.capacityProvided").formatted(GRAY));
|
||||
add(linesOnShift, level);
|
||||
|
||||
IFormattableTextComponent genSpeed = generatorSpeed(block, rpmUnit);
|
||||
if (!genSpeed.getUnformattedComponentText().equals("")) {
|
||||
add(linesOnShift, GREEN + " " + genSpeed);
|
||||
add(linesOnShift, new StringTextComponent(" ").append(genSpeed).formatted(GREEN));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSpeedRequirement || hasStressImpact || hasStressCapacity)
|
||||
add(linesOnShift, "");
|
||||
add(linesOnShift, StringTextComponent.EMPTY);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -178,14 +162,14 @@ public class ItemDescription {
|
|||
}
|
||||
|
||||
public ItemDescription withBehaviour(String condition, String behaviour) {
|
||||
add(linesOnShift, GRAY + condition);
|
||||
addStrings(linesOnShift, cutString(behaviour, palette.color, palette.hColor, 1));
|
||||
add(linesOnShift, new StringTextComponent(condition).formatted(GRAY));
|
||||
addStrings(linesOnShift, cutStringTextComponent(behaviour, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemDescription withControl(String condition, String action) {
|
||||
add(linesOnCtrl, GRAY + condition);
|
||||
addStrings(linesOnCtrl, cutString(action, palette.color, palette.hColor, 1));
|
||||
add(linesOnCtrl, new StringTextComponent(condition).formatted(GRAY));
|
||||
addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -248,7 +232,7 @@ public class ItemDescription {
|
|||
return palette.hColor + s + palette.color;
|
||||
}
|
||||
|
||||
public static void addStrings(List<ITextComponent> infoList, List<String> textLines) {
|
||||
public static void addStrings(List<ITextComponent> infoList, List<ITextComponent> textLines) {
|
||||
textLines.forEach(s -> add(infoList, s));
|
||||
}
|
||||
|
||||
|
@ -256,10 +240,6 @@ public class ItemDescription {
|
|||
infoList.addAll(textLines);
|
||||
}
|
||||
|
||||
public static void add(List<ITextComponent> infoList, String line) {
|
||||
infoList.add(new StringTextComponent(line));
|
||||
}
|
||||
|
||||
public static void add(List<ITextComponent> infoList, ITextComponent line) {
|
||||
infoList.add(line);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,8 @@ package com.simibubi.create.foundation.item;
|
|||
|
||||
import static net.minecraft.util.text.TextFormatting.DARK_GRAY;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.mojang.bridge.game.Language;
|
||||
import com.simibubi.create.AllItems;
|
||||
|
@ -26,9 +23,7 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.TieredItem;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.*;
|
||||
|
||||
public class TooltipHelper {
|
||||
|
||||
|
@ -44,17 +39,12 @@ public class TooltipHelper {
|
|||
.formatted(colorFormat));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static List<String> cutString(ITextComponent s, TextFormatting defaultColor, TextFormatting highlightColor) {
|
||||
return cutString(s.getUnformattedComponentText(), defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<ITextComponent> cutStringToComponents(ITextComponent s, TextFormatting defaultColor,
|
||||
TextFormatting highlightColor) {
|
||||
return cutString(s.getUnformattedComponentText(), defaultColor, highlightColor, 0).stream()
|
||||
.map(ITextComponent::of)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static List<String> cutString(String s, TextFormatting defaultColor, TextFormatting highlightColor,
|
||||
int indent) {
|
||||
String lineStart = defaultColor.toString();
|
||||
|
@ -93,6 +83,57 @@ public class TooltipHelper {
|
|||
return lines;
|
||||
}
|
||||
|
||||
public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor, TextFormatting highlightColor) {
|
||||
return cutTextComponent(ITextComponent.of(c), defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor, TextFormatting highlightColor) {
|
||||
return cutTextComponent(c, defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<ITextComponent> cutStringTextComponent(String c, TextFormatting defaultColor, TextFormatting highlightColor,
|
||||
int indent) {
|
||||
return cutTextComponent(ITextComponent.of(c), defaultColor, highlightColor, indent);
|
||||
}
|
||||
|
||||
public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor, TextFormatting highlightColor,
|
||||
int indent) {
|
||||
IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy();
|
||||
for (int i = 0; i < indent; i++)
|
||||
lineStart.append(" ");
|
||||
lineStart.formatted(defaultColor);
|
||||
|
||||
List<ITextComponent> lines = new ArrayList<>();
|
||||
String rawText = c.getUnformattedComponentText();
|
||||
String[] words = rawText.split(" ");
|
||||
String word;
|
||||
IFormattableTextComponent currentLine = lineStart.copy();
|
||||
|
||||
boolean firstWord = true;
|
||||
boolean lastWord;
|
||||
|
||||
// Apply hard wrap
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
word = words[i];
|
||||
lastWord = i == words.length - 1;
|
||||
|
||||
if (!lastWord && !firstWord && getComponentLength(currentLine) + word.length() > maxCharsPerLine) {
|
||||
lines.add(currentLine);
|
||||
currentLine = lineStart.copy();
|
||||
firstWord = true;
|
||||
}
|
||||
|
||||
currentLine.append(new StringTextComponent((firstWord ? "" : " ") + word.replace("_", "")).formatted(word.matches("_([^_]+)_") ? highlightColor : defaultColor));
|
||||
firstWord = false;
|
||||
}
|
||||
|
||||
if (!firstWord) {
|
||||
lines.add(currentLine);
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static void checkLocale() {
|
||||
Language currentLanguage = Minecraft.getInstance()
|
||||
.getLanguageManager()
|
||||
|
@ -201,4 +242,13 @@ public class TooltipHelper {
|
|||
.getTranslationKey(stack) + ".tooltip";
|
||||
}
|
||||
|
||||
private static int getComponentLength(ITextComponent component) {
|
||||
AtomicInteger l = new AtomicInteger();
|
||||
TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
||||
l.getAndIncrement();
|
||||
return true;
|
||||
});
|
||||
return l.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class WipScription extends ItemDescription {
|
|||
int index = new Random().nextInt(descriptions);
|
||||
ITextComponent translate = Lang.translate("tooltip.randomWipDescription" + index);
|
||||
List<ITextComponent> lines = getLines();
|
||||
TooltipHelper.cutString(translate, TextFormatting.DARK_RED, TextFormatting.DARK_RED).forEach(s -> lines.add(new StringTextComponent(s).formatted(TextFormatting.DARK_RED)));
|
||||
lines.addAll(TooltipHelper.cutTextComponent(translate, TextFormatting.DARK_RED, TextFormatting.DARK_RED));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue