#Dynamically adjust attribute based on held item?

8 messages · Page 1 of 1 (latest)

waxen waveBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

ember pagoda
late dirge
#

there isnt

#

what i would do is set the attribute for every item you want to use as a "attribute item" you can do this in vanilla minecraft

#

this might work i havent tested it and dont know how the levelZ mod works so if there are any issues i dont know how i would fix it

// Register event for player tick
PlayerEvents.tick(event => {
    let player = event.player;
    let itemInMainHand = player.mainHandItem;
    let meetsRequirements = player.getScore('meetsLevelZRequirements') === 1;

    // Define your items and their attributes
    let itemsWithAttributes = {
        'modid:fire_staff': {
            attribute: 'spell_power:fire',
            value: 6
        }
        // Add more items as needed
    }

    // Remove all dynamic attributes first
    for (let itemId in itemsWithAttributes) {
        let attribute = itemsWithAttributes[itemId].attribute;
        let value = itemsWithAttributes[itemId].value;
        let attributeKey = `kubejs:attribute_${attribute}_${value}`;
        player.persistentData.remove(attributeKey);
        player.removeAttributeModifier(attribute, attributeKey);
    }

    // Check if the player is holding an item with attributes and meets requirements
    if (meetsRequirements && itemsWithAttributes[itemInMainHand.id]) {
        let attribute = itemsWithAttributes[itemInMainHand.id].attribute;
        let value = itemsWithAttributes[itemInMainHand.id].value;
        let attributeKey = `kubejs:attribute_${attribute}_${value}`;
        player.persistentData.put(attributeKey, true);
        player.addAttributeModifier(attribute, value, attributeKey);
    }
});

This Script also depends on a scoreboard

/scoreboard objectives add meetsLevelZRequirements dummy

i did my best to make it work so yea

#

and im sure that this is a very crude way of doing this and there are several people that could have done it better

ember pagoda
#
event.player.setAttributeBaseValue('minecraft:generic.max_health', 10);
event.player.modifyAttribute('minecraft:generic.max_health', event.player, 10, 'addition')
late dirge
#

they are trying to base it off levelZ