package ru.dbotthepony.mc.otm.datagen.items

import net.minecraft.world.item.DyeColor
import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.datagen.modLocation
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRegistry

fun addItemModels(provider: MatteryItemModelProvider) {
	provider.block(MItems.ANDROID_STATION, "android_station_working")
	provider.block(MItems.BATTERY_BANK)
	provider.block(MItems.MATTER_CAPACITOR_BANK)
	provider.block(MItems.PATTERN_STORAGE)

	provider.exec {
		provider
			.withExistingParent(MItems.BLACK_HOLE.registryName!!.path, MatteryItemModelProvider.GENERATED)
			.texture("layer0", modLocation("item/" + MItems.BLACK_HOLE.registryName!!.path))
			.renderType("translucent")
	}

	provider.block(MItems.CARBON_FIBRE_BLOCK)
	provider.block(MItems.METAL_JUNK)
	provider.block(MItems.METAL_MESH)
	provider.generatedTranslucent(MItems.TRITANIUM_BARS, modLocation("block/decorative/tritanium_bars"))
	provider.block(MItems.DEEPSLATE_TRITANIUM_ORE)
	provider.block(MItems.TRITANIUM_ORE)
	provider.block(MItems.TRITANIUM_STRIPED_BLOCK)
	provider.block(MItems.TRITANIUM_RAW_BLOCK)
	provider.block(MItems.TRITANIUM_INGOT_BLOCK)
	provider.block(MItems.ITEM_MONITOR)
	provider.block(MItems.PHANTOM_ATTRACTOR)
	provider.block(MItems.HOLO_SIGN)
	provider.generated(MItems.FLUID_CAPSULE)
	provider.block(MItems.FLUID_TANK)

	MRegistry.VENT.allItems.values.forEach(provider::block)
	MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block)
	MRegistry.TRITANIUM_BLOCK.allItems.values.forEach(provider::block)
	MRegistry.INDUSTRIAL_GLASS.allItems.values.forEach(provider::block)

	for (block in MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) {
		provider.block(block)
	}

	for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allItems) {
		provider.generatedTranslucent(glass, modLocation("block/decorative/${MRegistry.INDUSTRIAL_GLASS.allItems[color]!!.registryName!!.path}"))
	}

	provider.blocks(MRegistry.DECORATIVE_CRATE.allItems.values)

	provider.components(MItems.DATAGEN_COMPONENTS)

	provider.generated(MItems.PILL_ANDROID)
	provider.generated(MItems.PILL_HUMANE)
	provider.generated(MItems.PILL_OBLIVION)
	provider.generated(MItems.PILL_HEAL)
	provider.generated(MItems.NUTRIENT_PASTE)

	provider.generated(MItems.ESSENCE_DRIVE)
	provider.generated(MItems.ESSENCE_CAPSULE)
	provider.generated(MItems.ESSENCE_SERVO)

	for (item in MItems.ExopackUpgrades.INVENTORY_UPGRADES) {
		provider.generated(item, modLocation("item/exosuit_inventory_upgrade"))
	}

	for (item in listOf(
		MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE,
		MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG,
		MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL,
		MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER,
		MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON,
	)) {
		provider.generated(item, modLocation("item/exosuit_inventory_upgrade"))
	}

	provider.generated(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE)
	provider.generated(MItems.ExopackUpgrades.CRAFTING_UPGRADE)
	provider.generated(MItems.ExopackUpgrades.SMELTING_UPGRADE)

	provider.component(MItems.TRITANIUM_DUST)
	provider.component(MItems.TRITANIUM_INGOT)
	provider.component(MItems.TRITANIUM_NUGGET)
	provider.resource(MItems.TRITANIUM_ORE_CLUMP)

	provider.generated(MItems.EXOPACK_PROBE)

	provider.handheld(MItems.TRITANIUM_TOOLS)
	provider.generated(MItems.TRITANIUM_ARMOR)
	provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR)

	provider.generatedTiered(MItems.BATTERIES, "battery_tier")
	provider.generated(MItems.BATTERY_CREATIVE)
	provider.generated(MItems.PROCEDURAL_BATTERY, modLocation("item/battery_procedural"))

	provider.generated(MItems.MATTER_CAPACITOR_BASIC, modLocation("item/matter_capacitor_tier1"))
	provider.generated(MItems.MATTER_CAPACITOR_NORMAL, modLocation("item/matter_capacitor_tier2"))
	provider.generated(MItems.MATTER_CAPACITOR_DENSE, modLocation("item/matter_capacitor_tier3"))
	provider.generated(MItems.MATTER_CAPACITOR_CREATIVE)

	provider.generated(MItems.CreativeUpgrades.SPEED, modLocation("item/upgrade_speed"))

	provider.generated(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, modLocation("item/upgrade_energy"))
	provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, modLocation("item/upgrade_energy"))
	provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, modLocation("item/upgrade_energy"))
	provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, modLocation("item/upgrade_energy"))

	provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE, modLocation("item/upgrade_capacity"))
	provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, modLocation("item/upgrade_capacity"))
	provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, modLocation("item/upgrade_capacity"))

	provider.generated(MItems.CreativeUpgrades.FAILSAFE, modLocation("item/upgrade_failure"))
	provider.generated(MItems.CreativeUpgrades.FAILURE, modLocation("item/upgrade_failure"))

	provider.generated(MItems.CreativeUpgrades.PROCESSING_ITEMS, modLocation("item/upgrade_processing"))

	provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE, modLocation("item/upgrade_matter"))
	provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, modLocation("item/upgrade_matter"))
	provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, modLocation("item/upgrade_matter"))


	provider.generated(MItems.QUANTUM_BATTERY)
	provider.generated(MItems.QUANTUM_CAPACITOR)
	provider.generated(MItems.QUANTUM_BATTERY_CREATIVE)

	provider.generated(MItems.PATTERN_DRIVE_CREATIVE)
	provider.generated(MItems.PATTERN_DRIVE_CREATIVE2)

	provider.generated(MItems.MATTER_DUST)

	provider.generated(MItems.TRITANIUM_DOOR.values)

	provider.block(MItems.TRITANIUM_TRAPDOOR[null]!!, "tritanium_trapdoor_bottom")


	for (color in DyeColor.values())
		provider.block(MItems.TRITANIUM_TRAPDOOR[color]!!, "tritanium_trapdoor_${color.name.lowercase()}_bottom")

	for (item in MRegistry.CARGO_CRATES.allItems.values) {
		provider.block(item, "${item.registryName!!.path}_closed")
	}

	provider.block(MItems.CHEMICAL_GENERATOR, "chemical_generator_working")
	provider.block(MItems.ENERGY_COUNTER, "energy_counter_down")
	provider.block(MItems.MATTER_BOTTLER, "matter_bottler_working")
	provider.block(MItems.MATTER_CABLE, "matter_cable_core")
	provider.block(MItems.MATTER_DECOMPOSER, "matter_decomposer_working")
	provider.block(MItems.ENERGY_SERVO, "energy_servo")
	provider.block(MItems.ESSENCE_STORAGE, "essence_storage")
	provider.block(MItems.MATTER_RECONSTRUCTOR, "matter_reconstructor")
	provider.block(MItems.POWERED_BLAST_FURNACE, "powered_blast_furnace_working")
	provider.block(MItems.POWERED_FURNACE, "powered_furnace_working")

	provider.block(MItems.PLATE_PRESS, "plate_press_idle")
	provider.block(MItems.TWIN_PLATE_PRESS, "twin_plate_press_idle")
	provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier")
	provider.block(MItems.MATTER_RECYCLER, "matter_recycler_working")
	provider.block(MItems.COBBLESTONE_GENERATOR, "cobblestone_generator")

	provider.block(MItems.STORAGE_BUS)
	provider.block(MItems.STORAGE_IMPORTER)
	provider.block(MItems.STORAGE_EXPORTER)

	for (item in MItems.TRITANIUM_ANVIL) {
		provider.block(item)
	}

	for ((color, item) in MItems.CARGO_CRATE_MINECARTS) {
		provider.generated(item)
	}
}
