#nbt path for Selected item display name (1.21.1)
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1732221151:t>, feel free to use the Summon Helpers button to ping our helper team.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
SelectedItem.components."minecraft:item_name"
The name that is displayed can come from multiple components or may not even be in its nbt (if it’s not changed)
it has been changed
If it's been changed in an anvil then it's custom_name
You can always look at the data using the command you used and follow it from there.
To get "c", you'd use a.b
{"a": {"b": "c"}, "d": "e"}
And that way you can navigate to the correct component
ohhh i got u
how would i make this look better
becuase i want it to just say SPELL NAME
In a text component you can try and add "interpret": true
Is this in the actionbar?
Because there you are probably using a text component, like {text:"Something"} and just like "text" you can add "interpret"
Or that, yep
lol thanks i never even noticed it
ive turned interpret to true and now its not displaying anything
im so confused its just stopped working now
nvm i got it now i think
im sorry im having a hard time under standing this, would u be able to give me a example
would this also work for other characters like "["
You know how snbt (the thing you see when using a data get for example) is a bunch of key value pairs?
The path just "follows" these keys
So item.components.minecraft:custom_name
looks at the whole nbt, then goes into the "item" key. In there it looks for a "components" key and so on
ohhhhh i miss understood that
For arrays [] it works slightly differently
[0] selected the first element (they start at 0)
[5] selected the 6th element and so on
[-1] selects the last element
[-3] the third from the end and so on
You can also do something like [{slot:0b}] which returns all elements that have a "slot" key that is set to 0b
A path like that looks like
something.array[12]
And you can follow up like you’d expect array[12].data.id
when u say "element" what is that refering to?, is it just the context of the datapath?
like if i was looking for selectedslot [2] it would be slot 2
im guessing thats prob fomatted wrong but u get the idea
Maybe an example helps
Data:
{array:[a,b,c,d,e]}
Path:
array[0] => a
array[2] => c
array[-1] => e
array[-3] => c
And these letters could also be numbers, objects, arrays or anything else
I think they need to be the same data type though
So all floats, all strings or all objects and so on
You can also try these out if you have the game open, that may help you to get used to it
/data get entity @s Inventory[{Slot:0b}].id
this would for example get the id of the item in your first hotbar slot
Do you have an item in your first hotbar slot?
Ah I think slot is still capitalised: Slot
Unlike count, which was turned to lowercase
there we go, it worked now
Minecraft is so inconsistent lol
the capitalation (ignore spelling) throws me to often lol
I had that first and changed it 🙈 I thought they had updated it with all other item stuff - it’s so weird how the capitalization is very off since they are making it all lowercase now
it threw me so long when they changed effect ids
I'm surprised they didn't change it to slot when they changed count
lmao
Probably because it’s inventory logic and not item stack logic 🤔
🤷 we will never know, mojangs ways are beyond us :D
since ur both here lol, how would i go about separating this from the name to use in other commands
im trying to make a spell creation system, i wanted to originaly use a writeable book but i couldnt be arsed to make an id system and storage for all the players, im using ameythyst shards
i wanted it so the "[1-2-3-4]" is the fomula if that makes sense
i can make a separate post if u want lol
You can use data … string, it’s not that straightforward though
would i have to throw it in to a storage system?
Yeah, item -> storage and then you can execute if data storage or use a macro
howd i do it using a macro, i cant be bothered to make a id based storage system
It’s pretty much a string replacement for commands
I think it’s probably best if you start a new post, it almost midnight for me and I gotta get up early ^^
And Gears is also European
You gotta watch out for unclean user input, esp if the users are writing the spell ids themselves
If your question is resolved, that's great to hear! Make sure to run /resolve or click the Resolve Question button. Otherwise, feel free to continue asking for help! :D