a minecraft command that tests if an item with an nbt tag is touching another item

Okay so I am trying to run a Minecraft command that tests if an item with an nbt tag is touching another item I have tried /execute if entity @e[nbt={id:"minecraft:oak_planks"}] at @e[name=Glowstone] run time set day I also tried /execute if entity @e[nbt={Count:1b}] at @e[name=Glowstone] run time set day but both do not work can anyone tell me what I am doing wrong.

1

1 Answer

As Fabian Röling pointed out, your question isn't super clear, so this answer is based on my understanding of what you want:

If you want to test for an item entity 'touching' another item entity, you will need to test to see if the second one is within a certain radius of the first. To do this, use an execute command, executing at the position of the first item, and testing if there is the second entity nearby:

execute as @e[type=item,nbt={Item:{id:"minecraft:oak_planks"}}] at @s if entity @e[type=item,distance=..<radius>,nbt={Item:{id:"minecraft:glowstone"}}] run ...

Depending on how selective you want this command to be, you can choose your own <radius> value (make sure to leave the .. right before <radius>, because it means 'less than or equal to' your radius; without it, the items will need to be exactly <radius> blocks apart for it to work). I found 0.5 to be a good radius value. You can add more filters to the selectors to adjust the command to your own preferences.

Additionally, I strongly recommend that you visit this page, which might help you learn more about how commands work.

You Might Also Like