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.android.AndroidFeature
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
import java.util.*

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

		if (modifier != null) {
			modifier.removePermanentModifier(MODIFIER_ID)
			modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * 0.15, AttributeModifier.Operation.MULTIPLY_TOTAL))
		}
	}

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

	companion object {
		private val MODIFIER_ID = UUID.fromString("4a3fae46-e57b-4e21-857d-f5c2b2c8a2f2")
	}
}
