🏷️ ID#
#bs.id:help
Assign unique numeric IDs to entities.
“We know what we are, but know not what we may be.”
—William Shakespeare
🔧 Functions#
You can find below all functions available in this module.
Give Simple Unique ID#
- #bs.id:give_suid
Give a unique
bs.idscore to each entity.- Inputs:
Execution
as <entities>: Entities to assign an ID to.- Outputs:
Score
@s bs.id: Generated simple unique ID.
Example: Give an ID to all players:
# Give an ID to all players who don't already have one
execute as @a[predicate=!bs.id:has_suid] run function #bs.id:give_suid
# Display the results in the sidebar
scoreboard objective setdisplay sidebar bs.id
Credits: Aksiome, KubbyDev
Give Chain Unique ID#
- #bs.id:give_cuid
Give a unique
bs.cidscore to each entity.- Inputs:
Execution
as <entities>: Entities to assign an ID to.- Outputs:
Score
@s bs.cid: Generated chain unique ID.
How it works?
The chain ID is similar to the simple ID. However, with chain IDs, you can use the function #bs.id:update_cuids to make sure there are no gaps in the ID sequence, thus creating a continuous chain.
Example: Give an ID to all players:
# Give an ID to all players who don't have one
execute as @a[predicate=!bs.id:has_cuid] run function #bs.id:give_cuid
# Display the results in the sidebar
scoreboard objective setdisplay sidebar bs.cid
Credits: Aksiome, KubbyDev
Update Chain Unique ID#
- #bs.id:update_cuids
Update all entities’ CUIDs to ensure the chain is continuous.
Example: Ensure the chain is free of gaps and duplicates:
function #bs.id:update_cuids
# See the result
scoreboard objective setdisplay sidebar bs.cid
Credits: Aksiome, KubbyDev
👁️ Predicates#
You can find below all predicates available in this module.
Check Simple Unique ID#
- bs.id:has_suid
Determine if an entity has a
bs.idscore.
Example: Give an SUID to all entities that aren’t identified by a bs.id score:
execute as @e[predicate=!bs.id:has_suid] run function #bs.id:give_suid
- bs.id:suid_equal
Find an entity that has the same
bs.idas the input value.- Inputs:
Score
$id.suid bs.in: Value to check against.
Example: Find the entity that has a bs.id equal to 1:
scoreboard players set $id.suid bs.in 1
execute as @e[predicate=bs.id:suid_equal,limit=1] run say I'm the one
- bs.id:suid_lower
Filter entities that have a
bs.idless than or equal to the input value.- Inputs:
Score
$id.suid bs.in: Value to check against.
Example: Filter entities that have a bs.id less than or equal to 17:
scoreboard players set $id.suid bs.in 17
execute as @e[predicate=bs.id:suid_lower] run say I'm a minor
- bs.id:suid_upper
Filter entities that have a
bs.idgreater than or equal to the input value.- Inputs:
Score
$id.suid bs.in: Value to check against.
Example: Filter entities that have a bs.id greater than or equal to 18:
scoreboard players set $id.suid bs.in 18
execute as @e[predicate=bs.id:suid_upper] run say I'm an adult
- bs.id:suid_match
Filter entities that have a
bs.idbetween the given values.- Inputs:
Score
$id.suid.min bs.in: Min value to check against.Score
$id.suid.max bs.in: Max value to check against.
Example: Filter entities that have a bs.id between 2 and 4:
scoreboard players set $id.suid.min bs.in 2
scoreboard players set $id.suid.max bs.in 4
execute as @e[predicate=bs.id:suid_match,limit=1] run say In range
Credits: Aksiome
Check Chain Unique ID#
- bs.id:has_cuid
Determine if an entity has a
bs.cidscore.
Example: Give a CUID to all entities that aren’t identified by a bs.cid score:
execute as @e[predicate=!bs.id:has_cuid] run function #bs.id:give_cuid
- bs.id:cuid_equal
Find an entity that has the same
bs.cidas the input value.- Inputs:
Score
$id.cuid bs.in: Value to check against.
Example: Find the entity that has a bs.cid equal to 1:
scoreboard players set $id.cuid bs.in 1
execute as @e[predicate=bs.id:cuid_equal,limit=1] run say I'm the one
- bs.id:cuid_lower
Filter entities that have a
bs.cidless than or equal to the input value.- Inputs:
Score
$id.cuid bs.in: Value to check against.
Example: Filter entities that have a bs.cid less than or equal to 17:
scoreboard players set $id.cuid bs.in 17
execute as @e[predicate=bs.id:cuid_lower] run say I'm a minor
- bs.id:cuid_upper
Filter entities that have a
bs.cidgreater than or equal to the input value.- Inputs:
Score
$id.cuid bs.in: Value to check against.
Example: Filter entities that have a bs.cid greater than or equal to 18:
scoreboard players set $id.cuid bs.in 18
execute as @e[predicate=bs.id:cuid_upper] run say I'm an adult
- bs.id:cuid_match
Filter entities that have a
bs.cidbetween the given values.- Inputs:
Score
$id.cuid.min bs.in: Min value to check against.Score
$id.cuid.max bs.in: Max value to check against.
Example: Filter entities that have a bs.cid between 2 and 4:
scoreboard players set $id.cuid.min bs.in 2
scoreboard players set $id.cuid.max bs.in 4
execute as @e[predicate=bs.id:cuid_match,limit=1] run say In range
Credits: Aksiome
💬 Did it help you?
Feel free to leave your questions and feedback below!