Giving attributes (modifiers) to items.

Discussion in 'Plugin Development' started by nzkiwi.5000, Aug 22, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    nzkiwi.5000

    Hello!
    Is there any way to give the items atrtributes?
    What MCWiki says (open)

    http://minecraft.gamepedia.com/Attribute:


    Attributes are a system of buffs/debuffs added in 13w16a.They are hidden properties on mobs and players, and some are specific to certain types of mobs. Attributes also haveModifiers which adjust the strength of their effect. When applied to an item, a Modifier will adjust the corresponding Attribute if the item is held or worn. [...]
    Code:text
    1. /give @p diamond_sword 1 0 {AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:20,Operation:0,UUIDLeast:894654,UUIDMost:2872}]}


    will give you a diamond sword which does 20 ([​IMG] × 10) extra damage. [...]


    So is there any other way than composing the command and dispatching it?

    Question 2:
    There's an attribute called generic.maxHealth. If I set it to make the wearer have for ex. 30HP, will the problem posted here occur?
     
  2. Offline

    Zettelkasten

    nzkiwi.5000 I would also love info on this! The error occurs only when you set a players health greater then his maximum health. The attribute generic.maxHealth increases maxHealth though :)
     
  3. Offline

    Dragonphase

    nzkiwi.5000
    There is an issue with this at the moment. That command, for example - if you are in creative mode, it will give you an unchanged diamond sword. If you are in survival mode, it will give you a diamond sword with "+20 Attack Damage" although the actual damage of the sword is unchanged and still causes the same amount of damage as a normal diamond sword.
     
  4. Offline

    Zettelkasten

    Dragonphase Can you please post your way of giving the item anyways? This sounds like a bug that would be fixed in the future, so the code would be very handy.
     
  5. Offline

    Dragonphase

    Zettelkasten

    I didn't do it programmatically, I just used a Command Block to give myself the item. I haven't taken a deeper look into the issue so I can't say I know how to change attribute modifiers programmatically but my best guess is to use NMS. I do have an interest in attribute modifiers though, so I'm keeping my eyes peeled.
     
  6. Offline

    nzkiwi.5000

    Zettelkasten So should I report this to bug tracker? Also, the only way I know is via this give command with json.
    Do you mean that Bukkit ignores JSON parameter? I was doing it some time ago on SSP and it worked fine!
     
  7. Offline

    Dragonphase

    nzkiwi.5000

    It works great in SSP. Just not on a Bukkit server.
     
Thread Status:
Not open for further replies.

Share This Page