#Custom NBT

1 messages · Page 1 of 1 (latest)

digital birch
#

Docs:

custom nbt of %item% = Returns the 'minecraft:custom_data' component of an item's NBT. Modifying this will modify the original item. (This is an MC 1.20.5+ feature).
Please see Data Component Format on McWiki for more information on item NBT components.```
minecraft command:

/item replace entity @p hotbar.8 with stick[custom_data={test1:1,test2:2}] 1```
Skript:

command /test:
    trigger:
        set {_item} to player's inventory's slot 8
        set {_nbt::*} to custom nbt of {_item}
        broadcast {_nbt::*}```
I'm trying to get all the custom data values as a list in {_nbt::*}
The best solution I can think of is
#
command /test:
    trigger:
        set {_item} to player's inventory's slot 8
        set {_custom} to custom nbt of {_item} #forgot to add this earlier
        set {_custom} to the last length of {_custom} - 1 characters of {_custom}
        set {_custom} to the first length of {_custom} - 1 characters of {_custom}
        set {_nbt::*} to custom nbt of {_custom} split at ","
        broadcast {_nbt::*}```
Is there a better way to do it?
rose knot
#

Uhh

#

You cant set a local var to something dependent on itself, as the local var hasnt been defined yet

digital birch
rose knot
#

You can check out the skbee wiki, ypu might want to use a list tag or something

digital birch
rose knot
#

so you want to individually add each tag to the list

digital birch
#

Previously I used lore of items

#

I want to now upgrade things

#

And saw that 1.21.4 offers custom_data and that SkBee supports it

#

There aren't many examples of it so I wanted to make a new help thread to understand them better

digital birch
rose knot
digital birch
# rose knot for like damage and defence stats?

kinda. More like for those things:

projpenetration=
projdamage=
projdamagepenalty=
projspeed=
projbounce=
projlifetime= 
projeffect=
projeffectrange=
projtrail=
projareadamage=
projareaknockbackrange=
projareaknockbackforce=
projheadshot=```
rose knot
#

so then why not just check the tags

digital birch
#

I was using tags but editing them was HELL

digital birch
rose knot
#

okay..

digital birch
#

I can do split at "=" and create local variables for each one

rose knot
#

so you want to get all the tag names in an NBT compound

digital birch
#

Like adding, editing or modifying properties

#

custom_data seems like a way to go

#

I just want to know how can I turn contents of custom_data into the list {_list::*}

#

To edit them

rose knot
#

and what's wrong with just NBT?


add 10 to (int tag "example" of {_NBT})

set (string tag "somethingElse" of {_NBT}) to "imEditingStuff"```
digital birch
#

Hopefully

#

Where?

rose knot
#

cause then you'd have to move the list back to the NBt anyways

digital birch
#

Yeah - that's why I asked here generally for help

#

Because I saw my method flawed

#

And wanted to improve it

digital birch
digital birch
# rose knot cause then you'd have to move the list back to the NBt anyways
command /test:
    trigger:
        set {_item} to player's inventory's slot 8
        set {_metal1::*} to compound list tag "minecraft:custom_model_data;strings" of {_nbt}
        set {_metal2::*} to (compound list tag "minecraft:custom_model_data;strings" of nbt of {_nbt})
        set compound list tag "minecraft:custom_model_data;strings" of {_nbt} to {_metal3::*}
        set {_nbt} to nbt compound of {_item}
        set compound list tag "minecraft:custom_model_data;strings" of nbt of {_nbt} to {_metal4::*}
        broadcast {_nbt}
        broadcast "<green>%{_metal1::*}%"
        broadcast "<yellow>%{_metal2::*}%"
        broadcast "<gold>%{_metal3::*}%"
        broadcast "<red>%{_metal4::*}%"```
#

tried with and without minecraft: in all cases

#

what am I doing wrong?

#

I can't even get simple values like "2", "0", "0"

digital birch
digital birch
#
        set {_s1} to string tag "minecraft:custom_model_data;strings[0]" of {_nbt}
        set {_s2} to string tag "minecraft:custom_model_data;strings[1]" of {_nbt}
        set {_s3} to string tag "minecraft:custom_model_data;strings[2]" of {_nbt}
        broadcast "{_s1} %{_s1}%"
        broadcast "{_s2} %{_s2}%"
        broadcast "{_s3} %{_s3}%"```
#

this one works

digital birch
digital birch
#
#

okay