🎯 Hitbox#
#bs.hitbox:help
Get and check the hitboxes of blocks or entities.
“Talent hits a target no one else can hit; Genius hits a target no one else can see.”
—Arthur Schopenhauer
🔧 Functions#
You can find below all functions available in this module.
Get#
- #bs.hitbox:get_block
Get the hitbox of a block as a shape, represented by a list of boxes coordinates. Dimensions range from 0 to 16 as for models.
- Inputs:
Execution
at <entity>
orpositioned <x> <y> <z>
: Position from which to get the block hitbox.- Outputs:
Storage
bs:out hitbox
:- Block collision box
- shape: A list of cube coordinates (
[[min_x, min_y, min_z, max_x, max_y, max_z]]
). - offset: Hitbox offset (used for example by flowers).
- x: Number describing the X coordinate offset.
- z: Number describing the Z coordinate offset.
- shape: A list of cube coordinates (
- Block collision box
Get the hitbox of stairs:
setblock 0 0 0 minecraft:oak_stairs
execute positioned 0 0 0 run function #bs.hitbox:get_block
data get storage bs:out hitbox
- #bs.hitbox:get_entity
Get the width and height of an entity.
- Inputs:
Execution
as <entities>
: Entity to get the hitbox from.- Outputs:
Storage
bs:out hitbox
:- Block collision box
- height: Height of the entity.
- width: Width of the entity.
- scale: Scaling of the hitbox.
- Block collision box
Get the hitbox of an armor_stand:
execute summon minecraft:armor_stand run function #bs.hitbox:get_entity
data get storage bs:out hitbox
Important
Static entities, such as paintings and item frames, do not provide height and width information. Instead, they return a shape similar to blocks in bs:out hitbox
.
Credits: Aksiome
Is entity inside#
- #bs.hitbox:is_entity_in_block
Check if the specified entity is within the block at the execution position.
- Inputs:
Execution
as <entity>
: Entity to check.Execution
at <entity>
orpositioned <x> <y> <z>
: Position to check.- Outputs:
Return: Success or failure.
Note
This function checks if the entity’s bounding box is inside the block at the current position, not any other blocks the entity might touch.
Check if a summoned cow is inside the fence at your position:
setblock ~ ~ ~ minecraft:oak_fence
# move to the edge of the fence, then run
execute summon minecraft:cow if function #bs.hitbox:is_entity_in_block run say I'm in the fence
# since the cow is bigger than the player, you should see the message
- #bs.hitbox:is_entity_in_blocks
Check if the specified entity is within a block.
- Inputs:
Execution
as <entity>
: Entity to check.Function macro:
- Arguments
- with: Optional settings.
- ignored_blocks: Blocks to ignore (default:
#bs.hitbox:intangible
).
- ignored_blocks: Blocks to ignore (default:
- with: Optional settings.
- Arguments
- Outputs:
Return: Success or failure.
Note
Since an entity’s bounding box can extend across multiple blocks, this function checks all blocks the entity might be in contact with.
Check if a summoned cow is inside a block:
# move to the edge of a block, then run
execute summon minecraft:cow run function #bs.hitbox:is_entity_in_blocks {with:{}}
# since the cow is bigger than the player, you should get a success
Credits: Aksiome
Is inside#
- #bs.hitbox:is_in_block
Check if the execution position is inside the hitbox of a block.
- Inputs:
Execution
at <entity>
orpositioned <x> <y> <z>
: Position to check.- Outputs:
Return: Success or failure.
Say “My name is Pavel” if you are inside a block:
execute if function #bs.hitbox:is_in_block run say My name is Pavel
- #bs.hitbox:is_in_entity
Check if the execution position is inside the entity executing the command.
- Inputs:
Execution
as <entities>
: Entity to check.Execution
at <entity>
orpositioned <x> <y> <z>
: Position to check.- Outputs:
Return: Success or failure.
Check if you are inside an entity:
execute summon minecraft:cow if function #bs.hitbox:is_in_entity run say Oh no...
Credits: Aksiome