package ru.dbotthepony.mc.otm.triggers

import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.advancements.Criterion
import net.minecraft.advancements.critereon.ContextAwarePredicate
import net.minecraft.resources.ResourceLocation
import java.util.*

class SingletonTrigger(id: ResourceLocation) : MCriterionTrigger<SingletonTrigger.Instance>(id) {
	override val codec: Codec<Instance> = RecordCodecBuilder.create {
		it.group(playerPredicateCodec.forGetter(Instance::playerPredicate)).apply(it, ::Instance)
	}

	val empty = Instance()
	val criterion = Criterion(empty)

	inner class Instance(player: Optional<ContextAwarePredicate> = Optional.empty()) : AbstractInstance(player)
}
