I'm trying to replace the block underneath where I throw two items on with a beacon (block). The two items I am trying to throw, respectively, are a custom nether star and a beacon (item).

Here are my commands:

execute as @e[type=item,nbt={Item:{id:"minecraft:nether_star",Count:1b,tag:{display:{Name:'[{"text":"Warp Stone","italic":true}]'}}}}] if entity @e[type=item,distance=..1,nbt={Item:{id:"minecraft:beacon",Count:1b}}] run function warp_shrines:create_shrine

and my function warp_shrines:create_shrine is as follows:

setblock ~ ~-1 ~ minecraft:beacon

Simple enough, but it doesn't work with the first command. What does work is if I run this command:

execute as @e[type=item,nbt={Item:{id:"minecraft:nether_star",Count:1b,tag:{display:{Name:'[{"text":"Warp Stone","italic":true}]'}}}}] at @s run function warp_shrines:create_shrine

which is just the top command without the "if entity" qualifier, meaning that I'm not detecting if those two items are on the same block correctly. Is my syntax/logic wrong, or do I need to figure out a workaround for this?


Just combine the 1st and 3rd commands. You need to add at @s without removing the 2nd if entity.

You'll need to put at @s between the first item and the second item in the 1st command. (see the section marked BOLD)

...{Name:'[{"text":"Warp Stone","italic":true}]'}}}}] at @s if entity @e[type=item,distance=..1,...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.