package com.zivilon.cinder_loe.mixins;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

import com.zivilon.cinder_loe.items.LoEGreatSword;
import lotr.common.item.LOTRItemBattleaxe;
import lotr.common.item.LOTRItemHammer;
import lotr.common.item.LOTRItemBalrogWhip;
import lotr.common.enchant.LOTREnchantment;
import lotr.common.enchant.LOTREnchantmentType;
import lotr.common.enchant.LOTREnchantmentHelper;
import lotr.common.enchant.LOTREnchantmentWeaponSpecial;
import lotr.common.item.LOTRWeaponStats;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

@Mixin(LOTREnchantmentWeaponSpecial.class)
public abstract class MixinLOTREnchantmentWeaponSpecial extends LOTREnchantment {

    public MixinLOTREnchantmentWeaponSpecial(String s, LOTREnchantmentType type) {
        super(s, type);
    }

    /**
     * @author Shinare
     * @reason Made Wrathful exclusive to heavy weapons
     */
    @Overwrite(remap = false)
    public boolean canApply(ItemStack itemstack, boolean considering) {
        if (super.canApply(itemstack, considering)) {
            Item item = itemstack.getItem();
            if (item instanceof LOTRItemBalrogWhip && (this == LOTREnchantment.fire || this == LOTREnchantment.chill))
                return false;
            if (this == LOTREnchantment.getEnchantmentByName("wrath"))
                return (item instanceof LoEGreatSword || item instanceof LOTRItemBattleaxe || item instanceof LOTRItemHammer);
            return true;
        }
        return false;
    }
}
