26 lines
1.1 KiB
Java
26 lines
1.1 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.serialization.Codec
|
|
* com.mojang.serialization.MapCodec
|
|
*/
|
|
package net.minecraft.advancements;
|
|
|
|
import com.mojang.serialization.Codec;
|
|
import com.mojang.serialization.MapCodec;
|
|
import net.minecraft.advancements.CriteriaTriggers;
|
|
import net.minecraft.advancements.CriterionTrigger;
|
|
import net.minecraft.advancements.CriterionTriggerInstance;
|
|
import net.minecraft.util.ExtraCodecs;
|
|
|
|
public record Criterion<T extends CriterionTriggerInstance>(CriterionTrigger<T> trigger, T triggerInstance) {
|
|
private static final MapCodec<Criterion<?>> MAP_CODEC = ExtraCodecs.dispatchOptionalValue("trigger", "conditions", CriteriaTriggers.CODEC, Criterion::trigger, Criterion::criterionCodec);
|
|
public static final Codec<Criterion<?>> CODEC = MAP_CODEC.codec();
|
|
|
|
private static <T extends CriterionTriggerInstance> Codec<Criterion<T>> criterionCodec(CriterionTrigger<T> trigger) {
|
|
return trigger.codec().xmap(instance -> new Criterion<CriterionTriggerInstance>(trigger, (CriterionTriggerInstance)instance), Criterion::triggerInstance);
|
|
}
|
|
}
|
|
|