NbtPredicate.java
net.minecraft.advancements.criterion.NbtPredicate
信息
- 全限定名:net.minecraft.advancements.criterion.NbtPredicate
- 类型:public record
- 包:net.minecraft.advancements.criterion
- 源码路径:src/main/java/net/minecraft/advancements/criterion/NbtPredicate.java
- 起始行号:L23
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
CODEC- 类型:
Codec<NbtPredicate> - 修饰符:
public static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
STREAM_CODEC- 类型:
StreamCodec<ByteBuf,NbtPredicate> - 修饰符:
public static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
SELECTED_ITEM_TAG- 类型:
String - 修饰符:
public static final - 源码定位:
L27 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public boolean matches(DataComponentGetter components) @ L29
- 方法名:matches
- 源码定位:L29
- 返回类型:boolean
- 修饰符:public
参数:
- components: DataComponentGetter
说明:
TODO
public boolean matches(Entity entity) @ L34
- 方法名:matches
- 源码定位:L34
- 返回类型:boolean
- 修饰符:public
参数:
- entity: Entity
说明:
TODO
public boolean matches(Tag tag) @ L38
- 方法名:matches
- 源码定位:L38
- 返回类型:boolean
- 修饰符:public
参数:
- tag: Tag
说明:
TODO
public static CompoundTag getEntityTagToCompare(Entity entity) @ L42
- 方法名:getEntityTagToCompare
- 源码定位:L42
- 返回类型:CompoundTag
- 修饰符:public static
参数:
- entity: Entity
说明:
TODO
代码
public record NbtPredicate(CompoundTag tag) {
private static final Logger LOGGER = LogUtils.getLogger();
public static final Codec<NbtPredicate> CODEC = TagParser.LENIENT_CODEC.xmap(NbtPredicate::new, NbtPredicate::tag);
public static final StreamCodec<ByteBuf, NbtPredicate> STREAM_CODEC = ByteBufCodecs.COMPOUND_TAG.map(NbtPredicate::new, NbtPredicate::tag);
public static final String SELECTED_ITEM_TAG = "SelectedItem";
public boolean matches(DataComponentGetter components) {
CustomData data = components.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY);
return data.matchedBy(this.tag);
}
public boolean matches(Entity entity) {
return this.matches(getEntityTagToCompare(entity));
}
public boolean matches(@Nullable Tag tag) {
return tag != null && NbtUtils.compareNbt(this.tag, tag, true);
}
public static CompoundTag getEntityTagToCompare(Entity entity) {
CompoundTag var7;
try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(entity.problemPath(), LOGGER)) {
TagValueOutput output = TagValueOutput.createWithContext(reporter, entity.registryAccess());
entity.saveWithoutId(output);
if (entity instanceof Player player) {
ItemStack selected = player.getInventory().getSelectedItem();
if (!selected.isEmpty()) {
output.store("SelectedItem", ItemStack.CODEC, selected);
}
}
var7 = output.buildResult();
}
return var7;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
NbtUtils.compareNbt()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用/构造调用 - 关联成员:
ProblemReporter.ScopedCollector(), ScopedCollector()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
TagValueOutput.createWithContext()
- 引用位置: