How do I test when a player moves forward?
I'm working on a one command creation called Magical Weapons. There's a weapon called the Reverse Crystal, and it basically reverses the movement. If you move +1 on the x-axis, you are teleported -2 on the x-axis, and so on and so forth. But how do I test for when a player moves, like +1 X or -1 Z?
Best Answer
I made a movement detection system a while ago that I think could be useful for this. You can use it as a reference or modify it to fit your creation.
You will need 1 repeating command block and 15 chain command blocks connected to it (all set to always active). Here are the commands: https://pastebin.com/445LRfFz
And here is the system in action:

it stores the player's current position into some scoreboard objectives (x and z). Then, it constantly compares the player's x objective to the player's prev_x objective to see if there are any changes. If x is greater than prev_x, that means the player has moved towards positive x. I also made it so it tags the player with "x+" and then says "x+" in chat.
Pictures about "How do I test when a player moves forward?"



WHEN To Move FORWARD In Padel!
More answers regarding how do I test when a player moves forward?
Answer 2
I redid the command blocks and got a much better, but still not excellent solution:
Now, what the command blocks have:
1:
/testfor @e[type=ArmorStand]
2:
/execute @a ~ ~ ~ testfor @e[type=ArmorStand,r=0]
3:
/execute @a ~ ~ ~ summon ArmorStand ~ ~ ~
4:
/kill @e[type=ArmorStand]
5:
/tp @a @e[type=ArmorStand]
Notes:
- Sorry for not using the 1.9 Command blocks, because I really don't know how to do this with them.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pixabay, RODNAE Productions, RODNAE Productions, RODNAE Productions

