/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.Codec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.advancements.criterion; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import java.util.Optional; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.advancements.Criterion; import net.minecraft.advancements.criterion.ContextAwarePredicate; import net.minecraft.advancements.criterion.EntityPredicate; import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.advancements.criterion.SimpleCriterionTrigger; import net.minecraft.server.level.ServerPlayer; public class ConstructBeaconTrigger extends SimpleCriterionTrigger { @Override public Codec codec() { return TriggerInstance.CODEC; } public void trigger(ServerPlayer player, int levels) { this.trigger(player, t -> t.matches(levels)); } public record TriggerInstance(Optional player, MinMaxBounds.Ints level) implements SimpleCriterionTrigger.SimpleInstance { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group((App)EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), (App)MinMaxBounds.Ints.CODEC.optionalFieldOf("level", (Object)MinMaxBounds.Ints.ANY).forGetter(TriggerInstance::level)).apply((Applicative)i, TriggerInstance::new)); public static Criterion constructedBeacon() { return CriteriaTriggers.CONSTRUCT_BEACON.createCriterion(new TriggerInstance(Optional.empty(), MinMaxBounds.Ints.ANY)); } public static Criterion constructedBeacon(MinMaxBounds.Ints level) { return CriteriaTriggers.CONSTRUCT_BEACON.createCriterion(new TriggerInstance(Optional.empty(), level)); } public boolean matches(int levels) { return this.level.matches(levels); } } }