Skip to main content
Ctrl+K
โš ๏ธ You are reading a doc of an undergoing development version. Information can be out of date and/or change at any time. โš ๏ธ
Logo image

Bookshelf

Site Navigation

  • ๐Ÿ‘‹ Getting Started
  • ๐Ÿงฉ Modules
  • ๐Ÿค Contribute
  • โ“ FAQ
  • ๐Ÿ”ง Changelog
    • โค๏ธ Special thanks
  • GitHub
  • Download
  • Support us
  • Gunivers
  • Discord server

Site Navigation

  • ๐Ÿ‘‹ Getting Started
  • ๐Ÿงฉ Modules
  • ๐Ÿค Contribute
  • โ“ FAQ
  • ๐Ÿ”ง Changelog
    • โค๏ธ Special thanks
  • GitHub
  • Download
  • Support us
  • Gunivers
  • Discord server

Section Navigation

All modules

  • โ›ฐ๏ธ Biome
  • ๐Ÿ–ฅ๏ธ Bitwise
  • ๐Ÿงฑ Block
  • ๐ŸŽจ Color
  • โš™๏ธ Core
  • โค๏ธ Health
  • ๐Ÿท๏ธ ID
  • โ›๏ธ Item
  • ๐Ÿ”— Link
  • ๐Ÿ“„ Log
  • ๐ŸŒ MapEdit
  • ๐Ÿงฎ Math
  • ๐Ÿƒ Move
    • by_vector custom collision
  • ๐Ÿงญ Position
  • โฒ๏ธ Schedule
  • ๐Ÿ“ฐ Sidebar
  • โŒš Time
  • ๐ŸŒณ Tree
  • โ†—๏ธ Vector
  • ๐Ÿ‘€ View
  • โ›… Weather
  • ๐Ÿ… XP

Filter by content

  • ๐Ÿ“š Libs
    • โ›ฐ๏ธ Biome
    • ๐Ÿ–ฅ๏ธ Bitwise
    • ๐Ÿงฑ Block
    • ๐ŸŽจ Color
    • โค๏ธ Health
    • ๐Ÿท๏ธ ID
    • โ›๏ธ Item
    • ๐Ÿ”— Link
    • ๐Ÿ“„ Log
    • ๐ŸŒ MapEdit
    • ๐Ÿงฎ Math
    • ๐Ÿƒ Move
      • by_vector custom collision
    • ๐Ÿงญ Position
    • โฒ๏ธ Schedule
    • โŒš Time
    • โ†—๏ธ Vector
    • ๐Ÿ‘€ View
    • ๐Ÿ… XP
    • ๐Ÿชƒ LGdir
  • โš™๏ธ Systems
    • ๐Ÿชƒ LGdir
  • ๐Ÿฆ Banks
    • ๐ŸŒณ Tree
  • ๐Ÿงฉ Modules
  • ๐Ÿ”— Link

๐Ÿ”— Link#

#bs.link:help

Link positions and rotations between entities and create coherent entity structures!

๐ŸŽฌ Watch a demo

Dependencies

This module require the following modules to work properly:

  • bs.id

  • bs.math

  • bs.position


๐ŸŽ“ Create behaviors#

With this module you can combine multiple behaviors to create your very own custom one.


To create a new behavior, you first need to create a new function tag. The tag must start with bs.link:behaviors/setup and end with bs.link:behaviors/apply. Between those 2 functions you are free to use any behaviors that are provided inside the bs.link:behaviors folder.

Example

This is how #bs.link:mirror_x_plane is implemented inside bookshelf:

{
  "values": [
    "bs.link:behaviors/setup",
    "bs.link:behaviors/reverse_pos_x",
    "bs.link:behaviors/imitate_pos_y",
    "bs.link:behaviors/imitate_pos_z",
    "bs.link:behaviors/reverse_rot_h",
    "bs.link:behaviors/imitate_rot_v",
    "bs.link:behaviors/apply"
  ]
}

๐Ÿ”ง Functions#

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


Create link#

bs.link:create_link_ata

This function creates a link between the entity executing the function and the entity closest to the execution position.

Inputs
(execution) as <entities>

The link lead on a parent-child relation. The executing (source) entity must be the child.

(execution) at <entity> or positioned <x> <y> <z>

The execution position is the position of the parent entity (the function will take the nearest entity).

Outputs
(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[x,y,z]

Representing local position.

(score) @s bs.link.l[h,v]

Representing local rotation.

(score) @s bs.link.to

Identifies the entity to which it is linked.

Example

Link all armor_stand to the nearest sheep:

# Once
execute as @e[type=armor_stand] at @e[type=sheep,limit=1,sort=nearest] run function #bs.link:create_link_ata

Note

The output scores should generally not be directly modified because they are used as parameters for other link functions. It is then recommanded to only use the bookshelf function to modify these scores.

Credits: Leirof, Aksiome


Imitate behaviors#

#bs.link:imitate_pos_and_rot

Allows to replace the entity at its relative position. This operation repeated in a loop is to imitate movements and rotations of the parent entity.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s position and rotation

The entity is moved such as it maintain the relative position and rotation with the parent entity.

Example

Make armor_stands mimic your moves:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_pos_and_rot

#bs.link:imitate_pos

Allows to replace the entity at its relative position. This operation repeated in a loop is to imitate movements of the parent entity.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

Outputs
(state) @s position

The entity is moved such as it maintain the relative position with the parent entity.

Example

Make armor_stands mimic your moves:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_pos

#bs.link:imitate_rot

Allows to replace the entity at its local rotation. This operation repeated in a loop is to imitate rotations of the parent entity.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s rotation

The entity is moved such as it maintain the local rotation of the parent entity.

Example

Make armor_stands mimic your moves:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_rot

#bs.link:imitate_pos_x

Allows to replace the entity at its relative position along the X axis. This operation repeated in a loop is to imitate the movements of the parent entity on the X ais.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.rx

Representing the relative position.

Outputs
(state) @s position

The entity is moved such as it maintain the relative position with the parent entity along the X axis.

Example

Make armor_stands mimic your moves on X axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_pos_x

#bs.link:imitate_pos_y

Allows to replace the entity at its relative position along the Y axis. This operation repeated in a loop is to imitate the movements of the parent entity on the Y axis.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.ry

Representing the relative position.

Outputs
(state) @s position

The entity is moved such as it maintain the relative position with the parent entity along the Y axis.

Example

Make armor_stands mimic your moves on Y axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_pos_y

#bs.link:imitate_pos_z

Allows to replace the entity at its relative position along the Z axis. This operation repeated in a loop is to imitate the movements of the parent entity on the Z axis.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.rz

Representing the relative position.

Outputs
(state) @s position

The entity is moved such as it maintain the relative position with the parent entity along the Z axis.

Example

Make armor_stands mimic your moves on Z axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_pos_z

#bs.link:imitate_rot_h

Allows to replace the entity to its local horizontal rotation. This operation repeated in a loop is to imitate the rotations of the parent entity on the horizontal axis.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.lh

Representing the horizontal local rotation.

Outputs
(state) @s rotation

The entity is rotated such as it maintain the rotation of the parent entity on the horizontal axis.

Example

Make armor_stands mimic your rotation changes on the horizontal axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_rot_h

#bs.link:imitate_rot_v

Allows to replace the entity to its local vertical rotation. This operation repeated in a loop is to imitate the rotations of the parent entity on the vertical axis.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.lv

Representing the vertical local rotation.

Outputs
(state) @s rotation

The entity is rotated such as it maintain the rotation of the parent entity on the vertical axis.

Example

Make armor_stands mimic your rotation changes on the vertical axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:imitate_rot_v

๐ŸŽฌ Watch a demo

Credits: Leirof, Aksiome


Keep local position#

#bs.link:keep_local_pos

Allows to keep the local position with the parent entity.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.l[x,y,z]

Representing the local coordinates (position only).

Outputs
(state) @s position

The entity is moved such as it maintain the local position with the parent entity.

Example

Make armor_stands lock to your rotation:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:keep_local_pos

๐ŸŽฌ Watch a demo

How does it work?

This reference frame, unlike the relative coordinates, takes into account the rotation of the entity. Thus, when the parent entity turns on itself, the child entity will turn around it keeping its distance and the angle formed between the direction of the parent entityโ€™s look and the parent->child vector.

Credits: Leirof, Aksiome


Mirror plane#

#bs.link:mirror_x_plane

Allows to mirror the position and rotation of an entity along the X plane.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s position and rotation

The entity is moved such as it mirrors the relative position and rotation of the the parent entity.

Example

Make armor_stands mirror your position and rotation along the X plane:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:mirror_x_plane

#bs.link:mirror_z_plane

Allows to mirror the position and rotation of an entity along the Z plane.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s position and rotation

The entity is moved such as it mirrors the relative position and rotation of the the parent entity.

Example

Make armor_stands mirror your position and rotation along the Z plane:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:mirror_z_plane

Credits: Aksiome


Mirror point#

#bs.link:mirror_point_ata

Allows to mirror the position and rotation of an entity around a given point.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(execution) at <entity> or positioned <x> <y> <z>

The execution position is the position of the point around which the entity is mirrored.

Outputs
(state) @s position and rotation

The entity is moved such as it mirrors the position and rotation of the the parent entity around the given point.

Example

Make armor_stands mirror your position and rotation around 0 0 0:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] positioned 0 0 0 run function #bs.link:mirror_point_ata

Credits: Aksiome


Reverse behaviors#

#bs.link:reverse_pos_and_rot

Allows to determine the rotation and displacement made by the parent entity, and reproduce them in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s position and rotation

The entity is moved and rotated opposingly to the movements and rotations of the parent entity.

Example

Make armor_stands invert your moves and rotations:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_pos_and_rot

#bs.link:reverse_pos

Allows to determine the displacement made by the parent entity, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.r[x,y,z]

Representing the relative position.

Outputs
(state) @s position

The entity is moved opposingly to the movements of the parent entity.

Example

Make armor_stands do the opposite of your moves:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_pos

#bs.link:reverse_rot

Allows you to determine the rotation performed by the parent entity, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Outputs
(state) @s rotation

The entity is rotated opposingly to the rotations of the parent entity.

Example

Make armor_stands invert your rotations:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_rot

#bs.link:reverse_pos_x

Allows to determine the displacement made by the parent entity along the X axis, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.rx

Representing the relative position.

Outputs
(state) @s position

The entity is moved opposingly to the movements of the parent entity along the X axis.

Example

Make armor_stands do the opposite of your moves along the X axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_pos_x

#bs.link:reverse_pos_y

Allows to determine the displacement made by the parent entity along the Y axis, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.ry

Representing the relative position.

Outputs
(state) @s position

The entity is moved opposingly to the movements of the parent entity along the Y axis.

Example

Make armor_stands do the opposite of your moves along the Y axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_pos_y

#bs.link:reverse_pos_z

Allows to determine the displacement made by the parent entity along the Z axis, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.rz

Representing the relative position.

Outputs
(state) @s position

The entity is moved opposingly to the movements of the parent entity along the Z axis.

Example

Make armor_stands do the opposite of your moves along the Z axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_pos_z

#bs.link:reverse_rot_h

Allows you to determine the rotation performed by the parent entity along the horizontal axis, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.lh

Representing the horizontal local rotation.

Outputs
(state) @s rotation

The entity is rotated opposingly to the rotations of the parent entity along the horizontal axis.

Example

Make armor_stands invert your rotations along the horizontal axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_rot_h

#bs.link:reverse_rot_v

Allows you to determine the rotation performed by the parent entity along the vertical axis, and reproduce it in the opposite direction.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

(score) @s bs.link.lv

Representing the vertical local rotation.

Outputs
(state) @s rotation

The entity is rotated opposingly to the rotations of the parent entity along the vertical axis.

Example

Make armor_stands invert your rotations along the vertical axis:

# Once
execute as @e[type=armor_stand] at @s run function #bs.link:create_link_ata

# In a loop
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:reverse_rot_v

Credits: Leirof, Aksiome


Update link#

#bs.link:update_link

This function allows to update the link between entities. If you only use immitation and/or local position keeping functions, this function will not be of any use to you. On the other hand, if you change the position of the child entity automatically, you will have to update the link so that your operation is not cancelled the next time you call the link function.

Automatically updated

The link functions of the lib automatically call the update functions if necessary (example: reverse functions). No need to manage this on your side.

Inputs
(execution) as <entities>

The executing entity must be linked to another entity.

Outputs
(score) @s bs.link.r[x,y,z]

Representing the relative position.

(score) @s bs.link.l[x,y,z]

Representing the local position.

(score) @s bs.link.l[h,v]

Representing the local rotation.

Example

Update armor_stands link:

# Once
execute as @e[type=armor_stand,scores={bs.link.to=1..}] run function #bs.link:update_link

Credits: Leirof, Aksiome


๐Ÿ’ฌ Did it help you?

Feel free to leave your questions and feedbacks below!

previous

โ›๏ธ Item

next

๐Ÿ“„ Log

On this page
  • ๐ŸŽ“ Create behaviors
  • ๐Ÿ”ง Functions
    • Create link
    • Imitate behaviors
    • Keep local position
    • Mirror plane
    • Mirror point
    • Reverse behaviors
    • Update link
Edit on GitHub
Show Source

ยฉ Copyright 2023, Gunivers.

Created using Sphinx 7.2.6.

Built with the PyData Sphinx Theme 0.14.0.