is it possible to create such a command that the pig, approaching the door, puts redstone_torch causing the door to open and when it leaves the block with the torch, it immediately destroys?
/execute if entity @e[type=pig,x=first number of coordinates,y=second number of coordinates,z=thirth number of coordinates,distance=..distance in number of blocks] run setblock all free number of coordinates where you want to put redstone torch redstone_torch
this should be for placing torch.
then to remove that torch -
/execute if entity @e[type=pig,x=first number of coordinates,y=second number of coordinates,z=thirth number of coordinates,distance=distance in number of blocks..50] run setblock all free number of coordinates where you want to put redstone torch air
be aware of those points in distance=..number and distance=number.., one is that number or less and other is that number or more.
number 50 after those 2 points is just to not detect something far away, you can choose completly different number there.
also, run it in repeat command block, that is always active.
is it possible to create such a command that the pig, approaching the door, puts redstone_torch causing the door to open and when it leaves the block with the torch, it immediately destroys?
/execute if entity @e[type=pig,x=first number of coordinates,y=second number of coordinates,z=thirth number of coordinates,distance=..distance in number of blocks] run setblock all free number of coordinates where you want to put redstone torch redstone_torch
this should be for placing torch.
then to remove that torch -
/execute if entity @e[type=pig,x=first number of coordinates,y=second number of coordinates,z=thirth number of coordinates,distance=distance in number of blocks..50] run setblock all free number of coordinates where you want to put redstone torch air
be aware of those points in distance=..number and distance=number.., one is that number or less and other is that number or more.
number 50 after those 2 points is just to not detect something far away, you can choose completly different number there.
also, run it in repeat command block, that is always active.
i hope i know that right xd