
package ru.dbotthepony.mc.otm.registry

import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.food.FoodProperties
import net.minecraft.world.item.*
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.level.Level
import net.minecraftforge.common.ForgeTier
import net.minecraftforge.common.TierSortingRegistry
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.UpgradeType
import ru.dbotthepony.mc.otm.config.ItemsConfig
import ru.dbotthepony.mc.otm.core.collect.SupplierList
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.item.*
import ru.dbotthepony.mc.otm.item.exopack.ExoPackProbeItem
import ru.dbotthepony.mc.otm.item.exopack.ExoPackSlotUpgradeItem
import ru.dbotthepony.mc.otm.item.matter.CreativePatternItem
import ru.dbotthepony.mc.otm.item.matter.MatterCapacitorItem
import ru.dbotthepony.mc.otm.item.matter.MatterDustItem
import ru.dbotthepony.mc.otm.item.matter.PatternStorageItem
import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem
import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem
import ru.dbotthepony.mc.otm.item.tool.MatteryAxeItem
import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem
import ru.dbotthepony.mc.otm.item.armor.SimpleTritaniumArmorItem
import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem
import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem
import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem
import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem

object MItems {
	private val DEFAULT_PROPERTIES = Item.Properties()
	private val registry: DeferredRegister<Item> = DeferredRegister.create(ForgeRegistries.ITEMS, OverdriveThatMatters.MOD_ID)

	internal fun register(bus: IEventBus) {
		registry.register(bus)
	}

