๐ Link#
#bs.link:help
Link positions and rotations between entities and create coherent entity structures!
๐ 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>
orpositioned <x> <y> <z>
The execution position is the position of the parent entity (the function will take the nearest entity).
- (execution)
- 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.
- (score)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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
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).
- (execution)
- 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
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.
- (execution)
- 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.
- (execution)
- 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>
orpositioned <x> <y> <z>
The execution position is the position of the point around which the entity is mirrored.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (execution)
- 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.
- (score)
- 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!