forum Forumsplay_arrow Minecraft fiber_manual_record Redstone


Get Player Motion?

2 emeralds2 replies90 views
created 10/17/2018 9:54 pm by Cadermate
last reply 10/21/2018 9:56 am
So, 1.13 brought new commands, and I wanted to store player motion to a scoreboard for manipulation. However, when I attempt to store the X motion of the player (Motion[0]), it only stores to the scoreboard when sprint jumping. Why does this occur and how can I fix it? The command I used is shown below:

execute store result score @a Xmotion run data get entity @a[sort=nearest,limit=1] Motion[0] 100000
Posted by avatar
Level 9 : Apprentice Engineer

2 replies

10/20/2018 1:35 am
Level 9 : Apprentice Engineer
The reason that this is happening is because it's a bug. Now considering that it was resolved as "Won't Fix", I don't think that Mojang is going to fix it anytime soon. However I did try to come up with a workaround and I think that I've succeeded.

scoreboard objectives add Xmotion1 dummy
scoreboard objectives add Xmotion2 dummy
scoreboard players set #-1 Xmotion1 -1

Clock Commands
execute as @a run scoreboard players operation @s Xmotion2 = @s Xmotion1
execute as @a store result score @s Xmotion1 run data get entity @s Pos[0] 71
execute as @a run scoreboard players operation @s Xmotion2 -= @s Xmotion1
execute as @a run scoreboard players operation @s Xmotion2 *= #-1 Xmotion1

Getting the motion
Xmotion2 will be equal to the players motion. So you can simply use it.

Minor notes
In the second clock command, You can't use a scale larger than 71 without this setup breaking near the worldborder(roughly 30 million blocks out). The reason this happens is because scoreboards can only have a value up to the 32 bit integer limit. Any scale that is 72 or larger will result in a number larger than that limit.

I'm also not sure about how accurate this actually is as I can't get the players motion to compare with. However, it does seem to be close to what you are wanting.

10/21/2018 9:56 am
Level 9 : Apprentice Engineer
Thanks, this was what I needed. I wish they would fix that bug though. I’m making a portal gun and needed to conserve momentum through portals. (I probably won’t need absolute value though) Also, a scale of 71 should be fine.




© 2010 - 2019