GuiMessage .java

net.minecraft.client.multiplayer.chat.GuiMessage (record): members: addedTime, content, signature, source, tag, MESSAGE_TAG_MARGIN_LEFT, splitLines, Line.

net.minecraft.client.multiplayer.chatrecord40 linesclient1.3 KB

API Surface (5)

record GuiMessage(int addedTime, Component content, @Nullable MessageSignature signature, GuiMessageSource source, @Nullable GuiMessageTag tag)
List<FormattedCharSequence> splitLines(final Font font, int maxWidth)
record Line(GuiMessage parent, FormattedCharSequence content, boolean endOfEntry)
int getTagIconLeft(final Font font)
int addedTime()

Fields & Constants (1)

MESSAGE_TAG_MARGIN_LEFT

Full Source

GuiMessage.java40 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.multiplayer.chat;
2
3
import java.util.List;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.gui.Font;
7
import net.minecraft.client.gui.components.ComponentRenderUtils;
8
import net.minecraft.network.chat.Component;
9
import net.minecraft.network.chat.MessageSignature;
10
import net.minecraft.util.FormattedCharSequence;
11
import org.jspecify.annotations.Nullable;
12
13
@Environment(EnvType.CLIENT)
14
public record GuiMessage(int addedTime, Component content, @Nullable MessageSignature signature, GuiMessageSource source, @Nullable GuiMessageTag tag) {
15
	private static final int MESSAGE_TAG_MARGIN_LEFT = 4;
16
17
	public List<FormattedCharSequence> splitLines(final Font font, int maxWidth) {
18
		if (this.tag != null && this.tag.icon() != null) {
19
			maxWidth -= this.tag.icon().width + 4 + 2;
20
		}
21
22
		return ComponentRenderUtils.wrapComponents(this.content, maxWidth, font);
23
	}
24
25
	@Environment(EnvType.CLIENT)
26
	public record Line(GuiMessage parent, FormattedCharSequence content, boolean endOfEntry) {
27
		public int getTagIconLeft(final Font font) {
28
			return font.width(this.content) + 4;
29
		}
30
31
		public @Nullable GuiMessageTag tag() {
32
			return this.parent.tag;
33
		}
34
35
		public int addedTime() {
36
			return this.parent.addedTime;
37
		}
38
	}
39
}
40

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