1. /execute as @a if entity @s[nbt={Inventory:[{id:"minecraft:name_tag",tag:{display:{Name:"{\"text\":\"portal_key\"}"}}}]}]
2. /execute if entity @p[distance=0..5]
I want to combine this two commands, but the problem that I have is that the first command for the whole map is executed by all players. But I'm looking for a command that only tests one area
and secondly, I would like to check the enchantment in the first command above with
1. /execute as @a if entity @s[nbt={Inventory:[{id:"minecraft:name_tag",tag:{display:{Name:"{\"text\":\"portal_key\"}"}}}]}]
2. /execute if entity @p[distance=0..5]
I want to combine this two commands, but the problem that I have is that the first command for the whole map is executed by all players. But I'm looking for a command that only tests one area
and secondly, I would like to check the enchantment in the first command above with
{Enchantments:[{id:"minecraft:infinity"}
(if the command is correct)
wish a nice day
Ok. A name tag enchanted with infinity. Since people cannot do this in survival, checking infinity is enough (no need to check the name).
If that's the case, here it is.
execute as @a[nbt={Inventory:[{id:"minecraft:name_tag",tag:{Enchantments:[{id:"infinity"}]}}]}] if entity @s[distance=..5]
Remember, the execution position isn't set. If you use this on chat, the distance argument will always find a player. Test this command on a repeated command block.
heyho,
I want to combine this two commands, but the problem that I have is that the first command for the whole map is executed by all players. But I'm looking for a command that only tests one area
and secondly, I would like to check the enchantment in the first command above with
(if the command is correct)
wish a nice day
Ok. A name tag enchanted with infinity. Since people cannot do this in survival, checking infinity is enough (no need to check the name).
If that's the case, here it is.
execute as @a[nbt={Inventory:[{id:"minecraft:name_tag",tag:{Enchantments:[{id:"infinity"}]}}]}] if entity @s[distance=..5]
Remember, the execution position isn't set. If you use this on chat, the distance argument will always find a player. Test this command on a repeated command block.