KeybindContents.java

net.minecraft.network.chat.contents.KeybindContents

信息

  • 全限定名:net.minecraft.network.chat.contents.KeybindContents
  • 类型:public class
  • 包:net.minecraft.network.chat.contents
  • 源码路径:src/main/java/net/minecraft/network/chat/contents/KeybindContents.java
  • 起始行号:L14
  • 实现:ComponentContents
  • 职责:

    TODO

字段/常量

  • MAP_CODEC

    • 类型: MapCodec<KeybindContents>
    • 修饰符: public static final
    • 源码定位: L15
    • 说明:

      TODO

  • name

    • 类型: String
    • 修饰符: private final
    • 源码定位: L18
    • 说明:

      TODO

  • nameResolver

    • 类型: Supplier<Component>
    • 修饰符: private
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

构造器

public KeybindContents(String name) @ L21

  • 构造器名:KeybindContents
  • 源码定位:L21
  • 修饰符:public

参数:

  • name: String

说明:

TODO

方法

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

private Component getNestedComponent() @ L25

  • 方法名:getNestedComponent
  • 源码定位:L25
  • 返回类型:Component
  • 修饰符:private

参数:

说明:

TODO

public <T> Optional<T> visit(FormattedText.ContentConsumer<T> output) @ L33

  • 方法名:visit
  • 源码定位:L33
  • 返回类型: Optional
  • 修饰符:public

参数:

  • output: FormattedText.ContentConsumer

说明:

TODO

public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> output, Style currentStyle) @ L38

  • 方法名:visit
  • 源码定位:L38
  • 返回类型: Optional
  • 修饰符:public

参数:

  • output: FormattedText.StyledContentConsumer
  • currentStyle: Style

说明:

TODO

public boolean equals(Object o) @ L43

  • 方法名:equals
  • 源码定位:L43
  • 返回类型:boolean
  • 修饰符:public

参数:

  • o: Object

说明:

TODO

public int hashCode() @ L48

  • 方法名:hashCode
  • 源码定位:L48
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public String toString() @ L53

  • 方法名:toString
  • 源码定位:L53
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public String getName() @ L58

  • 方法名:getName
  • 源码定位:L58
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public MapCodec<KeybindContents> codec() @ L62

  • 方法名:codec
  • 源码定位:L62
  • 返回类型:MapCodec
  • 修饰符:public

参数:

说明:

TODO

代码

public class KeybindContents implements ComponentContents {
    public static final MapCodec<KeybindContents> MAP_CODEC = RecordCodecBuilder.mapCodec(
        i -> i.group(Codec.STRING.fieldOf("keybind").forGetter(o -> o.name)).apply(i, KeybindContents::new)
    );
    private final String name;
    private @Nullable Supplier<Component> nameResolver;
 
    public KeybindContents(String name) {
        this.name = name;
    }
 
    private Component getNestedComponent() {
        if (this.nameResolver == null) {
            this.nameResolver = KeybindResolver.keyResolver.apply(this.name);
        }
 
        return this.nameResolver.get();
    }
 
    @Override
    public <T> Optional<T> visit(FormattedText.ContentConsumer<T> output) {
        return this.getNestedComponent().visit(output);
    }
 
    @Override
    public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> output, Style currentStyle) {
        return this.getNestedComponent().visit(output, currentStyle);
    }
 
    @Override
    public boolean equals(Object o) {
        return this == o ? true : o instanceof KeybindContents that && this.name.equals(that.name);
    }
 
    @Override
    public int hashCode() {
        return this.name.hashCode();
    }
 
    @Override
    public String toString() {
        return "keybind{" + this.name + "}";
    }
 
    public String getName() {
        return this.name;
    }
 
    @Override
    public MapCodec<KeybindContents> codec() {
        return MAP_CODEC;
    }
}

引用的其他类