PropertyValueList.java

net.minecraft.client.data.models.blockstates.PropertyValueList

信息

  • 全限定名:net.minecraft.client.data.models.blockstates.PropertyValueList
  • 类型:public record
  • 包:net.minecraft.client.data.models.blockstates
  • 源码路径:src/main/java/net/minecraft/client/data/models/blockstates/PropertyValueList.java
  • 起始行号:L13
  • 职责:

    TODO

字段/常量

  • EMPTY

    • 类型: PropertyValueList
    • 修饰符: public static final
    • 源码定位: L14
    • 说明:

      TODO

  • COMPARE_BY_NAME

    • 类型: Comparator<Property.Value<?>>
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public PropertyValueList extend(Property.Value<?> element) @ L17

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

参数:

  • element: Property.Value<?>

说明:

TODO

public PropertyValueList extend(PropertyValueList other) @ L21

  • 方法名:extend
  • 源码定位:L21
  • 返回类型:PropertyValueList
  • 修饰符:public

参数:

  • other: PropertyValueList

说明:

TODO

public static PropertyValueList of(Property.Value<?>... values) @ L25

  • 方法名:of
  • 源码定位:L25
  • 返回类型:PropertyValueList
  • 修饰符:public static

参数:

  • values: Property.Value<?>…

说明:

TODO

public String getKey() @ L29

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

参数:

说明:

TODO

public String toString() @ L33

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public record PropertyValueList(List<Property.Value<?>> values) {
    public static final PropertyValueList EMPTY = new PropertyValueList(List.of());
    private static final Comparator<Property.Value<?>> COMPARE_BY_NAME = Comparator.comparing(p -> p.property().getName());
 
    public PropertyValueList extend(Property.Value<?> element) {
        return new PropertyValueList(Util.copyAndAdd(this.values, element));
    }
 
    public PropertyValueList extend(PropertyValueList other) {
        return new PropertyValueList(ImmutableList.<Property.Value<?>>builder().addAll(this.values).addAll(other.values).build());
    }
 
    public static PropertyValueList of(Property.Value<?>... values) {
        return new PropertyValueList(List.of(values));
    }
 
    public String getKey() {
        return this.values.stream().sorted(COMPARE_BY_NAME).map(Property.Value::toString).collect(Collectors.joining(","));
    }
 
    @Override
    public String toString() {
        return this.getKey();
    }
}

引用的其他类

  • Util

    • 引用位置: 方法调用
    • 关联成员: Util.copyAndAdd()
  • Property

    • 引用位置: 参数/字段