Skip to content

Instantly share code, notes, and snippets.

@AjaxGb
Last active February 11, 2019 23:10
Show Gist options
  • Save AjaxGb/ad6119caa317a640b24d70c332d3ff91 to your computer and use it in GitHub Desktop.
Save AjaxGb/ad6119caa317a640b24d70c332d3ff91 to your computer and use it in GitHub Desktop.
Specification for a proposed /motion Minecraft command

The Short Version:

/motion <entity> vector <x> <y> <z>
/motion <entity> magnitude (set|add|scale) <value>
/motion <entity> copyfrom <entity2>
/motion <entity> toward <x> <y> <z> (add|set) none <strength>
/motion <entity> toward <x> <y> <z> (add|set) <scaling> <nearStrength> <farStrength> <nearRadius> <farRadius>
/motion <entity> test vector <xRange> <yRange> <zRange>
/motion <entity> test direction <xRotRange> <yRotRange>
/motion <entity> test magnitude <range>
/motion <entity> get (x|y|z|magnitude) [<scale>]

The Long Version:

/motion <entity> vector <x> <y> <z>
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • x y z: The motion to apply in vector form. The units are up to Mojang; blocks per second seems reasonable. Can use decimals and negatives. Can be relative, in which case the motion in that coordinate is added to the original motion.

Examples:

/motion @a vector 0 ~ 0

Stop players' horizontal movement, while allowing them to continue rising or falling.

/motion @e[type=zombie] vector ~ ~1 ~

Make all zombies jump into the air.


/motion <entity> magnitude (set|add|scale) <value>
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • set|add|scale: How to modify the magnitude of the target(s)'s speed. Either set it directly, add a value to it (or subtract if negative), or multiply it by some value. In any case direction will be maintained, and only magnitude will be changed.
  • value: The value to modify the magnitude with.

In all cases, if the magnitude is zero, the command fails.

Examples:

/motion @a magnitude scale 1.1

Cause all players to speed up slightly.

/motion @a[tag=flightBoost] magnitude add 5

Boost flying players without using invisible entities.


/motion <entity> copyfrom <entity2>
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • entity2: Specifies the entity to copy motion from. Must be a player name or a target selector, and must evaluate to a single entity.

Examples:

/execute as @a at @s run motion @s copyfrom @e[type=snowball,limit=1,distance=..3]

Cause players to mirror the motion of a nearby snowball.


/motion <entity> toward <x> <y> <z> (add|set) none <strength>
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • x y z: The block position toward which the target(s) should be thrown. Can be outside of the world, and can use decimals to target specific locations within a block. May use tilde notation, in which case the tildes are relative to the executor, not the target.
  • add|set: Either add this motion to the entity's current motion, or replace it entirely.
  • strength: The magnitude of the motion to apply. Can be a decimal. Can also be negative, in which case entities are flung away instead. As above, the units are entirely up to Mojang.

OR

/motion <entity> toward <x> <y> <z> (add|set) <scaling> <nearStrength> <farStrength> <nearRadius> <farRadius>
  • entity x y z add|set: As above.
  • scaling: How to scale the force. Must be one of the following:
    • none: No scaling. Force is applied as-is. See the above command spec.
    • linear: Targets that are inside the nearRadius have the nearStrength applied. Targets that are outside the farRadius have the farStrength applied. Targets that are in between have a strength between nearStrength and farStrength applied, using linear scaling.
    • Other options are possible (quadraticIn, quadraticOut, cubicIn, etc.) but might be unnecessary. All would behave like linear but with the specified easing function.
  • nearStrength farStrength: The strength applied inside the minimum radius and outside the maximum radius, respectively. There is no requirement that nearStrength be less than or greater than farStrength. Can be decimals. Can be negative.
  • nearRadius farRadius: Behave as described above. Can be decimals. Cannot be negative. nearRadius cannot be larger than farRadius.

In all cases, if the distance between the target and x y z is zero, no motion is applied.

Examples:

/motion @e[type=zombie] toward ~ ~ ~ add none -1

Throw all zombies away from the person who ran the command.

/execute as @e[tag=BlackHole] at @s run motion @a[distance=..30] toward ~ ~ ~ add linear 10 0 0 30

All players within 30 blocks of a "black hole" are sucked toward it. The closer they are, the stronger the pull.


/motion <entity> test vector <xRange> <yRange> <zRange>
/motion <entity> test direction <xRotRange> <yRotRange>
/motion <entity> test magnitude <range>
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • vector|direction|magnitude: Which part of the motion to test.  - vector: Test the x, y, and z components of the motion vector individually.  - direction: Test the direction in with the entity is moving, much like testing entity rotation. Motion of zero magnitude will always fail to match.  - magnitude: Find the magnitude of the motion vector, and test that.
  • xRange yRange xRotRange etc.: The bounds to test for. Uses the new 1.13 range syntax (2, 2.., ..4, 2..4). Can include decimals, can be negative.

The success count of the command is the number of entities that match.

Examples:

/motion @a[tag=MainPlayer] test magnitude 2..

Test if the "main player" is moving at least 2 blocks per second (or whatever the unit ends up being).


/motion <entity> get (x|y|z|magnitude) [<scale>]
  • entity: Specifies the target(s). Must be a player name or a target selector.
  • x|y|z|magnitude: Which part of the motion to return.
  • scale: Amount to scale the result by.

The result of the command is the motion component in question, scaled as appropriate.

Examples:

/execute as @a store result score @s speed run motion @s get magnitude

Store every player's speed in the scoreboard for further use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment