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.
To do this you would need a few command blocks for each item you want to make unbreakable. To identify the player who has the item in their inventory we are going to use scoreboards. In this example we will use a diamond sword but you can change wherever it syas diamond sword to whatever item you would like.
Setup
run this once:
/scoreboard objectives add hasItem stat.craftItem.minecraft.diamond_sword
Detection
put this in a repeating command block:
/testfor @a[score_hasItem_min=1]
Execution
Using a comparator, run these commands when a player is found:
/clear @a[score_hasItem_min=1] minecraft:diamond_sword 0
/give @a[score_hasItem_min=1] minecraft:diamond_sword 1 1 {Unbreakable:1b}
/scoreboard players reset @a hasItem
Layout
Here is my layout:
Where the commands are from 1 - 4:
/testfor @a[score_hasItem_min=1]
/clear @a[score_hasItem_min=1] minecraft:diamond_sword 0
/give @a[score_hasItem_min=1] minecraft:diamond_sword 1 1 {Unbreakable:1b}
/scoreboard players reset @a hasItem
Best Answer
If your structure is 32*32*32 or lesser, use a structure block to save the structure, then load up its rotated form
Read about using it here
Click here
To See a Video Tutorial on using it(Made during the snapshots before its release)