2

Help with some commands

Toshnika 5/4/20 1:57 am
171
5/4/2020 3:06 am
so I have this command:

/execute as @e[type=minecraft:item,distance=1,limit=1] run data modify block -154 136 285 Lock set from entity @s Item.tag.display.Name

which is meant to lock a chest with the lock being the name of the item. However, the chest is not locked, and even from a command block I get no feedback. Any tips?
Posted by
Toshnika
Level 33 : Artisan System
6

  Have something to say?

JoinSign in

2

Bertiecrafter
05/04/2020 3:06 am
Level 72 : Legendary System
history
Unfortunately, the tag.display.Name is a JSON text component, while the Lock tag is plain string.

So when you rename an item in an anvil to "Key", the actual tag value will be '{"text":"Key"}'

When you lock a chest with "Key", you can open it with any item named Key, regardless of the JSON structure.

The problem with your command is that the chest Lock value will be '{"text":"Key"}' which only works if you actually type that code into an avil. Which obviously isn't what you want. Unless I'm wrong on what I just said (do comment if I am), there is no way of letting survival players pick their own key name. Maybe if you straight up put "Key" into the display.Name tag with a command (/give @s stick{tag:{....}}) it could work, but not sure.
2
Magneter102
05/04/2020 2:24 am
Level 41 : Master Princess
[​distance=1] would mean that the entity has to be exactly 1 block away. I assume you wanted to use [​distance=..1] , the two dots making it a maximum 1 block distance. Changing it should most likely fix it.
3

Welcome