BrewedPotionTrigger.java
net.minecraft.advancements.criterion.BrewedPotionTrigger
信息
- 全限定名:net.minecraft.advancements.criterion.BrewedPotionTrigger
- 类型:public class
- 包:net.minecraft.advancements.criterion
- 源码路径:src/main/java/net/minecraft/advancements/criterion/BrewedPotionTrigger.java
- 起始行号:L12
- 继承:SimpleCriterionTrigger<BrewedPotionTrigger.TriggerInstance>
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
net.minecraft.advancements.criterion.BrewedPotionTrigger.TriggerInstance- 类型:
record - 修饰符:
public - 源码定位:
L22 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public Codec<BrewedPotionTrigger.TriggerInstance> codec() @ L13
- 方法名:codec
- 源码定位:L13
- 返回类型:Codec<BrewedPotionTrigger.TriggerInstance>
- 修饰符:public
参数:
- 无
说明:
TODO
public void trigger(ServerPlayer player, Holder<Potion> potion) @ L18
- 方法名:trigger
- 源码定位:L18
- 返回类型:void
- 修饰符:public
参数:
- player: ServerPlayer
- potion: Holder
说明:
TODO
代码
public class BrewedPotionTrigger extends SimpleCriterionTrigger<BrewedPotionTrigger.TriggerInstance> {
@Override
public Codec<BrewedPotionTrigger.TriggerInstance> codec() {
return BrewedPotionTrigger.TriggerInstance.CODEC;
}
public void trigger(ServerPlayer player, Holder<Potion> potion) {
this.trigger(player, t -> t.matches(potion));
}
public record TriggerInstance(Optional<ContextAwarePredicate> player, Optional<Holder<Potion>> potion) implements SimpleCriterionTrigger.SimpleInstance {
public static final Codec<BrewedPotionTrigger.TriggerInstance> CODEC = RecordCodecBuilder.create(
i -> i.group(
EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(BrewedPotionTrigger.TriggerInstance::player),
Potion.CODEC.optionalFieldOf("potion").forGetter(BrewedPotionTrigger.TriggerInstance::potion)
)
.apply(i, BrewedPotionTrigger.TriggerInstance::new)
);
public static Criterion<BrewedPotionTrigger.TriggerInstance> brewedPotion() {
return CriteriaTriggers.BREWED_POTION.createCriterion(new BrewedPotionTrigger.TriggerInstance(Optional.empty(), Optional.empty()));
}
public boolean matches(Holder<Potion> potion) {
return !this.potion.isPresent() || this.potion.get().equals(potion);
}
}
}引用的其他类
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: