//This all goes in startup_scripts

let $Attributes = Java.loadClass('net.minecraft.world.entity.ai.attributes.Attributes')
let $AttributeModifier = Java.loadClass('net.minecraft.world.entity.ai.attributes.AttributeModifier')
let $ISSAttributeRegistry = Java.loadClass('io.redspace.ironsspellbooks.api.registry.AttributeRegistry')

ForgeEvents.onEvent('net.minecraftforge.event.ItemAttributeModifierEvent', event => {
    if (event.itemStack.id == 'cataclysm:the_incinerator' && event.slotType == 'mainhand') {
        //Inputting a ResourceLocation or a string of an attribute ID also works, but I just use the direct attribute
        event.addModifier($Attributes.ATTACK_SPEED, new $AttributeModifier(UUID.fromString('8de60aa9-1d4b-459f-b075-48e1c37523ce'), 'Weapon modifier', -0.4, 'multiply_total'))
        event.addModifier($Attributes.ATTACK_DAMAGE, new $AttributeModifier(UUID.fromString('e5f42dff-43e7-43a8-a289-8ec1e0b94fbf'), 'Weapon modifier', 4, 'addition'))
    }

    let legmonsters = [
        'legendary_monsters:the_great_frost',
        'legendary_monsters:golden_halbert',
        'legendary_monsters:knights_sword',
        'legendary_monsters:chorus_blade'
    ];

    let slowleg = [
        'legendary_monsters:axe_of_lightning',
        'legendary_monsters:wand_of_clouds'
    ];

    let heldItem = event.itemStack;
    let slot = event.slotType;

    if ((slot === 'mainhand') && legmonsters.includes(heldItem.id)) {
        event.addModifier(
            $Attributes.ATTACK_DAMAGE,
            new $AttributeModifier(
                UUID.fromString('a8aee957-e0d8-448b-8e05-77d9e3c207c7'),
                'Weapon modifier',
                3,
                'addition'
            )
        );
    }

    if ((slot === 'mainhand') && slowleg.includes(heldItem.id)) {
        event.addModifier(
            $Attributes.ATTACK_SPEED,
            new $AttributeModifier(
                UUID.fromString('1bf05998-8bf2-4de7-a8dd-aa2cc00c974e'),
                'Weapon modifier',
                -0.4,
                'multiply_total'
            )
        );
    }
});