package ru.dbotthepony.mc.otm.datagen

import net.minecraft.core.RegistrySetBuilder
import net.minecraft.core.registries.Registries
import net.minecraft.data.worldgen.BootstapContext
import net.minecraft.tags.DamageTypeTags
import net.minecraft.world.damagesource.DamageScaling
import net.minecraft.world.damagesource.DamageType
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider
import net.minecraftforge.data.event.GatherDataEvent
import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
import ru.dbotthepony.mc.otm.registry.MDamageTypes

fun registerDamageTypes(context: BootstapContext<DamageType>) {
	context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f))
	context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.EVENT_HORIZON, DamageType("otm_event_horizon", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.HAWKING_RADIATION, DamageType("otm_hawking_radiation", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.EMP, DamageType("otm_emp", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.SHOCKWAVE, DamageType("otm_shockwave", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.PLASMA, DamageType("otm_plasma", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f))
	context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f))
	context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f))
	context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f))
}

fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
	val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR)
	val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS)
	val ignoreInvl = provider.Appender(DamageTypeTags.BYPASSES_INVULNERABILITY)

	ignoreArmor
		.add(MDamageTypes.EXOPACK_PROBE)
		.add(MDamageTypes.BECOME_ANDROID)
		.add(MDamageTypes.BECOME_HUMANE)
		.add(MDamageTypes.EVENT_HORIZON)
		.add(MDamageTypes.EMP)
		.add(MDamageTypes.SHOCKWAVE)
		.add(MDamageTypes.COSMIC_RAYS)
		.add(MDamageTypes.ANDROID_DISCHARGE)

	ignoreMagic
		.add(MDamageTypes.EXOPACK_PROBE)
		.add(MDamageTypes.BECOME_ANDROID)
		.add(MDamageTypes.BECOME_HUMANE)
		.add(MDamageTypes.COSMIC_RAYS)
		.add(MDamageTypes.ANDROID_DISCHARGE)

	ignoreInvl
		.add(MDamageTypes.BECOME_HUMANE)
		.add(MDamageTypes.BECOME_ANDROID)
		.add(MDamageTypes.ANDROID_DISCHARGE)
}
