package ru.dbotthepony.mc.otm.triggers

import com.google.gson.JsonObject
import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance
import net.minecraft.advancements.critereon.ContextAwarePredicate
import net.minecraft.advancements.critereon.DeserializationContext
import net.minecraft.advancements.critereon.SimpleCriterionTrigger
import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerPlayer

class SingletonTrigger(val ID: ResourceLocation) : SimpleCriterionTrigger<AbstractCriterionTriggerInstance>() {
	override fun getId(): ResourceLocation {
		return ID
	}

	override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): AbstractCriterionTriggerInstance {
		return instance
	}

	fun trigger(player: ServerPlayer) {
		trigger(player) { true }
	}

	val instance = object : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) {}
}
