DataComponentMatchers.java
net.minecraft.advancements.criterion.DataComponentMatchers
信息
- 全限定名:net.minecraft.advancements.criterion.DataComponentMatchers
- 类型:public record
- 包:net.minecraft.advancements.criterion
- 源码路径:src/main/java/net/minecraft/advancements/criterion/DataComponentMatchers.java
- 起始行号:L15
- 实现:Predicate
- 职责:
TODO
字段/常量
-
ANY- 类型:
DataComponentMatchers - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
CODEC- 类型:
MapCodec<DataComponentMatchers> - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
STREAM_CODEC- 类型:
StreamCodec<RegistryFriendlyByteBuf,DataComponentMatchers> - 修饰符:
public static final - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.advancements.criterion.DataComponentMatchers.Builder- 类型:
class - 修饰符:
public static - 源码定位:
L51 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public boolean test(DataComponentGetter values) @ L33
- 方法名:test
- 源码定位:L33
- 返回类型:boolean
- 修饰符:public
参数:
- values: DataComponentGetter
说明:
TODO
public boolean isEmpty() @ L47
- 方法名:isEmpty
- 源码定位:L47
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public record DataComponentMatchers(DataComponentExactPredicate exact, Map<DataComponentPredicate.Type<?>, DataComponentPredicate> partial)
implements Predicate<DataComponentGetter> {
public static final DataComponentMatchers ANY = new DataComponentMatchers(DataComponentExactPredicate.EMPTY, Map.of());
public static final MapCodec<DataComponentMatchers> CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(
DataComponentExactPredicate.CODEC.optionalFieldOf("components", DataComponentExactPredicate.EMPTY).forGetter(DataComponentMatchers::exact),
DataComponentPredicate.CODEC.optionalFieldOf("predicates", Map.of()).forGetter(DataComponentMatchers::partial)
)
.apply(i, DataComponentMatchers::new)
);
public static final StreamCodec<RegistryFriendlyByteBuf, DataComponentMatchers> STREAM_CODEC = StreamCodec.composite(
DataComponentExactPredicate.STREAM_CODEC,
DataComponentMatchers::exact,
DataComponentPredicate.STREAM_CODEC,
DataComponentMatchers::partial,
DataComponentMatchers::new
);
public boolean test(DataComponentGetter values) {
if (!this.exact.test(values)) {
return false;
} else {
for (DataComponentPredicate predicate : this.partial.values()) {
if (!predicate.matches(values)) {
return false;
}
}
return true;
}
}
public boolean isEmpty() {
return this.exact.isEmpty() && this.partial.isEmpty();
}
public static class Builder {
private DataComponentExactPredicate exact = DataComponentExactPredicate.EMPTY;
private final ImmutableMap.Builder<DataComponentPredicate.Type<?>, DataComponentPredicate> partial = ImmutableMap.builder();
private Builder() {
}
public static DataComponentMatchers.Builder components() {
return new DataComponentMatchers.Builder();
}
public <T extends DataComponentType<?>> DataComponentMatchers.Builder any(DataComponentType<?> type) {
DataComponentPredicate.AnyValueType predicateType = DataComponentPredicate.AnyValueType.create(type);
this.partial.put(predicateType, predicateType.predicate());
return this;
}
public <T extends DataComponentPredicate> DataComponentMatchers.Builder partial(DataComponentPredicate.Type<T> type, T predicate) {
this.partial.put(type, predicate);
return this;
}
public DataComponentMatchers.Builder exact(DataComponentExactPredicate exact) {
this.exact = exact;
return this;
}
public DataComponentMatchers build() {
return new DataComponentMatchers(this.exact, this.partial.buildOrThrow());
}
}
}引用的其他类
-
- 引用位置:
参数/实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
DataComponentPredicate.AnyValueType.create()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
StreamCodec.composite()
- 引用位置: