# ๐ Move#

bs.move:_

Make your entity move exactly the way you want them to!

๐ฌ Watch a demo

In the universe, everything is mouvement.

โ Heraclite dโEphรจs

## ๐ง Functions#

You can find below all the function available in this module.

### Move using vector#

bs.move:by_vector

Allows to move the entity according to its vector on each axis of the game.

Inputs
(execution) as <entity>

The entity to move

(scores) @s bs.vector.[x,y,z]

The local vector you want the entity to move on (respectively left, up and forward vectors), shifted by 3 digits (1000 $$\rightarrow$$ move by 1 block)

(scores) @s bs.collision

The collision behavior. Here is built-in behaviors:

• 0 (default): The entity will cross all the blocks

• -1: The entity will bounce on all the solid blocks

• -2: The entity will stick and slide on the surface it will encounter

• -3: The entity will stick and stop on all the solid blocks

• -4: The entity will bounce on solid blocks and reduce the total speed by 2

• -101, -102, -103, -104 : same but useing head position instead of feet as the source of detection collision.

Option
(score) @s bs.opt.0

Precision of detection (in miliblock, so 500 -> 0.5 block). Default: 1000 (1 block)

Outputs
(state) @s position

The new position of the entity

Examples

Apply a movement of 0.3 blocks per tick in the X direction to all boats (simulating a sea current):

# Once
scoreboard players set @e[type=boat] bs.vector.x 300
scoreboard players set @e[type=boat] bs.vector.y 0
scoreboard players set @e[type=boat] bs.vector.z 0

# In loop
execute as @e[type=boat] run function bs.move:by_vector


Take into account collisions and make the boat stop, with a precision of 0.1 block:

# Once
scoreboard players set @e[type=boat] bs.vector.x 300
scoreboard players set @e[type=boat] bs.vector.y 0
scoreboard players set @e[type=boat] bs.vector.z 0
scoreboard players set @e[type=boat] bs.collision 2
scoreboard players set @e[type=boat] bs.precision 100

# In loop
execute as @e[type=boat] run function bs.move:by_vector


Performance tip

Moving an entity using this system is pretty efficient because it only consist in 50 to 100 commands such as scoreboard operation and teleport, which doesnโt cost a lot. However, collision detection is from far the heaviest part due to block detection. A higher precision or a higher speed will increase the number of block detection and then the impact on performances.

bs.move:by_local_vector

Allows to move the entity according to its vector on each axis of the local reference frame.

Inputs
(execution) as <entity>

The entity to move

(scores) bs.vector.[x,y,z]

The local vector you want the entity to move on (respectively left, up and forward vectors), shifted by 3 digits (1000 $$\rightarrow$$ move by 1 block)

Outputs
(state) @s position

The new position of the entity

Example

Apply a movement of 0.3 blocks per tick to the left to all boats:

# Once
scoreboard players set @e[type=boat] bs.vector.x 300
scoreboard players set @e[type=boat] bs.vector.y 0
scoreboard players set @e[type=boat] bs.vector.z 0

# In loop
execute as @e[type=boat] run function bs.move:by_local_vector


Performance tip

The system does not include any speed limit. However, the resources consumed by this function are proportional to the number of blocks/tick at which the entity moves.

Credits: Leirof

### Move forward#

forward: Allows to move the entity according to the direction towards which it looks and its vector bs.vector.z

• A vector of 1000 on an axis will cause a movement of one block at each execution of the function.

• The sum of the movements on each axis will give a movement in space (thus in 3 dimensions), corresponding to the global vector of the entity.

• The system takes as input the 3 scores bs.vector[Left,Up,Front] (1000 <=> 1 block).

Warning

The system does not include any speed limit. However, the resources consumed by this function are proportional to the number of blocks/tick at which the entity moves.

Example:

• Apply a movement of 0.3 blocks per tick forward to all boats:

# Once
scoreboard players set @e[type=boat] bs.vector.z 300

# In a loop
execute as @e[type=boat] run function bs.move:forward


Credits: Leirof

### Find a path โas to atโ#

pathfind_ata: Allows to determine a path between the position of the source entity and the execution position of the function.

• By default, the function will make 500 tests (defined via the bs.in.1 score). This limit allow to avoid the function taking too many ressources if the path is too complexe or impossible to find.

• The behavior is defined by the variable bs.in.3 which, by default is 0, corresponding to a behavior of a zombie, creeper, skeleton or a player (terrestrial entity of size 121).

• When it is set to 1, the behavior will be similar to a bat.

• You can create your own behaviors at any time in the pathfind/config/ folder and link them in the main.mcfunction file in the same folder.

• The path is then defined by a succession of armor_stand with the tag โGlib_Pathfind_Rewindโ and โGlib_Pathfindโ.

Example:

• Find the path to the nearest armor_stand:

# Once
execute at @e[type=minecraft:armor_stand,limit=1,sort=nearest] run function bs.move:pathfind_ata


Watch the video

Credits: Leirof

### Convert vector to motion#

vector_to_motion: Allows to move the entity according to its vector through a motion (motion system integrated in the game).

• A vector of 1000 on an axis will move a block at each tick of the game.

• The sum of the movements on each axis will give a movement in space (thus in 3 dimensions), corresponding to the global vector of the entity.

Note

This system admits a speed limit corresponding to that of the Motions. Moreover, the entity will have by default a collision system preventing it from crossing blocks. Moreover, adding Marker, NoAI, NoGravity tags can block this system. Collisions are integrated in this system but are not very reliable and therefore not recommended. Only activated when the entity has a Collision score greater than 1 (each value corresponds to a type of collision). You can modify the collision reactions or create your own in the by_vector/config/collision/ folder. By default, the precision of the collisions, stored on the Var5 score, is 500 (= 0,5 blocks).

Credits: Leirof