๐ Link#
bs.link:_
Link positions and orientations between entities and create coherent entity structures!
๐ง Functions#
You can find below all the function available in this module.
Create link#
bs.link:create_link_ata
In the same way as create_link_to_target_id
, 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,h,v]
Representing the relative coordinates (position + orientation)
- (score)
@s bs.link.l[x,y,z]
Representing local coordinates (position only)
- (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 # See the result # In loop execute as @e[type=armor_stand] run function glib_debug:link/display_link
bs.link:create_link_tti
Create a link between two entities : compute relative and local position and orientation in order to manipulate them later.
- Inputs
- (execution)
as <entities>
The link lead on a parent-child relation. The executing (source) entity must be the child.
- (score)
@s bs.id.target
Score of the executing entity must match the
bs.id
score of the entity to which it will be linked. Multiple entities can be linked to a single entity (generally recommended for armor_stand structures).
- (execution)
- Outputs
- (score)
@s bs.link.r[x,y,z,h,v]
Representing the relative coordinates (position + orientation)
- (score)
@s bs.link.l[x,y,z]
Representing local coordinates (position only)
- (score)
@s bs.link.to
Identifies the entity to which it is linked
- (score)
- Example
Link all armor_stand to the entity with ID 3 (see the
bs.id
module to know how to assign an ID to an entity)# Once scorebaord players set @e[type=armor_stand] bs.id.target 3 execute as @e[type=armor_stand] run function bs.link:create_link_tti # See the result # In loop execute as @e[type=armor_stand] run function glib_debug:link/display_link
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.
Dependencies
This function require the following modules to work properly:
Credits: Leirof
Imitate location#
bs.link:imitate_loc
Allows to replace the entity at its relative position. This operation repeated in a loop is to imitate the 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 coordinates (position only)
- (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,tag=bs.linked] run function bs.link:imitate_loc
bs.link:imitate_loc_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 coordinates (position only)
- (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,tag=bs.linked] run function bs.link:imitate_loc_x
bs.link:imitate_loc_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 coordinates (position only)
- (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,tag=bs.linked] run function bs.link:imitate_loc_y
bs.link:imitate_loc_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 coordinates (position only)
- (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,tag=bs.linked] run function bs.link:imitate_loc_z
Credits: Leirof
Imitate orientation#
bs.link:immitate_ori
Allows to replace the entity to its relative orientation. This operation repeated in a loop is to imitate the rotations of the parent entity.
- Inputs
- (execution)
as <entities>
The executing entity must be linked to another entity.
- (score)
@s bs.link.r[h,v]
Representing the horizontal and vertical relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s orientation
The entity is rotated such as it maintain the relative orientation with the parent entity.
- Example
Make armor_stands mimic your orientation changes
# 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,tag=bs.linked] run function bs.link:imitate_ori
bs.link:immitate_ori_h
Allows to replace the entity to its relative horizontal orientation. 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.rh
Representing the horizontal relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s orientation
The entity is rotated such as it maintain the relative orientation with the parent entity on the horizontal axis.
- Example
Make armor_stands mimic your orientation 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,tag=bs.linked] run function bs.link:imitate_ori_h
bs.link:immitate_ori_v
Allows to replace the entity to its relative vertical orientation. 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.rv
Representing the vertical relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s orientation
The entity is rotated such as it maintain the relative orientation with the parent entity on the vertical axis.
- Example
Make armor_stands mimic your orientation 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,tag=bs.linked] run function bs.link:imitate_ori_v
Credits: Leirof
Keep local location#
bs.link:keep_local_location
Allows to keep the local position corresponding to the position of the child entity in the repository of 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 the armor_stands lock to your orientation
# 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,tag=bs.linked] run function bs.link:keep_local_location
Dependencies
This function require the following modules to work properly:
How does it work?
This reference frame, unlike the relative coordinates, takes into account the orientation 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
Reverse location#
bs.link:reverse_loc
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 coordinates (position only)
- (execution)
- Outputs
- (state) @s position
The entity is moved opposingly to the movements of the parent entity.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_loc
bs.link:reverse_loc_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 coordinates (position only)
- (execution)
- Outputs
- (state) @s position
The entity is moved opposingly to the movements of the parent entity along the X axis.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_loc_x
bs.link:reverse_loc_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 coordinates (position only)
- (execution)
- Outputs
- (state) @s position
The entity is moved opposingly to the movements of the parent entity along the Y axis.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_loc_y
bs.link:reverse_loc_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 coordinates (position only)
- (execution)
- Outputs
- (state) @s position
The entity is moved opposingly to the movements of the parent entity along the Z axis.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_loc_z
Credits: Leirof
Reverse orientation#
bs.link:reverse_ori
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.r[h,v]
Representing the relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s rotation
The entity is rotated opposingly to the rotations of the parent entity.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_ori
bs.link:reverse_ori_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.rh
Representing the relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s rotation
The entity is rotated opposingly to the rotations of the parent entity along the horizontal axis.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_ori_h
bs.link:reverse_ori_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.rv
Representing the relative orientation (rotation only)
- (execution)
- Outputs
- (state) @s rotation
The entity is rotated opposingly to the rotations of the parent entity along the vertical axis.
- Example
Make the 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,tag=bs.linked] run function bs.link:reverse_ori_v
Credits: Leirof
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[h,v]
Representing the relative orientation (rotation only)
- (score)
@s bs.link.r[x,y,z]
Representing the relative coordinates (position only)
- (score)
@s bs.link.l[x,y,z]
Representing the local coordinates (position only)
- (score)
- Example
Update the armor_stands link
# Once execute as @e[type=armor_stand] run function bs.link:update_link # See the result # In a loop execute as @e[tag=bs.linked] run function glib_debug:link/display_link
Dependencies
This function require the following modules to work properly:
Credits: Leirof
๐ฌ Did it help you?
Feel free to leave your questions and feedbacks below!