|
2 | 2 |
|
3 | 3 | import com.github.zly2006.enclosure.EnclosureView;
|
4 | 4 | import com.github.zly2006.enclosure.network.config.UUIDCacheS2CPacket;
|
| 5 | +import com.github.zly2006.enclosure.utils.UtilsKt; |
5 | 6 | import net.minecraft.client.MinecraftClient;
|
6 | 7 | import net.minecraft.client.gui.DrawContext;
|
7 | 8 | import net.minecraft.client.gui.Element;
|
8 | 9 | import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
9 | 10 | import net.minecraft.client.gui.widget.ButtonWidget;
|
10 | 11 | import net.minecraft.entity.player.PlayerInventory;
|
| 12 | +import net.minecraft.text.MutableText; |
11 | 13 | import net.minecraft.text.Text;
|
12 | 14 | import net.minecraft.util.Formatting;
|
13 | 15 | import org.jetbrains.annotations.Nullable;
|
@@ -54,7 +56,7 @@ protected void init() {
|
54 | 56 | .size(100, 20)
|
55 | 57 | .position(5, 35)
|
56 | 58 | .build());
|
57 |
| - playerWidget = addDrawableChild(ButtonWidget.builder(Text.translatable("enclosure.widget.player"), button -> { |
| 59 | + playerWidget = addDrawableChild(ButtonWidget.builder(Text.translatable("enclosure.widget.showplayer"), button -> { |
58 | 60 | assert client != null;
|
59 | 61 | button.active = false;
|
60 | 62 | unlistedWidget.active = true;
|
@@ -98,37 +100,16 @@ protected void init() {
|
98 | 100 | }, 5, 5, width - 10));
|
99 | 101 | }
|
100 | 102 | textWidgets.add(new ClickableTextWidget(client, this, Text.empty()
|
101 |
| - .append(Text.literal(area.getFullName()).styled(style -> style.withColor(Formatting.GOLD))) |
102 |
| - .append(" ") |
103 |
| - .append(Text.translatable("enclosure.info.created_by")) |
104 |
| - .append(" ") |
105 |
| - .append(owner == null ? |
106 |
| - Text.translatable("enclosure.message.unknown_user").styled(style -> style.withColor(Formatting.RED)) : |
107 |
| - Text.literal(owner).styled(style -> style.withColor(Formatting.GOLD))) |
108 |
| - .append(", ") |
109 |
| - .append(Text.translatable("enclosure.info.created_on")) |
110 |
| - .append(Text.literal(new SimpleDateFormat().format(area.getCreatedOn())).styled(style -> style.withColor(Formatting.GOLD))), |
| 103 | + .append(Text.translatable("enclosure.info.created", |
| 104 | + Text.literal(area.getFullName()).styled(style -> style.withColor(Formatting.GOLD)), |
| 105 | + (owner == null ? |
| 106 | + Text.translatable("enclosure.message.unknown_user").styled(style -> style.withColor(Formatting.RED)) : Text.literal(owner).styled(style -> style.withColor(Formatting.GOLD))), |
| 107 | + Text.literal(new SimpleDateFormat().format(area.getCreatedOn())).styled(style -> style.withColor(Formatting.GOLD)) |
| 108 | + )), |
111 | 109 | null, null,
|
112 | 110 | 5, 5, width - 10));
|
113 |
| - textWidgets.add(new ClickableTextWidget(client, this, Text.translatable("enclosure.message.select.from") |
114 |
| - .append(Text.literal("[").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
115 |
| - .append(Text.literal(String.valueOf(area.getMinX())).styled(style -> style.withColor(Formatting.GREEN))) |
116 |
| - .append(Text.literal(", ").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
117 |
| - .append(Text.literal(String.valueOf(area.getMinY())).styled(style -> style.withColor(Formatting.GREEN))) |
118 |
| - .append(Text.literal(", ").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
119 |
| - .append(Text.literal(String.valueOf(area.getMinZ())).styled(style -> style.withColor(Formatting.GREEN))) |
120 |
| - .append(Text.literal("]").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
121 |
| - .append(Text.translatable("enclosure.message.select.to")) |
122 |
| - .append(Text.literal("[").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
123 |
| - .append(Text.literal(String.valueOf(area.getMaxX())).styled(style -> style.withColor(Formatting.GREEN))) |
124 |
| - .append(Text.literal(", ").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
125 |
| - .append(Text.literal(String.valueOf(area.getMaxY())).styled(style -> style.withColor(Formatting.GREEN))) |
126 |
| - .append(Text.literal(", ").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
127 |
| - .append(Text.literal(String.valueOf(area.getMaxZ())).styled(style -> style.withColor(Formatting.GREEN))) |
128 |
| - .append(Text.literal("]").styled(style -> style.withColor(Formatting.DARK_GREEN))) |
129 |
| - .append(Text.translatable("enclosure.message.select.world")) |
130 |
| - .append(Text.literal(handler.worldId.toString()).styled(style -> style.withColor(Formatting.GOLD))), |
131 |
| - Text.translatable("enclosure.widget.selection_render.hover"), |
| 111 | + MutableText selectionText = UtilsKt.formatSelection(handler.worldId, area.getMinX(), area.getMinY(), area.getMinZ(), area.getMaxX(), area.getMaxY(), area.getMaxZ()); |
| 112 | + textWidgets.add(new ClickableTextWidget(client, this, selectionText, Text.translatable("enclosure.widget.selection_render.hover"), |
132 | 113 | button -> {
|
133 | 114 | assert client.player != null;
|
134 | 115 | client.player.networkHandler.sendChatCommand("enclosure select land " + handler.fullName);
|
|
0 commit comments