/* * 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.BlockPredicate; import net.minecraft.advancements.criterion.ContextAwarePredicate; import net.minecraft.advancements.criterion.EntityEquipmentPredicate; import net.minecraft.advancements.criterion.EntityPredicate; import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.advancements.criterion.LocationPredicate; import net.minecraft.advancements.criterion.SimpleCriterionTrigger; import net.minecraft.core.HolderGetter; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; public class PlayerTrigger extends SimpleCriterionTrigger { @Override public Codec codec() { return TriggerInstance.CODEC; } public void trigger(ServerPlayer player) { this.trigger(player, t -> true); } public record TriggerInstance(Optional player) implements SimpleCriterionTrigger.SimpleInstance { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group((App)EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player)).apply((Applicative)i, TriggerInstance::new)); public static Criterion located(LocationPredicate.Builder location) { return CriteriaTriggers.LOCATION.createCriterion(new TriggerInstance(Optional.of(EntityPredicate.wrap(EntityPredicate.Builder.entity().located(location))))); } public static Criterion located(EntityPredicate.Builder player) { return CriteriaTriggers.LOCATION.createCriterion(new TriggerInstance(Optional.of(EntityPredicate.wrap(player.build())))); } public static Criterion located(Optional player) { return CriteriaTriggers.LOCATION.createCriterion(new TriggerInstance(EntityPredicate.wrap(player))); } public static Criterion sleptInBed() { return CriteriaTriggers.SLEPT_IN_BED.createCriterion(new TriggerInstance(Optional.empty())); } public static Criterion raidWon() { return CriteriaTriggers.RAID_WIN.createCriterion(new TriggerInstance(Optional.empty())); } public static Criterion avoidVibration() { return CriteriaTriggers.AVOID_VIBRATION.createCriterion(new TriggerInstance(Optional.empty())); } public static Criterion tick() { return CriteriaTriggers.TICK.createCriterion(new TriggerInstance(Optional.empty())); } public static Criterion walkOnBlockWithEquipment(HolderGetter blocks, HolderGetter items, Block stepOnBlock, Item requiredEquipment) { return TriggerInstance.located(EntityPredicate.Builder.entity().equipment(EntityEquipmentPredicate.Builder.equipment().feet(ItemPredicate.Builder.item().of(items, requiredEquipment))).steppingOn(LocationPredicate.Builder.location().setBlock(BlockPredicate.Builder.block().of(blocks, stepOnBlock)))); } } }