ComponentCollector.java

net.minecraft.client.ComponentCollector

信息

  • 全限定名:net.minecraft.client.ComponentCollector
  • 类型:public class
  • 包:net.minecraft.client
  • 源码路径:src/main/java/net/minecraft/client/ComponentCollector.java
  • 起始行号:L11
  • 职责:

    TODO

字段/常量

  • parts
    • 类型: List<FormattedText>
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public void append(FormattedText component) @ L14

  • 方法名:append
  • 源码定位:L14
  • 返回类型:void
  • 修饰符:public

参数:

  • component: FormattedText

说明:

TODO

public FormattedText getResult() @ L18

  • 方法名:getResult
  • 源码定位:L18
  • 返回类型:FormattedText
  • 修饰符:public

参数:

说明:

TODO

public FormattedText getResultOrEmpty() @ L26

  • 方法名:getResultOrEmpty
  • 源码定位:L26
  • 返回类型:FormattedText
  • 修饰符:public

参数:

说明:

TODO

public void reset() @ L31

  • 方法名:reset
  • 源码定位:L31
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ComponentCollector {
    private final List<FormattedText> parts = Lists.newArrayList();
 
    public void append(FormattedText component) {
        this.parts.add(component);
    }
 
    public @Nullable FormattedText getResult() {
        if (this.parts.isEmpty()) {
            return null;
        } else {
            return this.parts.size() == 1 ? this.parts.get(0) : FormattedText.composite(this.parts);
        }
    }
 
    public FormattedText getResultOrEmpty() {
        FormattedText result = this.getResult();
        return result != null ? result : FormattedText.EMPTY;
    }
 
    public void reset() {
        this.parts.clear();
    }
}

引用的其他类

  • FormattedText
    • 引用位置: 参数/字段/方法调用/返回值
    • 关联成员: FormattedText.composite()