1.13+ how do you get the slot NBT tag for /give? [duplicate]
So, I'm working on a little arena map for my friends and me and I need to give a weird invisibility totem. The person should get five and It consumes all of them at once if I stack them so I need to spread the out in the hotbar. I am using /give to give all five and am using 5 different command blocks. I am using a separate detection system for each totem but this is the command I have so far:
give @a[scores={assassin=1..}] minecraft:wither_skeleton_skull{slot:1b,display:{Name:"{\"text\":\"Invisibility Totem\",\"color\":\"gray\",\"strikethrough\":\"true\"}"}} 1
It's the part at the beginning of the NBT tags that says: slot:1b, the command works perfectly otherwise. Anyone know what I should use there or if they still have this in the game as of 1.13?
I think the replaceitem command will suit you, since the give command gives out an item as if the player picks it up.
/replaceitem entity @a[scores={assassin=1..}] inventory.0 minecraft:wither_skeleton_skull{display:{Name:"{\"text\":\"Invisibility Totem\",\"color\":\"gray\",\"strikethrough\":\"true\"}"}} 1
The way the /give
command works is by throwing you the item specified. If it's a non-stackable item, you'll pick it up as if it were a sword, but if it's a stackable item, you'll pick it up as if it were something like planks. In order to prevent that from happening is by using the /replaceitem
command. Like so:
/replaceitem entity @a[scores={assassin=1..}] container.4 minecraft:wither_skeleton_skull{slot:1b,display:{Name:"{\"text\":\"Invisibility Totem\",\"color\":\"gray\",\"strikethrough\":\"true\"}"}} 1
You'll still need to use 5 command blocks as the slot container.4
will change to container.5
, container.6
and so on.
Hope this helps!