GuiMessage.java

net.minecraft.client.multiplayer.chat.GuiMessage

信息

  • 全限定名:net.minecraft.client.multiplayer.chat.GuiMessage
  • 类型:public record
  • 包:net.minecraft.client.multiplayer.chat
  • 源码路径:src/main/java/net/minecraft/client/multiplayer/chat/GuiMessage.java
  • 起始行号:L14
  • 职责:

    TODO

字段/常量

  • MESSAGE_TAG_MARGIN_LEFT
    • 类型: int
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.multiplayer.chat.GuiMessage.Line
    • 类型: record
    • 修饰符: public
    • 源码定位: L26
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

public List<FormattedCharSequence> splitLines(Font font, int maxWidth) @ L17

  • 方法名:splitLines
  • 源码定位:L17
  • 返回类型:List
  • 修饰符:public

参数:

  • font: Font
  • maxWidth: int

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public record GuiMessage(int addedTime, Component content, @Nullable MessageSignature signature, GuiMessageSource source, @Nullable GuiMessageTag tag) {
    private static final int MESSAGE_TAG_MARGIN_LEFT = 4;
 
    public List<FormattedCharSequence> splitLines(Font font, int maxWidth) {
        if (this.tag != null && this.tag.icon() != null) {
            maxWidth -= this.tag.icon().width + 4 + 2;
        }
 
        return ComponentRenderUtils.wrapComponents(this.content, maxWidth, font);
    }
 
    @OnlyIn(Dist.CLIENT)
    public record Line(GuiMessage parent, FormattedCharSequence content, boolean endOfEntry) {
        public int getTagIconLeft(Font font) {
            return font.width(this.content) + 4;
        }
 
        public @Nullable GuiMessageTag tag() {
            return this.parent.tag;
        }
 
        public int addedTime() {
            return this.parent.addedTime;
        }
    }
}

引用的其他类