2

Get Player Motion?

Cadermate's Avatar Cadermate10/17/18 9:54 pm
2 emeralds 1.6k 2
10/21/2018 9:56 am
Cadermate's Avatar Cadermate
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 Cadermate's Avatar
Cadermate
Level 16 : Journeyman Engineer
0

Create an account or sign in to comment.

2

2
10/20/2018 1:35 amhistory
Level 29 : Expert Engineer
SUPERIONtheKnight
SUPERIONtheKnight's Avatar
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.

Prerequisites
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.

~SUPERIONtheKnight
2
10/21/2018 9:56 amhistory
Level 16 : Journeyman Engineer
Cadermate
Cadermate's Avatar
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.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome