execute if item in an item_frame is in a certain position in minecraft 1.16

Solution 1:

So I think you mean to make the player "turn" the structure void.

Because you can test for item_frame specifically the only thing needed to be in the nbt selector is the ItemRotation.

This command will properly execute when the entity in the target location is an item frame with the item rotation as 2:

execute if entity @e[type=minecraft:item_frame,x=269,y=66,z=533,dx=0,dy=0,dz=0,nbt={ItemRotation:2b}]

I also used this command to summon the item frame:

/summon minecraft:item_frame 269 66 533 {Facing:2b,Invulnerable:1b,Invisible:1b,ItemRotation:1b,Item:
{id:"minecraft:structure_void",Count:1b}}

Remember that when the item is rotated the correct way if your using a repeating command block the command will execute 20 times a second until the item is turned again. I would recommend making an off switch with another rotation such as ItemRotation:6b that would turn of the water. This way you could test for when the rotation is 2 and this would place a Redstone block next to some other command blocks that would remove the power source to the first command block. and would activate the water as well as activate the command block with the off switch command.

Example command:

execute if entity @e[type=minecraft:item_frame,x=269,y=66,z=533,dx=0,dy=0,dz=0,nbt={ItemRotation:2b}] run setblock x y z redstone_block

Then the command block line:

activate water

Next command block:

place Redstone block at the execute command block that tests for the ItemRotation:6b

Then remove the Redstone block that the first command block placed, so this can be repeated.

You would need to do this for when it tests for the 2:nd rotation and have another line of command blocks placing a Redstone block next to the command block testing for ItemRotation:2b.

The left one has ItemRotation of 0 and the right one has 1. 2, 4, 6 will show the same as 0 as well as 3 5 7 will show the same as 1. ItemRotation

Solution 2:

It works!!! Thank you so much! Even numbers start the water and odd numbers stop it again, just like i wanted! Great!!!

water-tower