Jump to content

[Question] what is the UUID for with attributes on items?


theishiopian

Recommended Posts

I am attempting to make a weapon with a custom attribute, in this case armor penetration. Everything has made sense so far, except that the attribute map on the item requires a UUID, which from what i can tell, is just preset at random. 

My current constructor looks like this:

public WeaponMace(IItemTier tier, Properties properties, float baseDamage, double speed, int armorPen)
    {
        super(tier, properties);

        Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
        float attackDamage = baseDamage + tier.getAttackDamageBonus();
        builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", attackDamage, AttributeModifier.Operation.ADDITION));
        builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", speed, AttributeModifier.Operation.ADDITION));
        builder.put(ModAttributes.ARMOR_PENETRATION.get(), new AttributeModifier(UUID.fromString("c7675e5c-2e25-4589-ace1-f0ad816b40b8"), "Weapon modifier", armorPen, AttributeModifier.Operation.ADDITION));
        this.defaultModifiers = builder.build();
    }

Is this an ok way of doing this? 

Link to comment
Share on other sites

1 hour ago, theishiopian said:

Everything has made sense so far, except that the attribute map on the item requires a UUID, which from what i can tell, is just preset at random.

The UUID is used to identify the attribute. This means that if two items have the same UUID for an attribute, the most recently equipped one will override the other if both are equipped at the same time. The Minecraft wiki has some info about it on the attribute page here. What I usually do is generate a random UUID once with UUID.randomUUID(), and then use that in UUID.fromString().

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.