package ru.dbotthepony.mc.otm.data.condition

import net.minecraft.world.level.storage.loot.LootContext
import net.minecraft.world.level.storage.loot.parameters.LootContextParams
import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.data.get
import ru.dbotthepony.mc.otm.registry.data.MLootItemConditions

object HasExoPackCondition : LootItemCondition, LootItemCondition.Builder {
	override fun test(t: LootContext): Boolean {
		t[LootContextParams.LAST_DAMAGE_PLAYER]?.matteryPlayer?.let {
			return it.hasExopack
		}

		return false
	}

	override fun getType(): LootItemConditionType {
		return MLootItemConditions.HAS_EXOPACK
	}

	override fun build(): LootItemCondition {
		return this
	}

	val INVERTED: LootItemCondition = InvertedLootItemCondition.invert(this).build()
}
