package ru.dbotthepony.mc.otm.datagen.tags

import net.minecraft.tags.BlockTags
import net.minecraft.tags.ItemTags
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.item.Items
import net.neoforged.neoforge.common.Tags
import ru.dbotthepony.kommons.collect.flatMap
import ru.dbotthepony.mc.otm.core.ResourceLocation
import ru.dbotthepony.mc.otm.registry.MBlockTags
import ru.dbotthepony.mc.otm.registry.game.MBlocks
import ru.dbotthepony.mc.otm.registry.game.MFluids
import ru.dbotthepony.mc.otm.registry.MItemTags
import ru.dbotthepony.mc.otm.registry.game.MItems
import ru.dbotthepony.mc.otm.registry.MRegistry

fun addTags(tagsProvider: TagsProvider) {
	tagsProvider.items.forge("pistons").add(Items.PISTON)

	tagsProvider.items.Appender(ItemTags.BEACON_PAYMENT_ITEMS)
		.add(MItems.TRITANIUM_INGOT)
		.add(MItems.DILITHIUM_CRYSTAL)
		.add(MItems.WITHERED_STEEL)
		.add(MItems.ROFLITE_ALLOY_INGOT)

	tagsProvider.items.Appender(ItemTags.MEAT).add(MItems.NUTRIENT_PASTE)

	tagsProvider.fluids.forge("experience").add(MFluids.LIQUID_XP).add(MFluids.LIQUID_XP_FLOWING)
	tagsProvider.fluidTypes.forge("experience").add(MFluids.LIQUID_XP_TYPE)

	tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES)
		.add(MItemTags.WORKBENCHES)
		.add(MItemTags.WORKBENCH)

	tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES)
		.add(MBlockTags.WORKBENCHES)
		.add(MBlockTags.WORKBENCH)

	tagsProvider.items.Appender(MItemTags.MINECART_CARGO_CRATES).add(MItems.CARGO_CRATE_MINECARTS.values)

	tagsProvider.blocks.Appender(BlockTags.ANVIL).add(MBlocks.TRITANIUM_ANVIL.values.stream().flatMap { it.stream() })
	tagsProvider.items.Appender(ItemTags.ANVIL).add(MItems.TRITANIUM_ANVIL.values.stream().flatMap { it.stream() })

	tagsProvider.items.Appender(MItemTags.UPGRADES)
		.add(MItems.MachineUpgrades.Basic.LIST)
		.add(MItems.MachineUpgrades.Normal.LIST)
		.add(MItems.MachineUpgrades.Advanced.LIST)
		.add(MItems.MachineUpgrades.Creative.LIST)

	tagsProvider.items.Appender(MItemTags.NO_REPLICATION)
		.add(MItemTags.DILITHIUM_GEMS)
		.add(MItemTags.DILITHIUM_ORES)
		.add(Items.WRITTEN_BOOK)
		.add(Tags.Items.ORES)
		.add(Tags.Items.RAW_MATERIALS)
		.add(MItems.PILL_ANDROID)
		.add(MItems.PILL_HUMANE)
		.add(MItems.PILL_OBLIVION)
		.add(MItems.QUANTUM_BATTERY)
		.add(MItems.QUANTUM_CAPACITOR)
		.add(MItems.QUANTUM_BATTERY_CREATIVE)
		.add(MItems.ZPM_BATTERY)
		.add(MItems.PROCEDURAL_BATTERY)
		.add(MItems.EXOPACK_PROBE)
		.add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL)
		.add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER)
		.add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON)

	tagsProvider.dragonImmune.add(
		MBlocks.BLACK_HOLE,
		MBlocks.GRAVITATION_STABILIZER,
		MBlocks.GRAVITATION_STABILIZER_LENS,
	)

	tagsProvider.witherImmune.add(
		MBlocks.BLACK_HOLE,
	)

	tagsProvider.guardedByPiglins.add(
		MBlockTags.CARGO_CRATES,
	)

	tagsProvider.impermeable.add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values)

	tagsProvider.androidImmuneEffects.add(
		MobEffects.CONDUIT_POWER,
		MobEffects.HEAL,
		// maybe it makes things go haywire idk
		// MobEffects.HARM,
		MobEffects.REGENERATION,
		MobEffects.WATER_BREATHING,
		MobEffects.POISON,
		// even skeletons can be withered
		// MobEffects.WITHER,
		MobEffects.HEALTH_BOOST,
		MobEffects.ABSORPTION,
		MobEffects.SATURATION,
		MobEffects.DOLPHINS_GRACE,
		MobEffects.CONFUSION,
	)

	tagsProvider.androidImmuneEffects.add(
		ResourceLocation("rats", "plague"),
		ResourceLocation("rats", "synesthesia"),
	)
}
