How do I add attribute to item?

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

KorkugunuB

Member
Jan 25, 2017
15
1
3
28
Germany
How do I add attribute to item?

For example,
{AttributeModifiers:[{AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:20,Operation:0,UUIDLeast:894654,UUIDMost:2872}]}
 
Last edited:
You have to use skStuff to modify the NBT.
Code:
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.
 
You have to use skStuff to modify the NBT.
Code:
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.
thanks for helping me
[doublepost=1485733805,1485730901][/doublepost]
code_language.skript:
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
 
thanks for helping me
[doublepost=1485733805,1485730901][/doublepost]
code_language.skript:
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
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:
[22:05:12 WARN]: [Skript] Failed to change the NBT of an item: Itemstack didn't have any slot attached to it.
 
Can you show us the function?
code_language.skript:
function addAttribute(item: item, itemid: text) :: itemtype:
     if yaml path "items.%{_itemid}%.AttributeModifiers" in file "plugins/Task/items.yml" exists:
          set {_attribute::*} to yaml nodes "items.%{_itemid}%.AttributeModifiers" from file "plugins/Task/items.yml"
          loop {_attribute::*}:
               set {_atname} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.AttributeName" from file "plugins/Task/items.yml"
               set {_name} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Name" from file "plugins/Task/items.yml"
               set {_amount} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Amount" from file "plugins/Task/items.yml"
               set {_operation} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Operation" from file "plugins/Task/items.yml"
               set {_uuidl} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDLeast" from file "plugins/Task/items.yml"
               set {_uuidm} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDMost" from file "plugins/Task/items.yml"
               add "{AttributeModifiers:[{AttributeName:%{_atname}%,Name:%{_name}%,Amount:%{_amount}%,Operation:%{_operation}%,UUIDLeast:%{_uuidl}%,UUIDMost:%{_uuidm}%}]}" to nbt of {_item} parsed as a item
          return {_item}
 
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>
 
Last edited by a moderator:
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 not and tell me if it broadcast the item's nbt or <none>
item's nbt :
Y1IndSU.png
 
code_language.skript:
function addAttribute(item: item, itemid: text) :: item:
     if yaml path "items.%{_itemid}%.AttributeModifiers" in file "plugins/Task/items.yml" exists:
          set {_attribute::*} to yaml nodes "items.%{_itemid}%.AttributeModifiers" from file "plugins/Task/items.yml"
          loop {_attribute::*}:
               set {_atname} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.AttributeName" from file "plugins/Task/items.yml"
               set {_name} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Name" from file "plugins/Task/items.yml"
               set {_amount} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Amount" from file "plugins/Task/items.yml"
               set {_operation} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Operation" from file "plugins/Task/items.yml"
               set {_uuidl} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDLeast" from file "plugins/Task/items.yml"
               set {_uuidm} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDMost" from file "plugins/Task/items.yml"
               add "{AttributeModifiers:[{AttributeName:""%{_atname}%"",Name:""%{_name}%"",Amount:%{_amount}%,Operation:%{_operation}%,UUIDLeast:%{_uuidl}%,UUIDMost:%{_uuidm}%}]}" to nbt of {_item}
          return {_item}
Try that
 
code_language.skript:
function addAttribute(item: item, itemid: text) :: item:
     if yaml path "items.%{_itemid}%.AttributeModifiers" in file "plugins/Task/items.yml" exists:
          set {_attribute::*} to yaml nodes "items.%{_itemid}%.AttributeModifiers" from file "plugins/Task/items.yml"
          loop {_attribute::*}:
               set {_atname} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.AttributeName" from file "plugins/Task/items.yml"
               set {_name} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Name" from file "plugins/Task/items.yml"
               set {_amount} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Amount" from file "plugins/Task/items.yml"
               set {_operation} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.Operation" from file "plugins/Task/items.yml"
               set {_uuidl} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDLeast" from file "plugins/Task/items.yml"
               set {_uuidm} to yaml value "items.%{_itemid}%.AttributeModifiers.%loop-value%.UUIDMost" from file "plugins/Task/items.yml"
               add "{AttributeModifiers:[{AttributeName:""%{_atname}%"",Name:""%{_name}%"",Amount:%{_amount}%,Operation:%{_operation}%,UUIDLeast:%{_uuidl}%,UUIDMost:%{_uuidm}%}]}" to nbt of {_item}
          return {_item}
Try that
it doesn't work
 
Status
Not open for further replies.