I went to a few other questions like this, regarding the rotate command, but none of them answered my question... I have the command:

/execute @e[r=10000] ~ ~ ~ detect ~ ~-2 ~ minecraft:coal_block 0 /tp @p ~ ~ ~ 360 0

And it is doing pretty much exactly what I want it to do - rotate a player when they walk 2 blocks above a coal block. HOWEVER, it is not rotating them 360 degrees from their current position, it is rotating them to the direction (which in this case is positive y/south) of the command block with the above command. Is there any way to navigate around this problem?


  • ~360​​​​​​​​​​ – Aequitas Dec 11 '15 at 3:02
  • 1
    You know 360 is a full circle right? so ~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
  • ahha, right :P Would you mind giving me an example for the command? Sorry – SMILIECHICKEN Dec 11 '15 at 3:19
  • I don't really know you'd have to set up the tp part in a loop somehow, I don't know much about minecraft, so couldn't be more specific than that – Aequitas Dec 11 '15 at 3:23
  • Ah, okay, thanks for the help though! And I already have it in a loop, just the command might have something to do with it. :D – SMILIECHICKEN Dec 11 '15 at 3:29

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.

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.