package ru.dbotthepony.mc.otm.datagen.loot

import net.minecraft.util.valueproviders.UniformInt
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets
import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.data.world.UniformDecimal
import ru.dbotthepony.mc.otm.datagen.modLootTable
import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem
import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem
import ru.dbotthepony.mc.otm.item.matter.MatterDustItem
import ru.dbotthepony.mc.otm.registry.game.MItems

fun addVaultLoot(lootTables: LootTables) {
	lootTables.builder(LootContextParamSets.VAULT, modLootTable("trials/matter_dust")) {
		lootPool { item(MItems.MATTER_DUST) {
			chanceCondition(0.2)
			setWeight(4)
			apply(MatterDustItem.Randomizer(UniformDecimal(Decimal(100), Decimal(2_500))))
		} }
	}

	lootTables.builder(LootContextParamSets.VAULT, modLootTable("trials/pill")) {
		lootPool { item(MItems.PILL_ANDROID) {
			chanceCondition(0.1)
			setWeight(1)
		} }
		lootPool { item(MItems.PILL_HEAL) {
			chanceCondition(0.5)
			setWeight(2)
			setCount(2, 5)
		} }
	}

	lootTables.builder(LootContextParamSets.VAULT, modLootTable("trials/exosuit")) {
		lootPool { item(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) {
			chanceCondition(0.2)
			setWeight(2)

			apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(1, 9), UniformInt.of(0, 3)))
		} }

		lootPool { item(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) {
			chanceCondition(0.1)
			setWeight(1)

			apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18), UniformInt.of(0, 3)))
		} }
	}

	lootTables.builder(LootContextParamSets.VAULT, modLootTable("trials/battery")) {
		lootPool { item(MItems.PROCEDURAL_BATTERY) {
			chanceCondition(0.05)
			setWeight(1)

			apply(
				ProceduralBatteryItem.Randomizer(
					maxBatteryLevel = UniformDecimal(Decimal(10_000_000), Decimal(50_000_000)),
					batteryLevel = UniformDecimal(Decimal(0), Decimal(25_000_000)),
					maxInput = UniformDecimal(Decimal(1_000), Decimal(5_000)),
				))
		} }
	}

	lootTables.builder(LootContextParamSets.VAULT, modLootTable("trials/zpm_battery")) {
		lootPool { item(MItems.ZPM_BATTERY) {
			chanceCondition(0.001)
			setWeight(1)
		} }
	}
}
