1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I add attribute to item?

Discussion in 'Skript' started by KorkugunuB, Jan 29, 2017.

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

    KorkugunuB Member

    Joined:
    Jan 25, 2017
    Messages:
    15
    Likes Received:
    1
    How do I add attribute to item?

    For example,
     
    #1 KorkugunuB, Jan 29, 2017
    Last edited: Jan 29, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You have to use skStuff to modify the NBT.
    Code (Text):
    1. add "{AttributeModifiers:[{AttributeName:""generic.attackDamage"",Name:""generic.attackDamage"",Amount:20,Operation:0,UUIDLeast:894654,UUIDMost:2872}]}" to nbt of player's tool
    Remember to double the quotes inside the NBT tag.
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    thanks for helping me
    --- Double Post Merged, Jan 29, 2017, Original Post Date: Jan 29, 2017 ---
    Code (Skript):
    1. add "{AttributeModifiers:[{AttributeName:generic.attackDamage,Name:generic.attackDamage,Amount:20,Operation:0,UUIDLeast:894654,UUIDMost:2872}]}" to nbt of {_item}
    I'm using it as a function.
    it's not working
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Seems like you cannot change the nbt of any item using functions. Use it normally and no problems will occour. I'll talk to TheBukor to see if he can fix it or something.
    Code (Text):
    1.  
    2. [22:05:12 WARN]: [Skript] Failed to change the NBT of an item: Itemstack didn't have any slot attached to it.
    3.  
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I need to do that
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Can you show us the function?
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Code (Skript):
    1. function addAttribute(item: item, itemid: text) :: itemtype:
    2.      if yaml path "items.%{_itemid}%.AttributeModifiers" in file "plugins/Task/items.yml" exists:
    3.           set {_attribute::*} to yaml nodes "items.%{_itemid}%.AttributeModifiers" from file "plugins/Task/items.yml"
    4.           loop {_attribute::*}:
    5.                set {_atname} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.AttributeName" from file "plugins/Task/items.yml"
    6.                set {_name} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Name" from file "plugins/Task/items.yml"
    7.                set {_amount} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Amount" from file "plugins/Task/items.yml"
    8.                set {_operation} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Operation" from file "plugins/Task/items.yml"
    9.                set {_uuidl} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDLeast" from file "plugins/Task/items.yml"
    10.                set {_uuidm} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDMost" from file "plugins/Task/items.yml"
    11.                add "{AttributeModifiers:[{AttributeName:%{_atname}%,Name:%{_name}%,Amount:%{_amount}%,Operation:%{_operation}%,UUIDLeast:%{_uuidl}%,UUIDMost:%{_uuidm}%}]}" to nbt of {_item} parsed as a item
    12.           return {_item}
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    You did the function return an item type instead of an itemstack, change the return type to "item" and see if it works. If it still doesn't work, broadcast the {_item}'s nbt and tell me if it broadcast the item's nbt or <none>
     
    #8 ShaneBee, Jan 30, 2017
    Last edited by a moderator: Jan 30, 2017
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    item's nbt : [​IMG]
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Code (Skript):
    1. function addAttribute(item: item, itemid: text) :: item:
    2.      if yaml path "items.%{_itemid}%.AttributeModifiers" in file "plugins/Task/items.yml" exists:
    3.           set {_attribute::*} to yaml nodes "items.%{_itemid}%.AttributeModifiers" from file "plugins/Task/items.yml"
    4.           loop {_attribute::*}:
    5.                set {_atname} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.AttributeName" from file "plugins/Task/items.yml"
    6.                set {_name} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Name" from file "plugins/Task/items.yml"
    7.                set {_amount} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Amount" from file "plugins/Task/items.yml"
    8.                set {_operation} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Operation" from file "plugins/Task/items.yml"
    9.                set {_uuidl} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDLeast" from file "plugins/Task/items.yml"
    10.                set {_uuidm} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDMost" from file "plugins/Task/items.yml"
    11.                add "{AttributeModifiers:[{AttributeName:""%{_atname}%"",Name:""%{_name}%"",Amount:%{_amount}%,Operation:%{_operation}%,UUIDLeast:%{_uuidl}%,UUIDMost:%{_uuidm}%}]}" to nbt of {_item}
    12.           return {_item}
    Try that
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    it doesn't work
     
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Does it throw and error? Can you show that values of the yml file?
     
  13. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    there isn't an error. just not added
    [​IMG]
    --- Double Post Merged, Jan 30, 2017, Original Post Date: Jan 30, 2017 ---
    when you answer ? @Snow-Pyon
    --- Double Post Merged, Jan 30, 2017 ---
    please help me
    --- Double Post Merged, Jan 31, 2017 ---
    urgent need
    please help me
     
Thread Status:
Not open for further replies.

Share This Page

Loading...