1

Testing for a certain item on the ground and in someone's inventory.

_JK47_'s Avatar _JK47_2/14/18 7:05 pm
1 emeralds 5.4k 3
2/15/2018 12:38 pm
ShelLuser's Avatar ShelLuser
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.
Posted by _JK47_'s Avatar
_JK47_
Level 1 : New Network
0

Create an account or sign in to comment.

3

1
02/14/2018 8:38 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
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 :)
1
02/15/2018 12:25 pm
Level 1 : New Network
_JK47_
_JK47_'s Avatar
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.
1
02/15/2018 12:38 pmhistory
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
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}.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome