package ru.dbotthepony.mc.otm.android.feature

import net.minecraft.world.entity.ai.attributes.AttributeModifier
import net.minecraft.world.entity.ai.attributes.Attributes
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.android.AndroidFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
import ru.dbotthepony.mc.otm.core.ResourceLocation
import ru.dbotthepony.mc.otm.registry.game.AndroidFeatures

class AttackBoostFeature(android: MatteryPlayer) : AndroidFeature(AndroidFeatures.ATTACK_BOOST, android) {
	override fun applyModifiers() {
		val modifier = ply.getAttribute(Attributes.ATTACK_DAMAGE)

		if (modifier != null) {
			modifier.removeModifier(MODIFIER_ID)
			modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, (level + 1) * 0.15, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL))
		}
	}

	override fun removeModifiers() {
		ply.getAttribute(Attributes.ATTACK_DAMAGE)?.removeModifier(MODIFIER_ID)
	}

	companion object {
		private val MODIFIER_ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "attack_boost_feature")
	}
}
