Solved How to use nbt tags on items

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

Jack57320

Member
Jun 19, 2018
13
0
0
24
Hello
I've got a problem i'm trying to drop an item with a custom name and make this name visible and other options

I've this code
code_language.skript:
drop 1 stone hoe with custom nbt "{CustomName:""&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}" at {SpawnOFPistolV2}

It doesn't work, this error appears """"&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}" at ?{SpawnOFPistolV2}' is not a valid item data (Ameliorateur.sk, line 249: drop 1 stone hoe with custom nbt "{CustomName:""&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}" at ?{SpawnOFPistolV2}')"

Could you please help me ?

Thanks
 
Try using SkStuff and maybe use this, but I didnt test it
code_language.skript:
drop 1 stone hoe with at {SpawnOFPistolV2}
add nbt "{CustomName:""&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}" to last spawned entity
 
Hey thanks for your reply
i've this message ! (minecraft 1.12.2 and last version of skript and skstuff)
 

Attachments

  • Sans titre.png
    Sans titre.png
    133.5 KB · Views: 790
Hey thanks for your reply
i've this message ! (minecraft 1.12.2 and last version of skript and skstuff)
I know that that gives an error, but if it is an actual error, I have no idea how to fix that. If it's just a message ignore it, because the error is about the custom name, so you can try adding this:
code_language.skript:
set display name of last spawned entity to "Something"

Whole code:
code_language.skript:
drop 1 stone hoe with at {SpawnOFPistolV2}
add nbt "{NoGravity:1b}" to last spawned entity
set display name of last spawned entity to "&2Pistolet&cV2"
 
It's maybe the fault of the version i've there. Because the item spawn well but nothing change on it

Don't worry i'll find an answer on the web

Thanks
 
The syntax is: add "{stuff}" to NBT of last spawned entity. The error message is misleading but you got the syntax wrong (unless that's an alternate syntax that I'm not aware of!)
 
The syntax is: add "{stuff}" to NBT of last spawned entity. The error message is misleading but you got the syntax wrong (unless that's an alternate syntax that I'm not aware of!)

As Mr_Simba said, the correct syntax is:

code_language.skript:
add "{nbtTag}" to nbt of last spawned entity

So your code would be something like this (Not tested):

code_language.skript:
drop 1 stone hoe at {SpawnOFPistolV2}
add "{CustomName:""&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}" to nbt of last spawned entity
 
Actually for dropped items the NBT is stored at a deeper level, so if you want to add NBT to the items within a dropped item entity with just SkStuff you'd have to do this:
code_language.skript:
drop 1 stone hoe at {SpawnOFPistolV2}
add "{Item:{tag:{CustomName:""&2Pistolet&cV2"",CustomNameVisible:1,NoGravity:1b}}}" to nbt of last spawned entity
 
Status
Not open for further replies.