/* * 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.SimpleCriterionTrigger; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.storage.loot.LootTable; public class LootTableTrigger extends SimpleCriterionTrigger { @Override public Codec codec() { return TriggerInstance.CODEC; } @Override public void trigger(ServerPlayer player, ResourceKey lootTable) { this.trigger(player, (T t) -> t.matches(lootTable)); } public record TriggerInstance(Optional player, ResourceKey lootTable) implements SimpleCriterionTrigger.SimpleInstance { public static final Codec CODEC = RecordCodecBuilder.create(i -> i.group((App)EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), (App)LootTable.KEY_CODEC.fieldOf("loot_table").forGetter(TriggerInstance::lootTable)).apply((Applicative)i, TriggerInstance::new)); public static Criterion lootTableUsed(ResourceKey lootTable) { return CriteriaTriggers.GENERATE_LOOT.createCriterion(new TriggerInstance(Optional.empty(), lootTable)); } public boolean matches(ResourceKey lootTable) { return this.lootTable == lootTable; } } }