	val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) }
	val ANDROID_CHARGER: BlockItem by registry.register(MNames.ANDROID_CHARGER) { BlockItem(MBlocks.ANDROID_CHARGER, DEFAULT_PROPERTIES) }
	val BATTERY_BANK: BlockItem by registry.register(MNames.BATTERY_BANK) { BlockItem(MBlocks.BATTERY_BANK, DEFAULT_PROPERTIES) }
	val MATTER_DECOMPOSER: BlockItem by registry.register(MNames.MATTER_DECOMPOSER) { BlockItem(MBlocks.MATTER_DECOMPOSER, DEFAULT_PROPERTIES) }
	val MATTER_CAPACITOR_BANK: BlockItem by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockItem(MBlocks.MATTER_CAPACITOR_BANK, DEFAULT_PROPERTIES) }
	val MATTER_CABLE: BlockItem by registry.register(MNames.MATTER_CABLE) { BlockItem(MBlocks.MATTER_CABLE, DEFAULT_PROPERTIES) }
	val PATTERN_STORAGE: BlockItem by registry.register(MNames.PATTERN_STORAGE) { BlockItem(MBlocks.PATTERN_STORAGE, DEFAULT_PROPERTIES) }
	val MATTER_SCANNER: BlockItem by registry.register(MNames.MATTER_SCANNER) { BlockItem(MBlocks.MATTER_SCANNER, DEFAULT_PROPERTIES) }
	val MATTER_PANEL: BlockItem by registry.register(MNames.MATTER_PANEL) { BlockItem(MBlocks.MATTER_PANEL, DEFAULT_PROPERTIES) }
	val MATTER_REPLICATOR: BlockItem by registry.register(MNames.MATTER_REPLICATOR) { BlockItem(MBlocks.MATTER_REPLICATOR, DEFAULT_PROPERTIES) }
	val MATTER_BOTTLER: BlockItem by registry.register(MNames.MATTER_BOTTLER) { BlockItem(MBlocks.MATTER_BOTTLER, DEFAULT_PROPERTIES) }

	val TRITANIUM_ORE: BlockItem by registry.register(MNames.TRITANIUM_ORE) { BlockItem(MBlocks.TRITANIUM_ORE, DEFAULT_PROPERTIES) }
	val DEEPSLATE_TRITANIUM_ORE: BlockItem by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { BlockItem(MBlocks.DEEPSLATE_TRITANIUM_ORE, DEFAULT_PROPERTIES) }
	val TRITANIUM_RAW_BLOCK: BlockItem by registry.register(MNames.TRITANIUM_RAW_BLOCK) { BlockItem(MBlocks.TRITANIUM_RAW_BLOCK, DEFAULT_PROPERTIES) }
	val ENERGY_COUNTER: BlockItem by registry.register(MNames.ENERGY_COUNTER) { BlockItem(MBlocks.ENERGY_COUNTER, DEFAULT_PROPERTIES) }
	val CHEMICAL_GENERATOR: BlockItem by registry.register(MNames.CHEMICAL_GENERATOR) { BlockItem(MBlocks.CHEMICAL_GENERATOR, DEFAULT_PROPERTIES) }
	val PLATE_PRESS: BlockItem by registry.register(MNames.PLATE_PRESS) { BlockItem(MBlocks.PLATE_PRESS, DEFAULT_PROPERTIES) }
	val TWIN_PLATE_PRESS: BlockItem by registry.register(MNames.TWIN_PLATE_PRESS) { BlockItem(MBlocks.TWIN_PLATE_PRESS, DEFAULT_PROPERTIES) }
	val MATTER_RECYCLER: BlockItem by registry.register(MNames.MATTER_RECYCLER) { BlockItem(MBlocks.MATTER_RECYCLER, DEFAULT_PROPERTIES) }

	val POWERED_FURNACE: BlockItem by registry.register(MNames.POWERED_FURNACE) { BlockItem(MBlocks.POWERED_FURNACE, DEFAULT_PROPERTIES) }
	val POWERED_BLAST_FURNACE: BlockItem by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockItem(MBlocks.POWERED_BLAST_FURNACE, DEFAULT_PROPERTIES) }
	val POWERED_SMOKER: BlockItem by registry.register(MNames.POWERED_SMOKER) { BlockItem(MBlocks.POWERED_SMOKER, DEFAULT_PROPERTIES) }

	val STORAGE_BUS: BlockItem by registry.register(MNames.STORAGE_BUS) { BlockItem(MBlocks.STORAGE_BUS, DEFAULT_PROPERTIES) }
	val STORAGE_IMPORTER: BlockItem by registry.register(MNames.STORAGE_IMPORTER) { BlockItem(MBlocks.STORAGE_IMPORTER, DEFAULT_PROPERTIES) }
	val STORAGE_EXPORTER: BlockItem by registry.register(MNames.STORAGE_EXPORTER) { BlockItem(MBlocks.STORAGE_EXPORTER, DEFAULT_PROPERTIES) }
	val DRIVE_VIEWER: BlockItem by registry.register(MNames.DRIVE_VIEWER) { BlockItem(MBlocks.DRIVE_VIEWER, DEFAULT_PROPERTIES) }
	val DRIVE_RACK: BlockItem by registry.register(MNames.DRIVE_RACK) { BlockItem(MBlocks.DRIVE_RACK, DEFAULT_PROPERTIES) }
	val ITEM_MONITOR: BlockItem by registry.register(MNames.ITEM_MONITOR) { BlockItem(MBlocks.ITEM_MONITOR, DEFAULT_PROPERTIES) }
	val STORAGE_CABLE: BlockItem by registry.register(MNames.STORAGE_CABLE) { BlockItem(MBlocks.STORAGE_CABLE, DEFAULT_PROPERTIES) }
	val STORAGE_POWER_SUPPLIER: BlockItem by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockItem(MBlocks.STORAGE_POWER_SUPPLIER, DEFAULT_PROPERTIES) }

	val GRAVITATION_STABILIZER: BlockItem by registry.register(MNames.GRAVITATION_STABILIZER) {
		object : BlockItem(MBlocks.GRAVITATION_STABILIZER, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)

				p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc").withStyle(ChatFormatting.GRAY))
				p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.DARK_GRAY))
				p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc2").withStyle(ChatFormatting.DARK_GRAY))
				p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc3").withStyle(ChatFormatting.DARK_GRAY))
			}
		}
	}

	val PHANTOM_ATTRACTOR: DoubleHighBlockItem by registry.register(MNames.PHANTOM_ATTRACTOR) {
		object : DoubleHighBlockItem(MBlocks.PHANTOM_ATTRACTOR, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)

				p_40574_.add(TranslatableComponent("${MBlocks.PHANTOM_ATTRACTOR.descriptionId}.desc").withStyle(ChatFormatting.GRAY))
				p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.DARK_GRAY))
			}
		}
	}

	val ENERGY_SERVO: BlockItem by registry.register(MNames.ENERGY_SERVO) {
		object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)

				p_40574_.add(TranslatableComponent("${MBlocks.ENERGY_SERVO.descriptionId}.desc").withStyle(ChatFormatting.GRAY))
			}
		}
	}

	val COBBLESTONE_GENERATOR: BlockItem by registry.register(MNames.COBBLESTONE_GENERATOR) {
		object : BlockItem(MBlocks.COBBLESTONE_GENERATOR, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)
				p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.GRAY))
			}
		}
	}

	val ESSENCE_STORAGE: BlockItem by registry.register(MNames.ESSENCE_STORAGE) {
		object : BlockItem(MBlocks.ESSENCE_STORAGE, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)
				p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY))
			}
		}
	}

	val MATTER_RECONSTRUCTOR: BlockItem by registry.register(MNames.MATTER_RECONSTRUCTOR) {
		object : BlockItem(MBlocks.MATTER_RECONSTRUCTOR, DEFAULT_PROPERTIES) {
			override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
				super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)
				p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY))
			}
		}
	}

	val MACHINES = SupplierList(
		::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE,
		::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR,
		::MATTER_RECYCLER, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::POWERED_FURNACE, ::POWERED_BLAST_FURNACE,
		::POWERED_SMOKER,
		// ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER,
		// ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER,
		::ENERGY_SERVO,
		::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE,
		::MATTER_RECONSTRUCTOR
	)

	val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) }
	val DEBUG_SPHERE_POINTS: Item by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockItem(MBlocks.DEBUG_SPHERE_POINTS, Item.Properties().stacksTo(64)) }

	val TRITANIUM_ANVIL: List<BlockItem>

	init {
		val props = ArrayList<() -> BlockItem>()

		for (i in MBlocks.TRITANIUM_ANVIL.indices) {
			props.add(registry.register(MNames.TRITANIUM_ANVIL + i) { BlockItem(MBlocks.TRITANIUM_ANVIL[i], DEFAULT_PROPERTIES) }::get)
		}

		TRITANIUM_ANVIL = SupplierList(props)
	}

	object CreativeUpgrades {
		val SPEED: SimpleUpgrade by registry.register("creative_speed_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.SPEED.set(), speedBonus = 1.0) }
		val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("creative_energy_consumption_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_CONSUMPTION.set(), energyConsumed = Decimal.MINUS_ONE) }
		val ENERGY_STORAGE: SimpleUpgrade by registry.register("creative_energy_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE) }
		val ENERGY_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_energy_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.LONG_MAX_VALUE) }
		val ENERGY_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.INT_MAX_VALUE) }
		val ENERGY_THROUGHPUT: SimpleUpgrade by registry.register("creative_energy_throughput_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughput = Decimal.ONE) }
		val ENERGY_THROUGHPUT_FLAT: SimpleUpgrade by registry.register("creative_energy_throughput_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.LONG_MAX_VALUE) }
		val ENERGY_THROUGHPUT_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_throughput_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.INT_MAX_VALUE) }
		val FAILSAFE: SimpleUpgrade by registry.register("creative_failsafe_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 0.0) }
		val FAILURE: SimpleUpgrade by registry.register("creative_failure_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 2.0) }
		val PROCESSING_ITEMS: SimpleUpgrade by registry.register("creative_processing_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.PROCESSING.set(), processingItems = 1) }

		val MATTER_STORAGE: SimpleUpgrade by registry.register("creative_matter_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE) }
		val MATTER_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_matter_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.LONG_MAX_VALUE) }
		val MATTER_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_matter_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.INT_MAX_VALUE) }

		val LIST = SupplierList(
			::SPEED,
			::ENERGY_CONSUMPTION,
			::ENERGY_STORAGE,
			::ENERGY_STORAGE_FLAT,
			::ENERGY_STORAGE_FLAT_SMALL,
			::ENERGY_THROUGHPUT,
			::ENERGY_THROUGHPUT_FLAT,
			::ENERGY_THROUGHPUT_FLAT_SMALL,
			::FAILSAFE,
			::FAILURE,
			::PROCESSING_ITEMS,
			::MATTER_STORAGE,
			::MATTER_STORAGE_FLAT,
			::MATTER_STORAGE_FLAT_SMALL,
		)
	}

	init {
		CreativeUpgrades
	}

	val MATTER_DUST: Item by registry.register(MNames.MATTER_DUST) { MatterDustItem() }

	val TRITANIUM_ORE_CLUMP: Item by registry.register(MNames.TRITANIUM_ORE_CLUMP) { Item(DEFAULT_PROPERTIES) }
	val TRITANIUM_DUST: Item by registry.register(MNames.TRITANIUM_DUST) { Item(DEFAULT_PROPERTIES) }
	val TRITANIUM_NUGGET: Item by registry.register(MNames.TRITANIUM_NUGGET) { Item(DEFAULT_PROPERTIES) }
	val TRITANIUM_INGOT: Item by registry.register(MNames.TRITANIUM_INGOT) { Item(DEFAULT_PROPERTIES) }
	val TRITANIUM_INGOT_BLOCK: BlockItem by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { BlockItem(MBlocks.TRITANIUM_INGOT_BLOCK, DEFAULT_PROPERTIES) }
	val TRITANIUM_BARS: BlockItem by registry.register(MNames.TRITANIUM_BARS) { BlockItem(MBlocks.TRITANIUM_BARS, DEFAULT_PROPERTIES) }

	val ESSENCE_SERVO: EssenceServoItem by registry.register("essence_servo") { EssenceServoItem() }
	val ESSENCE_CAPSULE: EssenceCapsuleItem by registry.register("essence_capsule") { EssenceCapsuleItem() }
	val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem() }

	val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) }
	val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Item.Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) }

	val TRITANIUM_COMPONENT: ForgeTier = ForgeTier(
		Tiers.IRON.level,
		3072,
		Tiers.IRON.speed * 1.1f,
		3.5f,
		16,
		MBlockTags.REQUIRES_TRITANIUM_TOOL
	) { Ingredient.of(TRITANIUM_INGOT) }

	val TRITANIUM_COMPONENT_NAME = ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium")

	init {
		TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf(Tiers.DIAMOND))
	}

	private val TOOLS_PROPRTIES = Item.Properties()

	val TRITANIUM_SWORD: SwordItem by registry.register(MNames.TRITANIUM_SWORD) { SwordItem(TRITANIUM_COMPONENT, 4, -2.7f, TOOLS_PROPRTIES) }
	val TRITANIUM_SHOVEL: ShovelItem by registry.register(MNames.TRITANIUM_SHOVEL) { ShovelItem(TRITANIUM_COMPONENT, 1.5f, -2.4f, TOOLS_PROPRTIES) }
	val TRITANIUM_AXE: MatteryAxeItem by registry.register(MNames.TRITANIUM_AXE) { MatteryAxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) }
	val TRITANIUM_PICKAXE: PickaxeItem by registry.register(MNames.TRITANIUM_PICKAXE) { PickaxeItem(TRITANIUM_COMPONENT, 2, -2.8f, TOOLS_PROPRTIES) }
	val TRITANIUM_HOE: HoeItem by registry.register(MNames.TRITANIUM_HOE) { HoeItem(TRITANIUM_COMPONENT, 0, -3.4f, TOOLS_PROPRTIES) }
	val TRITANIUM_SHEARS: ShearsItem by registry.register(MNames.TRITANIUM_SHEARS) { object : ShearsItem(Properties().durability(3072)) {
		override fun isValidRepairItem(pToRepair: ItemStack, pRepair: ItemStack): Boolean {
			return pRepair.`is`(MItemTags.TRITANIUM_INGOTS)
		}
	} }

	val TRITANIUM_SHIELD: ShieldItem by registry.register(MNames.TRITANIUM_SHIELD) { object : ShieldItem(Properties().durability(2048)) {
		override fun isValidRepairItem(pToRepair: ItemStack, pRepair: ItemStack): Boolean {
			return pRepair.`is`(MItemTags.REINFORCED_TRITANIUM_PLATES)
		}
	} }

	val TRITANIUM_TOOLS = SupplierList(
		::TRITANIUM_SWORD,
		::TRITANIUM_SHOVEL,
		::TRITANIUM_AXE,
		::TRITANIUM_PICKAXE,
		::TRITANIUM_HOE,
		::TRITANIUM_SHEARS,
	)

	val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(ArmorItem.Type.HELMET) }
	val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(ArmorItem.Type.CHESTPLATE) }
	val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(ArmorItem.Type.LEGGINGS) }
	val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(ArmorItem.Type.BOOTS) }

	val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(ArmorItem.Type.HELMET) }
	val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(ArmorItem.Type.CHESTPLATE) }
	val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(ArmorItem.Type.LEGGINGS) }
	val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(ArmorItem.Type.BOOTS) }

	val TRITANIUM_ARMOR = SupplierList(
		::TRITANIUM_HELMET,
		::TRITANIUM_CHESTPLATE,
		::TRITANIUM_PANTS,
		::TRITANIUM_BOOTS
	)

	val SIMPLE_TRITANIUM_ARMOR = SupplierList(
		::SIMPLE_TRITANIUM_HELMET,
		::SIMPLE_TRITANIUM_CHESTPLATE,
		::SIMPLE_TRITANIUM_PANTS,
		::SIMPLE_TRITANIUM_BOOTS
	)

	val EXPLOSIVE_HAMMER: ExplosiveHammerItem by registry.register("explosive_hammer") { ExplosiveHammerItem() }

	val ENERGY_SWORD: Item by registry.register(MNames.ENERGY_SWORD) { EnergySwordItem() }

	val PLASMA_RIFLE: Item by registry.register(MNames.PLASMA_RIFLE) { PlasmaRifleItem() }

	val BLACK_HOLE_SCANNER: Item by registry.register(MNames.BLACK_HOLE_SCANNER) {
		object : Item(DEFAULT_PROPERTIES) {
			override fun appendHoverText(
				p_41421_: ItemStack,
				p_41422_: Level?,
				p_41423_: MutableList<Component>,
				p_41424_: TooltipFlag
			) {
				p_41423_.add(TranslatableComponent("item.overdrive_that_matters.black_hole_scanner.desc").withStyle(ChatFormatting.GRAY))
				p_41423_.add(TranslatableComponent("item.overdrive_that_matters.black_hole_scanner.desc2").withStyle(ChatFormatting.DARK_GRAY))
			}
		}
	}

	val GRAVITATION_FIELD_LIMITER: Item by registry.register(MNames.GRAVITATION_FIELD_LIMITER) { Item(DEFAULT_PROPERTIES) }
	val GRAVITATION_FIELD_SENSOR: Item by registry.register(MNames.GRAVITATION_FIELD_SENSOR) { Item(DEFAULT_PROPERTIES) }
	val PORTABLE_GRAVITATION_STABILIZER: Item by registry.register(MNames.PORTABLE_GRAVITATION_STABILIZER) { PortableGravitationStabilizerItem() }

	val BLACK_HOLE: Item by registry.register(MNames.BLACK_HOLE) { BlockItem(MBlocks.BLACK_HOLE, DEFAULT_PROPERTIES) }

	val GRAVITATIONAL_DISRUPTOR: Item by registry.register(MNames.GRAVITATIONAL_DISRUPTOR) { GravitationalDisruptorItem() }

	val PILL_ANDROID: Item by registry.register(MNames.PILL_ANDROID) { PillItem(PillType.BECOME_ANDROID) }
	val PILL_HUMANE: Item by registry.register(MNames.PILL_HUMANE) { PillItem(PillType.BECOME_HUMANE) }
	val PILL_OBLIVION: Item by registry.register(MNames.PILL_OBLIVION) { PillItem(PillType.OBLIVION) }
	val PILL_HEAL: Item by registry.register(MNames.PILL_HEAL) { HealPillItem() }

	val PILLS = SupplierList(
		::PILL_ANDROID,
		::PILL_HUMANE,
		::PILL_OBLIVION,
		::PILL_HEAL,
	)

	val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() }
	val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BASIC) }
	val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.NORMAL) }
	val BATTERY_DENSE: Item by registry.register(MNames.BATTERY_DENSE) { BatteryItem(ItemsConfig.Batteries.DENSE) }
	val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ItemsConfig.Batteries.CAPACITOR) }
	val BATTERY_CREATIVE: Item by registry.register(MNames.BATTERY_CREATIVE) { BatteryItem() }

	val QUANTUM_BATTERY: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) }
	val QUANTUM_CAPACITOR: QuantumBatteryItem by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ItemsConfig.Batteries.QUANTUM_CAPACITOR) }
	val QUANTUM_BATTERY_CREATIVE: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE) }
	val ZPM_BATTERY: ZPMItem by registry.register(MNames.ZPM_BATTERY) { ZPMItem() }
	val PROCEDURAL_BATTERY: ProceduralBatteryItem by registry.register(MNames.PROCEDURAL_BATTERY) { ProceduralBatteryItem() }

	val BATTERIES = SupplierList(
		::BATTERY_CRUDE,
		::BATTERY_BASIC,
		::BATTERY_NORMAL,
		::BATTERY_DENSE,
		::BATTERY_CAPACITOR,
	)

	val UNIQUE_BATTERIES = SupplierList(
		::QUANTUM_BATTERY,
		::QUANTUM_CAPACITOR,
		::QUANTUM_BATTERY_CREATIVE,
		::ZPM_BATTERY,
	)

	val ALL_BATTERIES = SupplierList(
		::BATTERY_CRUDE,
		::BATTERY_BASIC,
		::BATTERY_NORMAL,
		::BATTERY_DENSE,
		::BATTERY_CAPACITOR,
		::BATTERY_CREATIVE,

		::QUANTUM_BATTERY,
		::QUANTUM_CAPACITOR,
		::QUANTUM_BATTERY_CREATIVE,
		::ZPM_BATTERY,
	)

	val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ItemsConfig.Capacitors::BASIC) }
	val MATTER_CAPACITOR_NORMAL: Item by registry.register(MNames.MATTER_CAPACITOR_NORMAL) { MatterCapacitorItem(ItemsConfig.Capacitors::NORMAL) }
	val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ItemsConfig.Capacitors::DENSE) }
	val MATTER_CAPACITOR_CREATIVE: Item by registry.register(MNames.MATTER_CAPACITOR_CREATIVE) { MatterCapacitorItem() }

	val MATTER_CAPACITORS = SupplierList(
		::MATTER_CAPACITOR_BASIC,
		::MATTER_CAPACITOR_NORMAL,
		::MATTER_CAPACITOR_DENSE,
		::MATTER_CAPACITOR_CREATIVE,
	)

	val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(ItemsConfig.PatternDrives::NORMAL) }
	val PATTERN_DRIVE_CREATIVE: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE) { PatternStorageItem() }
	val PATTERN_DRIVE_CREATIVE2: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE2) { CreativePatternItem() }

	val PORTABLE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(4000) }
	val PORTABLE_DENSE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_DENSE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(25000) }

	val NUTRIENT_PASTE: Item by registry.register(MNames.NUTRIENT_PASTE) { Item(Item.Properties().stacksTo(64).food(FoodProperties.Builder().meat().nutrition(8).saturationMod(0.9F).build())) }

	val LABORATORY_LAMP: Item by registry.register(MNames.LABORATORY_LAMP) { BlockItem(MBlocks.LABORATORY_LAMP, DEFAULT_PROPERTIES) }
	val LABORATORY_LAMP_INVERTED: Item by registry.register(MNames.LABORATORY_LAMP_INVERTED) { BlockItem(MBlocks.LABORATORY_LAMP_INVERTED, DEFAULT_PROPERTIES) }
	val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES) }
	val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES) }
	val ENGINE: Item by registry.register(MNames.ENGINE) { BlockItem(MBlocks.ENGINE, DEFAULT_PROPERTIES) }
	val HOLO_SIGN: Item by registry.register(MNames.HOLO_SIGN) { BlockItem(MBlocks.HOLO_SIGN, DEFAULT_PROPERTIES) }

	val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) }
	val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) }

	init {
		MRegistry.TRITANIUM_PRESSURE_PLATE.registerItems(registry)
	}

	// components
	val MATTER_IO_PORT: Item by registry.register(MNames.MATTER_IO_PORT) { Item(DEFAULT_PROPERTIES) }
	val MATTER_TRANSFORM_MATRIX: Item by registry.register(MNames.MATTER_TRANSFORM_MATRIX) { Item(DEFAULT_PROPERTIES) }
	val ENERGY_BUS: Item by registry.register(MNames.ENERGY_BUS) { Item(DEFAULT_PROPERTIES) }
	val ELECTRIC_PARTS: Item by registry.register(MNames.ELECTRIC_PARTS) { Item(DEFAULT_PROPERTIES) }
	val MACHINE_FRAME: Item by registry.register(MNames.MACHINE_FRAME) { Item(DEFAULT_PROPERTIES) }
	val TRITANIUM_PLATE: Item by registry.register(MNames.TRITANIUM_PLATE) { Item(DEFAULT_PROPERTIES) }
	val IRON_PLATE: Item by registry.register(MNames.IRON_PLATE) { Item(DEFAULT_PROPERTIES) }
	val GOLD_PLATE: Item by registry.register(MNames.GOLD_PLATE) { Item(DEFAULT_PROPERTIES) }
	val COPPER_WIRING: Item by registry.register(MNames.COPPER_WIRING) { Item(DEFAULT_PROPERTIES) }
	val GOLD_WIRING: Item by registry.register(MNames.GOLD_WIRING) { Item(DEFAULT_PROPERTIES) }
	val PORTABLE_CONDENSATION_DRIVE_CASING: Item by registry.register(MNames.PORTABLE_CONDENSATION_DRIVE_CASING) { Item(DEFAULT_PROPERTIES) }
	val PORTABLE_DENSE_CONDENSATION_DRIVE_CASING: Item by registry.register(MNames.PORTABLE_DENSE_CONDENSATION_DRIVE_CASING) { Item(DEFAULT_PROPERTIES) }
	val CIRCUIT_PLATING: Item by registry.register(MNames.CIRCUIT_PLATING) { Item(DEFAULT_PROPERTIES) }
	val BASIC_CONTROL_CIRCUIT: Item by registry.register(MNames.BASIC_CONTROL_CIRCUIT) { Item(DEFAULT_PROPERTIES) }
	val ADVANCED_CONTROL_CIRCUIT: Item by registry.register(MNames.ADVANCED_CONTROL_CIRCUIT) { Item(DEFAULT_PROPERTIES) }
	val MATTER_CAPACITOR_PARTS: Item by registry.register(MNames.MATTER_CAPACITOR_PARTS) { Item(DEFAULT_PROPERTIES) }
	val CARBON_MESH: Item by registry.register(MNames.CARBON_MESH) { Item(DEFAULT_PROPERTIES) }
	val REINFORCED_TRITANIUM_PLATE: Item by registry.register(MNames.REINFORCED_TRITANIUM_PLATE) { object : Item(DEFAULT_PROPERTIES) {
		override fun appendHoverText(
			p_41421_: ItemStack,
			p_41422_: Level?,
			p_41423_: MutableList<Component>,
			p_41424_: TooltipFlag
		) {
			super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_)
			p_41423_.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY))
		}
	} }

	val QUANTUM_TRANSCEIVER: Item by registry.register("quantum_transceiver") { Item(DEFAULT_PROPERTIES) }
	val ELECTROMAGNET: Item by registry.register("electromagnet") { Item(DEFAULT_PROPERTIES) }
	val MIRROR_COMPOUND: Item by registry.register("mirror_compound") { Item(DEFAULT_PROPERTIES) }
	val MIRROR: Item by registry.register("mirror") { object : Item(DEFAULT_PROPERTIES) {
		override fun appendHoverText(
			p_41421_: ItemStack,
			p_41422_: Level?,
			p_41423_: MutableList<Component>,
			p_41424_: TooltipFlag
		) {
			super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_)
			p_41423_.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY))
		}
	} }

	/**
	 * List of components for everything else
	 */
	val COMPONENTS = SupplierList(
		::MATTER_IO_PORT,
		::MATTER_TRANSFORM_MATRIX,
		::ENERGY_BUS,
		::ELECTRIC_PARTS,
		::MACHINE_FRAME,
		::TRITANIUM_PLATE,
		::IRON_PLATE,
		::GOLD_PLATE,
		::COPPER_WIRING,
		::GOLD_WIRING,
		::PORTABLE_CONDENSATION_DRIVE_CASING,
		::PORTABLE_DENSE_CONDENSATION_DRIVE_CASING,
		::CIRCUIT_PLATING,
		::BASIC_CONTROL_CIRCUIT,
		::ADVANCED_CONTROL_CIRCUIT,
		::MATTER_CAPACITOR_PARTS,

		::QUANTUM_TRANSCEIVER,
		::ELECTROMAGNET,
		::MIRROR_COMPOUND,
		::MIRROR,

		::CARBON_MESH,
		::REINFORCED_TRITANIUM_PLATE,
	)

	/**
	 * List of components for datagen code
	 */
	val DATAGEN_COMPONENTS = SupplierList(
		::ENERGY_BUS,
		::ELECTRIC_PARTS,
		::TRITANIUM_PLATE,
		::IRON_PLATE,
		::GOLD_PLATE,
		::COPPER_WIRING,
		::GOLD_WIRING,
		::CIRCUIT_PLATING,
		::BASIC_CONTROL_CIRCUIT,
		::ADVANCED_CONTROL_CIRCUIT,
		::MATTER_CAPACITOR_PARTS,
		::MATTER_IO_PORT,
		::MATTER_TRANSFORM_MATRIX,
		::QUANTUM_TRANSCEIVER,
		::ELECTROMAGNET,
		::MIRROR_COMPOUND,
		::MIRROR,

		::CARBON_MESH,
		::REINFORCED_TRITANIUM_PLATE,
	)

	val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) }

	val EXOPACK_PROBE: Item by registry.register(MNames.EXOPACK_PROBE, ::ExoPackProbeItem)

	object ExopackUpgrades {
		val INVENTORY_UPGRADE_CREATIVE: Item by registry.register("exosuit_inventory_upgrade_creative") { ExoPackSlotUpgradeItem(null, 27, Rarity.EPIC) }
		val CRAFTING_UPGRADE: Item by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") }
		val SMELTING_UPGRADE: Item by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") }

		val INVENTORY_UPGRADES = SupplierList(8) {
			registry.register("exosuit_inventory_upgrade_$it") { ExoPackSlotUpgradeItem(18, Rarity.COMMON) }::get
		}

		val INVENTORY_UPGRADE_PROCEDURAL: Item by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExoPackSlotUpgradeItem() }

		val INVENTORY_UPGRADE_BIG: Item by registry.register("exosuit_inventory_upgrade_big") { ExoPackSlotUpgradeItem(60, Rarity.RARE) }
		val INVENTORY_UPGRADE_HUGE: Item by registry.register("exosuit_inventory_upgrade_huge") { ExoPackSlotUpgradeItem(135, Rarity.RARE) }

		val INVENTORY_UPGRADE_WITHER: Item by registry.register("exosuit_inventory_upgrade_wither") { ExoPackSlotUpgradeItem(180, Rarity.RARE, hasDescription = true) }
		val INVENTORY_UPGRADE_ENDER_DRAGON: Item by registry.register("exosuit_inventory_upgrade_ender_dragon") { ExoPackSlotUpgradeItem(180, Rarity.EPIC, hasDescription = true) }
	}

	init {
		// call static initializer
		ExopackUpgrades

		MRegistry.CARGO_CRATES.registerItems(registry)
		MRegistry.TRITANIUM_BLOCK.registerItems(registry)
		MRegistry.TRITANIUM_STAIRS.registerItems(registry)
		MRegistry.TRITANIUM_SLAB.registerItems(registry)
		MRegistry.TRITANIUM_WALL.registerItems(registry)
	}

	val TRITANIUM_STRIPED_BLOCK: Item by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { BlockItem(MBlocks.TRITANIUM_STRIPED_BLOCK, DEFAULT_PROPERTIES) }
	val TRITANIUM_STRIPED_STAIRS: Item by registry.register(MNames.TRITANIUM_STRIPED_STAIRS) { BlockItem(MBlocks.TRITANIUM_STRIPED_STAIRS, DEFAULT_PROPERTIES) }
	val TRITANIUM_STRIPED_SLAB: Item by registry.register(MNames.TRITANIUM_STRIPED_SLAB) { BlockItem(MBlocks.TRITANIUM_STRIPED_SLAB, DEFAULT_PROPERTIES) }
	val TRITANIUM_STRIPED_WALL: Item by registry.register(MNames.TRITANIUM_STRIPED_WALL) { BlockItem(MBlocks.TRITANIUM_STRIPED_WALL, DEFAULT_PROPERTIES) }
	val CARBON_FIBRE_BLOCK: Item by registry.register(MNames.CARBON_FIBRE_BLOCK) { BlockItem(MBlocks.CARBON_FIBRE_BLOCK, DEFAULT_PROPERTIES) }
	val METAL_JUNK: Item by registry.register(MNames.METAL_JUNK) { BlockItem(MBlocks.METAL_JUNK, DEFAULT_PROPERTIES) }
	val METAL_MESH: Item by registry.register(MNames.METAL_MESH) { BlockItem(MBlocks.METAL_MESH, DEFAULT_PROPERTIES) }

	init {
		MRegistry.INDUSTRIAL_GLASS.registerItems(registry)
		MRegistry.INDUSTRIAL_GLASS_PANE.registerItems(registry)
		MRegistry.UNREFINED_FLOOR_TILES.registerItems(registry)
		MRegistry.FLOOR_TILES.registerItems(registry)
		MRegistry.FLOOR_TILES_STAIRS.registerItems(registry)
		MRegistry.FLOOR_TILES_SLAB.registerItems(registry)
		MRegistry.VENT.registerItems(registry)
		MRegistry.VENT_ALTERNATIVE.registerItems(registry)
		MRegistry.DECORATIVE_CRATE.registerItems(registry)
		MRegistry.TRITANIUM_STRIPED_BLOCK.registerItems(registry)
		MRegistry.TRITANIUM_STRIPED_STAIRS.registerItems(registry)
		MRegistry.TRITANIUM_STRIPED_SLAB.registerItems(registry)
		MRegistry.TRITANIUM_STRIPED_WALL.registerItems(registry)
	}
}
