ConditionBuilder.java

net.minecraft.client.data.models.blockstates.ConditionBuilder

信息

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

    TODO

字段/常量

  • terms
    • 类型: Builder<String,KeyValueCondition.Terms>
    • 修饰符: private final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

private <T extends Comparable<T>> void putValue(Property<T> property, KeyValueCondition.Terms term) @ L17

  • 方法名:putValue
  • 源码定位:L17
  • 返回类型:<T extends Comparable> void
  • 修饰符:private

参数:

  • property: Property
  • term: KeyValueCondition.Terms

说明:

TODO

public final <T extends Comparable<T>> ConditionBuilder term(Property<T> property, T value) @ L21

  • 方法名:term
  • 源码定位:L21
  • 返回类型:<T extends Comparable> ConditionBuilder
  • 修饰符:public final

参数:

  • property: Property
  • value: T

说明:

TODO

public final <T extends Comparable<T>> ConditionBuilder term(Property<T> property, T value, T... values) @ L26

  • 方法名:term
  • 源码定位:L26
  • 返回类型:<T extends Comparable> ConditionBuilder
  • 修饰符:public final

参数:

  • property: Property
  • value: T
  • values: T…

说明:

TODO

public final <T extends Comparable<T>> ConditionBuilder negatedTerm(Property<T> property, T value) @ L38

  • 方法名:negatedTerm
  • 源码定位:L38
  • 返回类型:<T extends Comparable> ConditionBuilder
  • 修饰符:public final

参数:

  • property: Property
  • value: T

说明:

TODO

public Condition build() @ L43

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ConditionBuilder {
    private final Builder<String, KeyValueCondition.Terms> terms = ImmutableMap.builder();
 
    private <T extends Comparable<T>> void putValue(Property<T> property, KeyValueCondition.Terms term) {
        this.terms.put(property.getName(), term);
    }
 
    public final <T extends Comparable<T>> ConditionBuilder term(Property<T> property, T value) {
        this.putValue(property, new KeyValueCondition.Terms(List.of(new KeyValueCondition.Term(property.getName(value), false))));
        return this;
    }
 
    @SafeVarargs
    public final <T extends Comparable<T>> ConditionBuilder term(Property<T> property, T value, T... values) {
        List<KeyValueCondition.Term> terms = Stream.concat(Stream.of(value), Stream.of(values))
            .map(property::getName)
            .sorted()
            .distinct()
            .map(v -> new KeyValueCondition.Term(v, false))
            .toList();
        this.putValue(property, new KeyValueCondition.Terms(terms));
        return this;
    }
 
    public final <T extends Comparable<T>> ConditionBuilder negatedTerm(Property<T> property, T value) {
        this.putValue(property, new KeyValueCondition.Terms(List.of(new KeyValueCondition.Term(property.getName(value), true))));
        return this;
    }
 
    public Condition build() {
        return new KeyValueCondition(this.terms.buildOrThrow());
    }
}

引用的其他类

  • Condition

    • 引用位置: 返回值
  • KeyValueCondition

    • 引用位置: 参数/字段/方法调用/构造调用
    • 关联成员: KeyValueCondition(), KeyValueCondition.Term(), KeyValueCondition.Terms(), Term(), Terms()
  • Property

    • 引用位置: 参数