FoodPredicate.java

net.minecraft.advancements.criterion.FoodPredicate

信息

  • 全限定名:net.minecraft.advancements.criterion.FoodPredicate
  • 类型:public record
  • 包:net.minecraft.advancements.criterion
  • 源码路径:src/main/java/net/minecraft/advancements/criterion/FoodPredicate.java
  • 起始行号:L7
  • 职责:

    TODO

字段/常量

  • ANY

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

      TODO

  • CODEC

    • 类型: Codec<FoodPredicate>
    • 修饰符: public static final
    • 源码定位: L9
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.advancements.criterion.FoodPredicate.Builder
    • 类型: class
    • 修饰符: public static
    • 源码定位: L21
    • 说明:

      TODO

构造器

方法

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

public boolean matches(FoodData food) @ L17

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

参数:

  • food: FoodData

说明:

TODO

代码

public record FoodPredicate(MinMaxBounds.Ints level, MinMaxBounds.Doubles saturation) {
    public static final FoodPredicate ANY = new FoodPredicate(MinMaxBounds.Ints.ANY, MinMaxBounds.Doubles.ANY);
    public static final Codec<FoodPredicate> CODEC = RecordCodecBuilder.create(
        i -> i.group(
                MinMaxBounds.Ints.CODEC.optionalFieldOf("level", MinMaxBounds.Ints.ANY).forGetter(FoodPredicate::level),
                MinMaxBounds.Doubles.CODEC.optionalFieldOf("saturation", MinMaxBounds.Doubles.ANY).forGetter(FoodPredicate::saturation)
            )
            .apply(i, FoodPredicate::new)
    );
 
    public boolean matches(FoodData food) {
        return !this.level.matches(food.getFoodLevel()) ? false : this.saturation.matches(food.getSaturationLevel());
    }
 
    public static class Builder {
        private MinMaxBounds.Ints level = MinMaxBounds.Ints.ANY;
        private MinMaxBounds.Doubles saturation = MinMaxBounds.Doubles.ANY;
 
        public FoodPredicate.Builder withLevel(MinMaxBounds.Ints level) {
            this.level = level;
            return this;
        }
 
        public FoodPredicate.Builder withSaturation(MinMaxBounds.Doubles saturation) {
            this.saturation = saturation;
            return this;
        }
 
        public static FoodPredicate.Builder food() {
            return new FoodPredicate.Builder();
        }
 
        public FoodPredicate build() {
            return new FoodPredicate(this.level, this.saturation);
        }
    }
}

引用的其他类