1
So I'm making a map with custom crafting and as far as I know it isn't possible to give a custom name for something in custom crafting so if you can tell me how to do this that would be great, otherwise how do you test for an item in someone's inventory with no name and then give them an item with a name. Then when they drop the item I want it to run setblock command. I am in 1.13 by the way.
Create an account or sign in to comment.
3
1
You're right: 1.13 custom crafting doesn't provide NBT tags for more customization (unfortunately).
How to test for items, fun question! It's actually not that much different from 1.12, well, "sorta" because as you probably know the /testfor command got shishkababed :D
On the good side though is that we got something much cooler in return!
So to try and keep bias out of my comment (apologies for the sillyness: I'm a good mood right now ;)) I shall concentrate on a randomly chosen 1.13 item: the Turtle Shell Piece.
Obviously Mojang did something wrong there because this should have been the "Shell shell" :D
Now, the really cool part about 1.13 is that we can actually combine several command aspects into 1 command. So....
give @p[nbt={Inventory:{id:"minecraft:turtle_shell_piece",Count:1b}]}] minecraft:turtle_shell_piece{display:{Name:"{\"text\":\"Shell shell\"}"}}
Dunno about you but this excites me. Unfortunately this isn't good enough. See, the problem is that once you gave a renamed shell you cannot easily take back the vanilla one. I can specify what the id or Name should be, but cannot negate that.
SO... Let's apply a little more 1.13 awesomeness.
Regular command block (but you'll probably want to change this to a repeating one eventually):
tag @p[nbt={Inventory:{id:"minecraft:turtle_shell_piece",Count:1b}]}] add hasshell
So now we marked the player who has a shell in his shell, errr: inventory :)
Chain command block, always active but it doesn't matter too much if you make this conditional or not (I suggest conditional):
clear @p[tag=hasshell] minecraft:turtle_shell_piece
So now we took back the item, next stop: replacement.
Chain command block as before (I suggest conditional):
give @p[tag=hasshell] minecraft:turtle_shell_piece{display:{Name:"{\"text\":\"Shell shell\"}"}}
This will give the replacement.
Finally, another chain command block:
tag @p[tag=hasshell] remove hasshell
And that will clear things up.
So when they drop the item you want to run a setblock command. hmm..
I may get back to you on that one. You'll need an /execute command.
/execute as @e[type=item,nbt={display:{Name:"{\"text\":\"Shell shell\"}"}}] at @s run setblock ~ ~-1 ~ minecraft:diamond_block
Yah, that no workie. Nor this:
/execute as @e[name="{\"text\":\"Shell shell\"}"] run say m000
This does work but seems wrong:
/execute as @e[type=item,name="Turtle Shell Piece"] run say m000
(if you pick it up it'll have the renamed name).
I think I hit a bug. I'll think this through and get back to you :)
How to test for items, fun question! It's actually not that much different from 1.12, well, "sorta" because as you probably know the /testfor command got shishkababed :D
On the good side though is that we got something much cooler in return!
So to try and keep bias out of my comment (apologies for the sillyness: I'm a good mood right now ;)) I shall concentrate on a randomly chosen 1.13 item: the Turtle Shell Piece.
Obviously Mojang did something wrong there because this should have been the "Shell shell" :D
Now, the really cool part about 1.13 is that we can actually combine several command aspects into 1 command. So....
give @p[nbt={Inventory:{id:"minecraft:turtle_shell_piece",Count:1b}]}] minecraft:turtle_shell_piece{display:{Name:"{\"text\":\"Shell shell\"}"}}
Dunno about you but this excites me. Unfortunately this isn't good enough. See, the problem is that once you gave a renamed shell you cannot easily take back the vanilla one. I can specify what the id or Name should be, but cannot negate that.
SO... Let's apply a little more 1.13 awesomeness.
Regular command block (but you'll probably want to change this to a repeating one eventually):
tag @p[nbt={Inventory:{id:"minecraft:turtle_shell_piece",Count:1b}]}] add hasshell
So now we marked the player who has a shell in his shell, errr: inventory :)
Chain command block, always active but it doesn't matter too much if you make this conditional or not (I suggest conditional):
clear @p[tag=hasshell] minecraft:turtle_shell_piece
So now we took back the item, next stop: replacement.
Chain command block as before (I suggest conditional):
give @p[tag=hasshell] minecraft:turtle_shell_piece{display:{Name:"{\"text\":\"Shell shell\"}"}}
This will give the replacement.
Finally, another chain command block:
tag @p[tag=hasshell] remove hasshell
And that will clear things up.
So when they drop the item you want to run a setblock command. hmm..
I may get back to you on that one. You'll need an /execute command.
/execute as @e[type=item,nbt={display:{Name:"{\"text\":\"Shell shell\"}"}}] at @s run setblock ~ ~-1 ~ minecraft:diamond_block
Yah, that no workie. Nor this:
/execute as @e[name="{\"text\":\"Shell shell\"}"] run say m000
This does work but seems wrong:
/execute as @e[type=item,name="Turtle Shell Piece"] run say m000
(if you pick it up it'll have the renamed name).
I think I hit a bug. I'll think this through and get back to you :)
1
Thank you very much for the reply! This part of the commands seems to not work.
@p[nbt={Inventory:{id:"minecraft:totem_of_undying",Count:1b}}]
I did replace Turtle shell piece with totem of undying.
@p[nbt={Inventory:{id:"minecraft:totem_of_undying",Count:1b}}]
I did replace Turtle shell piece with totem of undying.
1
And do you have a totem of undying in your inventory? I just tried this myself but can't reproduce any issues. For example:
/give @p[nbt={Inventory: [ {id:"minecraft:totem_of_undying",Count:1b}]}] minecraft:acacia_boat
Ah, I see what's up: in my previous post the forum somehow removed my []. Yeah, other people also warned me about this, but I didn't think it would happen with smaller commands.
So: @p[], is the first encapsulation. nbt={} is the second. Inventory:[] the third and within inventory (so the square brackets) you'll need the whole {id="minecraft:totem_of_undying",Count:1b}.
/give @p[nbt={Inventory: [ {id:"minecraft:totem_of_undying",Count:1b}]}] minecraft:acacia_boat
Ah, I see what's up: in my previous post the forum somehow removed my []. Yeah, other people also warned me about this, but I didn't think it would happen with smaller commands.
So: @p[], is the first encapsulation. nbt={} is the second. Inventory:[] the third and within inventory (so the square brackets) you'll need the whole {id="minecraft:totem_of_undying",Count:1b}.