You have to use a combination of relative rotational coordinates and a scoreboard objective. The latter is to ensure that players are only rotated once per stepping above a coal block.
Fancy single objective solution
Set up your objective as:
/scoreboard objectives add overCoal dummy
On a 20Hz. clock, run the following commands to set the score:
/execute @a[r=10000] ~ ~ ~ detect ~ ~-2 ~ minecraft:coal_block 0 scoreboard players add @a[c=1] overCoal 3
/scoreboard players remove @a[score_overCoal_min=1] overCoal 2
/scoreboard players set @a[score_overCoal_min=3] overCoal 2
/scoreboard players set @a[score_overCoal=-1] overCoal 0
This might look confusing at first, what with adding 3 and subtracting 2, but it does the trick. Basically, every tick the player is above a coal block, his score is incremented by +3-2=+1, but only to a maximum of 2 (3rd command). The moment the player steps off, the score decreases by 2 (thereby avoiding the value of 1), to a minimum of 0 (4th command).
This means that after these 4 commands are run, the score is:
- 0 if the player is not above a coal block.
- 1 if the player has been above a coal block for exactly 1 tick.
- 2 if the player was above the coal block for longer.
All that is left is to put a command to rotate the players with a score of exactly 1:
/tp @a[score_overCoal=1,score_overCoal_min=1] ~ ~ ~ ~<R> ~
where <R>
is the amount of degrees you want to rotate the player.
Simpler 2 objective solution
If the above solution was too confusing for your taste, a more intuitive way is to use 2 objectives:
/scoreboard objectives add overCoal dummy
/scoreboard objectives add overCoalTime dummy
On a 20Hz. clock, run the following commands to set the score:
/scoreboard players set @a overCoal 0
/execute @a[r=10000] ~ ~ ~ detect ~ ~-2 ~ minecraft:coal_block 0 scoreboard players set @a[c=1] overCoal 1
/scoreboard players set @a[score_overCoal=0] overCoalTime 0
/scoreboard players add @a[score_overCoal_min=1] overCoalTime 1
This achieves basically the same as above, but for overCoalTime
instead.
~360
– Aequitas Dec 11 '15 at 3:02~360
will be the same as~
. You'll need to have it set up to repeat x times and rotate them 360/x degrees each time. – Aequitas Dec 11 '15 at 3:10