45 lines
1.7 KiB
Java
45 lines
1.7 KiB
Java
/*
|
|
* 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.server.level.ServerPlayer;
|
|
|
|
public class StartRidingTrigger
|
|
extends SimpleCriterionTrigger<TriggerInstance> {
|
|
@Override
|
|
public Codec<TriggerInstance> codec() {
|
|
return TriggerInstance.CODEC;
|
|
}
|
|
|
|
public void trigger(ServerPlayer player) {
|
|
this.trigger(player, t -> true);
|
|
}
|
|
|
|
public record TriggerInstance(Optional<ContextAwarePredicate> player) implements SimpleCriterionTrigger.SimpleInstance
|
|
{
|
|
public static final Codec<TriggerInstance> CODEC = RecordCodecBuilder.create(i -> i.group((App)EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player)).apply((Applicative)i, TriggerInstance::new));
|
|
|
|
public static Criterion<TriggerInstance> playerStartsRiding(EntityPredicate.Builder player) {
|
|
return CriteriaTriggers.START_RIDING_TRIGGER.createCriterion(new TriggerInstance(Optional.of(EntityPredicate.wrap(player))));
|
|
}
|
|
}
|
|
}
|
|
|