CommonComponents .java

net.minecraft.network.chat.CommonComponents (class, 86 lines): members: GUI_COPY_LINK_TO_CLIPBOARD, TRANSFER_CONNECT_FAILED, GUI_COPY_TO_CLIPBOARD, days.

net.minecraft.network.chatclass86 linescommon3.7 KB

API Surface (11)

MutableComponent space()
MutableComponent days(final long value)
MutableComponent hours(final long value)
MutableComponent minutes(final long value)
Component optionStatus(final boolean value)
Component disconnectButtonLabel(final boolean isLocalServer)
MutableComponent optionStatus(final Component name, final boolean value)
MutableComponent optionNameValue(final Component name, final Component value)
MutableComponent joinForNarration(final Component... components)
Component joinLines(final Component... lines)
Component joinLines(final Collection<? extends Component> lines)

Fields & Constants (25)

EMPTY
OPTION_ON
OPTION_OFF
GUI_DONE
GUI_CANCEL
GUI_YES
GUI_REMOVE
GUI_NO
GUI_OK
GUI_PROCEED
GUI_CONTINUE
GUI_BACK
GUI_TO_TITLE
GUI_ACKNOWLEDGE
GUI_OPEN_IN_BROWSER
GUI_COPY_TO_CLIPBOARD
GUI_COPY_LINK_TO_CLIPBOARD
GUI_DISCONNECT
GUI_RETURN_TO_MENU
TRANSFER_CONNECT_FAILED
CONNECT_FAILED
NEW_LINE
NARRATION_SEPARATOR
ELLIPSIS
SPACE

String literals (26)

"options.on"
"options.off"
"gui.done"
"gui.cancel"
"gui.yes"
"gui.remove"
"gui.no"
"gui.ok"
"gui.proceed"
"gui.continue"
"gui.back"
"gui.toTitle"
"gui.acknowledge"
"chat.link.open"
"chat.copy"
"gui.copy_link_to_clipboard"
"menu.disconnect"
"menu.returnToMenu"
"connect.failed.transfer"
"connect.failed"
"gui.days"
"gui.hours"
"gui.minutes"
"options.on.composed"

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

CommonComponents.java86 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.chat;
2
3
import java.util.Arrays;
4
import java.util.Collection;
5
6
public class CommonComponents {
7
	public static final Component EMPTY = Component.empty();
8
	public static final Component OPTION_ON = Component.translatable("options.on");
9
	public static final Component OPTION_OFF = Component.translatable("options.off");
10
	public static final Component GUI_DONE = Component.translatable("gui.done");
11
	public static final Component GUI_CANCEL = Component.translatable("gui.cancel");
12
	public static final Component GUI_YES = Component.translatable("gui.yes");
13
	public static final Component GUI_REMOVE = Component.translatable("gui.remove");
14
	public static final Component GUI_NO = Component.translatable("gui.no");
15
	public static final Component GUI_OK = Component.translatable("gui.ok");
16
	public static final Component GUI_PROCEED = Component.translatable("gui.proceed");
17
	public static final Component GUI_CONTINUE = Component.translatable("gui.continue");
18
	public static final Component GUI_BACK = Component.translatable("gui.back");
19
	public static final Component GUI_TO_TITLE = Component.translatable("gui.toTitle");
20
	public static final Component GUI_ACKNOWLEDGE = Component.translatable("gui.acknowledge");
21
	public static final Component GUI_OPEN_IN_BROWSER = Component.translatable("chat.link.open");
22
	public static final Component GUI_COPY_TO_CLIPBOARD = Component.translatable("chat.copy");
23
	public static final Component GUI_COPY_LINK_TO_CLIPBOARD = Component.translatable("gui.copy_link_to_clipboard");
24
	public static final Component GUI_DISCONNECT = Component.translatable("menu.disconnect");
25
	public static final Component GUI_RETURN_TO_MENU = Component.translatable("menu.returnToMenu");
26
	public static final Component TRANSFER_CONNECT_FAILED = Component.translatable("connect.failed.transfer");
27
	public static final Component CONNECT_FAILED = Component.translatable("connect.failed");
28
	public static final Component NEW_LINE = Component.literal("\n");
29
	public static final Component NARRATION_SEPARATOR = Component.literal(". ");
30
	public static final Component ELLIPSIS = Component.literal("...");
31
	public static final Component SPACE = space();
32
33
	public static MutableComponent space() {
34
		return Component.literal(" ");
35
	}
36
37
	public static MutableComponent days(final long value) {
38
		return Component.translatable("gui.days", value);
39
	}
40
41
	public static MutableComponent hours(final long value) {
42
		return Component.translatable("gui.hours", value);
43
	}
44
45
	public static MutableComponent minutes(final long value) {
46
		return Component.translatable("gui.minutes", value);
47
	}
48
49
	public static Component optionStatus(final boolean value) {
50
		return value ? OPTION_ON : OPTION_OFF;
51
	}
52
53
	public static Component disconnectButtonLabel(final boolean isLocalServer) {
54
		return isLocalServer ? GUI_RETURN_TO_MENU : GUI_DISCONNECT;
55
	}
56
57
	public static MutableComponent optionStatus(final Component name, final boolean value) {
58
		return Component.translatable(value ? "options.on.composed" : "options.off.composed", name);
59
	}
60
61
	public static MutableComponent optionNameValue(final Component name, final Component value) {
62
		return Component.translatable("options.generic_value", name, value);
63
	}
64
65
	public static MutableComponent joinForNarration(final Component... components) {
66
		MutableComponent result = Component.empty();
67
68
		for (int i = 0; i < components.length; i++) {
69
			result.append(components[i]);
70
			if (i != components.length - 1) {
71
				result.append(NARRATION_SEPARATOR);
72
			}
73
		}
74
75
		return result;
76
	}
77
78
	public static Component joinLines(final Component... lines) {
79
		return joinLines(Arrays.asList(lines));
80
	}
81
82
	public static Component joinLines(final Collection<? extends Component> lines) {
83
		return ComponentUtils.formatList(lines, NEW_LINE);
84
	}
85
}
86

Decompiled Minecraft 26.3 source of CommonComponents (net/minecraft/network/chat/CommonComponents.java) with Mojang official mappings, stored verbatim on the site.