Hitbox

From Minecraft Wiki
(Redirected from Interaction box)
Jump to navigation Jump to search
A zombie chasing a villager with their hitboxes visible by using F3 + B debug hotkey.

A hitbox defines the physical boundary (or an approximation) of a block or entity. Hitboxes are used in the calculations of collisions and targeting.

Unlike with block models, all hitboxes' sizes are hard-coded and cannot be changed independently without modification.

In Java Edition, hitboxes can be seen through the F3 + B debug hotkey.

Entity hitboxes

[edit | edit source]

Bounding box

[edit | edit source]
Several entities with different bounding box sizes next to each other. From left to right, the shortest to tallest: chicken, pig, cow, creeper, zombie, and enderman.

An entity's bounding box manages their collision with blocks and other entities. It's also used for detecting hits and other interactions from players, villagers, arrows, and other entities. In Java Edition, it's shown as a white color coded hitbox around the entities' model, and moves with the entity but maintains a static orientation without rotating.

When the bounding boxes between two entities overlap, a small force is applied to each entity proportional to the distance between them to push them away from each other horizontally. Because there is no vertical collision, it is possible to put multiple entities in the same block by dropping them in from above.

An entity's bounding box can transform into different shapes depending on certain situations, typically unique to the entity itself. For instance, a pufferfish when approached by players gradually expands its shape, from unpuffed, to semi-puffed, then to fully puffed. It instantly shrinks its shape back to normal once it cools down. Players can also change their bounding box by sneaking, crawling, swimming, gliding, or any other means.

Bounding boxes can be scaled by minecraft:scale attribute, or for specific entities, like interaction, it can be changed by modifying their entity data.

Eye height

[edit | edit source]
A wither skeleton has a taller eye height hitbox (red) than a villager, making it suffocate in the barrier block above it.

The eye height shows an entity's eyes placement. It's used for detecting when an entity is submerged in a fluid or phasing through a solid block. In this state, the game usually times the entity drowning or suffocating. In Java Edition, it's shown as flat red lines typically appearing on entities' eyes or head.

The eye height is also used to determine if two entities can see and follow each other by their eye contact.[1] A long blue tint placed in-line with the eye height hitbox shows which direction entities are looking (view angle).

Passenger attachment point

[edit | edit source]

The passenger attachment point is a hitbox that shows the point where an entity passenger is attached on a mountable entity. It's shown as a small green hitbox. It appears on a mountable entity when it is mounted by another entity, and aligns precisely with the bottom side of the hitbox.

Block hitboxes

[edit | edit source]

Collision box

[edit | edit source]

Fences and gates have a one blocks tall interaction box (left), but with 1.5 blocks tall collision box (right). They are rendered via visualize_collision_boxes debug renderer.
Fences have a one blocks tall interaction box, but with 1.5 blocks tall collision box.

The collision box manages a block's collision with entities. They are usually shaped in cubes, but some may have different shapes, like slabs, lecterns, lily pads, fences, walls, and stairs.

A collision box may not be present for all blocks; non-solid blocks such as grass, sign, button, lever, and torch have no collision box.

While most blocks have their collision box identical to their interaction box[note 2] or an empty collision box if it is a non-solid block, some may have a different collision box compared to their interaction box counterpart. For instance, a lectern's collision box does not extend into the upper part of their interaction box, and a fence's collision box is a bit taller than their interaction box. The table below shows all the exceptions in Java Edition:[note 3]

In Java Edition, it is possible to visualize the collision boxes by enabling visualize_collision_boxes in the debug renderer. It is also possible to see when the debug property SHAPES is enabled, indicated by a dark gray outline.

Interaction box

[edit | edit source]
A barrier block's interaction box is shown when hovered by the crosshair.

The interaction box manages block interactions with players, such as block placement, destruction, use actions, etc. When looking at the given block, the interaction box is shown as a black outline around the block's edges; this is especially visible in the barrier block. The interaction box appears only if the block the player is looking at is inside of the interaction range.

A block's interaction box is usually contained within its own 1×1×1 cube space. However, some blocks, such as the ones reported below, are capable of extending outside of this space.

  • The arm of an extended piston – specifically the part that protrudes into the piston's block space.[2]
  • The very top part of a lectern's head.‌[Java Edition only] This is particularly noticeable when a block is placed above the lectern, making the lectern's outline overlap with the block.

The interaction box isn't visible when aiming the crosshair at the part that extends outside of the cube.[3]

In Java Edition, the interaction box outline is cyan (
 #57ffe1
) with a small black outline if "Options" → "Accessibility Settings" → "High Contrast Block Outlines" is enabled. When the debug property SHAPES is enabled, the interaction box outline is white.

Miscellaneous hitboxes

[edit | edit source]

Blocks visual box

[edit | edit source]

In most instances where Minecraft uses line clipping for detection, it utilizes the collision box or the interaction box of the blocks. For example, when a player tries to interact with a block, the game draws a line from it to the interaction range and looks for the first block whose interaction box the line intersects with. In the case of movement, the game draws a line in the direction of movement to find the first collision box to limit movement instead of crossing it.

However, there are five situations in the game where line clipping uses neither the interaction box nor the collision box, instead, the game uses the visual box. The visual box attempts to simulate what a sight would look like; however, most game sight simulations, such as a mob AI searching for a target, use line clipping with a collision box.

For fences, mud, snow, and soul sand the visual box and the interaction box are identical. For all copper bars, copper grates, glass, glass pane, iron bars, powder snow, stained glass, stained glass pane, and tinted glass the visual box are empty. For all other blocks, the visual box and the collision box are identical.

Note that many transparent blocks have an empty visual box; this is so they can be ignored when drawing a line of sight, because they are transparent. However, not all transparent blocks are ignored; for example, the barrier, ice, and leaves have a full visual box.

Below are all the uses of the visual box in Java Edition:

  • Third-person view camera: To position the third-person view camera, the game calculates the distance from the player based on the visual box, using it to avoid collisions.
  • Looking at the creaking: Visual boxes are used by the creaking to know if it is in a player's line of sight; if so, it stops. This is different from endermen, which use the collision box to detect when a player is looking at them.
  • Trial spawner detecting a player: When the trial spawner attempts to detect a player in order to activate, or detect a player with Trial Omen, the player needs to be looking at the spawner, and for that, a visual box is used. However, if the spawner already has a player in its list of detected players, new players will not need to look at the spawner unless they want to use the Trial Omen effect to convert the spawner into an ominous trial spawner.
  • Trial spawner mob spawning: When attempting to spawn a mob, the trial spawner checks if the position where it will spawn is visible starting from the center of the block where it is located. For this, it uses the visual box.
  • Ominous item spawner: When an ominous item spawner spawns above an entity, it first defines a point between 2 and 5 blocks above the top of the entity's hitbox. Then, it draws a line from the entity to that point, stopping at the chosen point or one block below the first collision found by the visual box. Note that this means that if an entity is directly below, for example, a glass block, the ominous item spawner will be spawned above the glass.

Particle collision box

[edit | edit source]

Some particles have physics: for example, the smoke particles from campfires. Particles with physics have a collision box that collides with collision box of blocks. Upon collision, the particle's motion is brought to zero along one of the axes, depending on the direction of the collision.

However, particles are generated even if their collision box intersects the collision box of a block. When this happens, the particle ignores the collision box.

A lit campfire creates smoke particles between 0 and 2 blocks above it, with a symmetric triangular distribution, by the formula pos.getY() + random.nextDouble() + random.nextDouble(), when pos.getY() is the Y coordinates of the campfire and random.nextDouble() is a random number between 0 and 1. Each particle has a 4×4×4 pixels (0.25×0.25×0.25 blocks) collision box. Therefore, the closer a collision box is above the campfire, the more likely a smoke particle is to pass through it, and when the collision box is at 2.25 blocks or more, no particle will pass through it.

For example, 71.9% of smoke particles pass through a full collidable block one block above the campfire, 28.1% pass through a top slab one block above the campfire, 3.13% pass through a full collidable block two blocks above the campfire, only 0.195% pass through a cauldron two blocks above the campfire, and no particle passes through a top slab two block above the campfire.[note 4]

List of entities' hitbox sizes

[edit | edit source]

Most entities' bounding boxes are shaped in cuboids, and do not always overlap with the models of the entities. For example, the witch's bounding box does not include the upper part of its hat, and the wither's bounding box does not include the two heads on its sides. Because most bounding boxes are cuboids, it is standard to measure them by their width and height, with both being measured in blocks tall.

Base hitbox size

[edit | edit source]

Below is a table of every entities' hitboxes, mainly sourced from Java Edition, unless stated otherwise. The list shows sizes of the entities' base bounding box size; other hitboxes may be noted.[note 5]

Some entities' hitbox size is marked with "Varies", this indicates that the entity has variable hitbox sizes, see § Variable hitbox size. For others, "None" marks that the entity does not have hitbox, and "N/A" indicates no data is available yet for the entity in the wiki. An empty cell indicates that the entity may not have hitbox or no data is available yet ("None" or "N/A").

Hitbox data are sourced either from in-game or the entities' articles.
This section needs to be updated.
 
Please update this section to reflect recent updates or newly available information. The talk page may contain suggestions.
Reason: baby chicken and rabbit bounding boxes updated in recent Java Edition 26.1 snapshots
  1. The sizes shown are the white hitbox sizes. Ender dragon has nine distinct hitboxes, consisting of a single massive white hitbox with eight small green hitboxes inside. These green hitboxes move as the ender dragon flies, but do not rotate. Players can only attack or interact with the Ender Dragon by hitting one of their green hitboxes.
    Ender Dragon Part Height Width
    Head 1.0 1.0
    Neck 3.0 3.0
    Body 3.0 5.0
    Tail (3x) 2.0 2.0
    Wing (2x) 2.0 4.0
  2. The baby variant of this entity is called "Ghastling", and their hitbox sizes are the baby height and width values.
Miscellaneous
Entity Height Width Eye Height
Area Effect Cloud 0.5 Varies 0.425
End Crystal 2 2 1.7
Evoker Fangs 0.8 0.5 0.68
Fishing Bobber 0.25 0.25 0.2125
Glow Item Frame N/A N/A None
Item Frame N/A N/A None
Leash Knot 0.5 0.375 0.0625
Interaction[JE only] Varies Varies None
Marker[JE only] None None None
Block Display[JE only] None None None
Text Display[JE only] None None None
Item Display[JE only] None None None
Painting N/A N/A None
Projectiles
Entity Height Width Eye Height
Arrow and Tipped Arrow 0.5 0.5 0.13
Bottle o' Enchanting 0.25 0.25 0.2125
Dragon Fireball 1 1 0.85
Egg 0.25 0.25 0.2125
Ender Pearl 0.25 0.25 0.2125
Eye of Ender 0.25 0.25 0.2125
Fireball 1‌[JE only] 0.31‌[BE only] 1‌[JE only] 0.31‌[BE only] 0.85
Firework Rocket 0.25 0.25 0.2125
Llama Spit 0.25 0.25 0.2125
Shulker bullet 0.3125 0.3125 0.2656
Small Fireball 0.3125 0.3125 0.2656
Snowball 0.25 0.25 0.2125
Spectral Arrow[JE only] 0.5 0.5 0.13
Thrown Lingering Potion 0.25 0.25 0.2125
Trident 0.5 0.5 0.13
Wind Charge 0.3125 0.3125 None
Wither Skull 0.3125 0.3125 0.2656
Vehicles
Entity Height Width Eye Height
Boat 0.5625 1.375 0.5625
Boat with Chest 0.5625 1.375 0.5625
Minecart 0.7 0.98 0.595
Minecart with Chest 0.7 0.98 0.595
Minecart with Command Block 0.7 0.98 0.595
Minecart with Furnace[JE only] 0.7 0.98 0.595
Minecart with Hopper 0.7 0.98 0.595
Minecart with Monster Spawner[JE only] 0.7 0.98 0.595
Minecart with TNT 0.7 0.98 0.595
Items
Entity Height Width Eye Height
Experience Orb 0.5‌[JE only] 0.25‌[BE only] 0.5‌[JE only] 0.25‌[BE only] 0.425
EnvSprite item.png: Sprite image for item in Minecraft Item 0.25 0.25 0.2125
Blocks
Entity Height Width Eye Height
Falling Block 0.98 0.98 0.833
Primed TNT 0.98 0.98 0.15

Variable hitbox size

[edit | edit source]

The size of an entity's hitbox is not necessarily static and may change depending on certain situations. For instance, a player's hitbox gets smaller while crouching, and a pufferfish's hitbox changes while its puffing. Some entities may also spawn in different sizes, like slime, magma cube, and salmon[Bedrock Edition only].

Below is the list of entities whose hitbox can change sizes given specific situations or states:

Entity States Height Width
Camel Normal 2.375 1.7
Sitting 0.945 1.0
Sitting (Baby) 0.945 0.45
Goat Normal 1.3 0.9
Jumping 0.91 0.63
Magma Cube Small 0.52 0.5202
Medium 1.04 1.0404
Big 2.08 2.0808
Player Normal 1.8 0.6
Sneaking 1.5 0.6
Gliding/Swimming 0.6 0.6
Sleeping 0.2 0.2
Polar Bear Normal 1.4 1.4
Attacking 2.0 1.0
Pufferfish Unpuffed 0.35 0.35
Semi-puffed 0.49 0.49
Fully Puffed 0.7 0.7
Salmon[BE only] Small 0.25 0.25
Medium 0.5 0.5
Large 0.75 0.75
Shulker Closed 1 1
Peeking 1.2 1
Open 2 1
Slime Small 0.52 0.5202
Medium 1.04 1.0404
Big 2.08 2.0808
Warden Normal 2.9 0.9
Digging/Emerging 1 0.9

History

[edit | edit source]

Java Edition

[edit | edit source]

Block hitboxes

[edit | edit source]
This section is missing information about: MC-1635, MC-73302, MC-1720, and b1.9pre2: did the wireframe also change?
 
Please expand the section to include this information. Further details may exist on the talk page.
Java Edition pre-Classic
rd-132211Targeted blocks now have a visual indicator in which they alternate between bright and dark continuously.
Java Edition Classic
0.0.13aTargeted blocks also have a thin outline box.
0.24_SURVIVAL_TESTThe holographic pulsating hitbox displayed when able to place or break a block has been removed, leaving just the wireframe hitbox.
?The hitboxes for some blocks (flowers, mushrooms, torches) are no longer full cubes, and are more fitting for the size of the block.
Java Edition Infdev
Minecraft Infdev20100313Prior to this version, the wireframe hitbox for highlighting blocks would behave increasingly incorrectly at far distances from the world origin. On all supported hardware, its position would jitter erratically with small shifts in camera rotation. On some GPUs/graphics cards, the geometry of the box would also distort, resulting in non-cubic shapes.
Java Edition Alpha
v1.0.11The hitbox of cacti at far distances became greater than a full block.
Java Edition Beta
1.2The hitbox of cakes at far distances became greater than a full block.
Java Edition
?Stairs cannot be targeted at angles where the crosshair does not point at a solid feature of the block. However, the wireframe outline still displays as a full cube regardless.
?The hitboxes for randomly misaligned blocks such as tall grass are now themselves randomly offset as well to accommodate them.
1.0.0Beta 1.9 Prerelease 2Fences no longer have a full block hitbox on the xz plane, and instead more closely match their shape.
1.112w01aThe fence gate hitbox has changed to match the changes made to fence hitboxes.
1.4.41.4.3Walls now have their own collision box size - previously they shared their size with fences.[4]
The above change also fixed a bug causing their hitboxes to distort and stop working correctly at far distances from the world origin.
1.513w06aFence hitboxes have been changed - concave corners now have their collision boxes respect that rather than always using its effective convex hull, resulting in an invisible portion of collision box there.
The above change also fixed a bug causing their hitboxes to distort and stop working correctly at far distances from the world origin.
1.814w25a The hitboxes of melon stems and pumpkin stems with ages ≥8 could visually extend into the block space above them while they existed (from Beta 1.8 Pre-release up to the removal of the last four in 14w10a and the remaining four in 14w25a).
1.915w38aThe hitboxes of cakes and cacti at far distances could become greater than a full block, allowing this to be seen (from Beta 1.2 and Alpha v1.0.11 respectively up to their fixing, although it became unobservable for cake from 15w38a onward due to fixed bug MC-106300).
Cake's wireframe hitbox now always appears at (0,0,0) regardless of where the targeted cake actually is. This also masks a distance issue fixed in 15w49a​[more information needed]; see below.
15w46aThe hitbox of redstone wire now covers only part of the surface of the block below, based on the orientation of the redstone.
15w49aPrior to this snapshot, the wireframe hitboxes used for cake and cactus would appear stretched and misshapen at far distances from spawn.
15w49bThe hitbox height of the end portal block has been increased from 116 of a block to 34 of a block.
1.1116w35aCake's hitbox now appears at the right position again.[5]
1.1317w47aThe hitbox of brewing stands now takes into account the central rod as well.[6][verify]
The collision box of walls has been made to be correctly concave.[7][verify]
The outline boxes of anvils and hoppers now much more closely fit the model shape of these blocks.
The outline boxes of fences is now correctly L-shaped, T-shaped or +-shaped when branching in perpendicular directions.[8]
Cactus now has a correct cuboid outline box.[9]
Blocks containing multiple vines now have better outline boxes.
Glass panes and iron bars have cleaner outline boxes when branching.
End portal frame outline boxes now properly account for the eye.
Piston and lily pad outline boxes were changed.
1.1418w48aThe outline boxes of beds now match better the visual shape of the bed.
19w13aThe outline boxes of cauldrons now fit the model better, allowing for blocks beneath it to be targeted.[10][verify]
1.1620w10aFire now has an outline box (alongside soul fire),[11] bringing it more in line with other blocks. Previously, fire had no outline box at all, and breaking it required targeting underlying blocks, which also allowed it to be put out in Creative mode when holding a sword or trident, which were programmed to not break blocks. It also prevented its block states from being read in the debug screen or modified via debug stick.
20w18aThe outline box of redstone wire has been changed to much more closely the visual shape of the block. For example, redstone wire branching in different directions causes its outline box to itself branch in said directions,[12] mirroring the behavior of fences, glass panes, iron bars and walls, and, if traveling up the side of a block, the vertical portion of the dust can now also be targeted.[13]
1.1720w48aThe hitboxes of pointed dripstone can sometimes also be randomly extended into adjacent blocks.[14]
20w49aThe hitboxes of pointed dripstone no longer sometimes extend into adjacent blocks.[15]
The overall width of the outline box of the pointed dripstone is reduced by 18 of a block.

Entity hitboxes

[edit | edit source]
Java Edition
1.4.41.4.3F3 + B now enables a debug renderer which visually displays entity hitboxes.
1.1419w08aChanged bounding box and eye height of foxes (prevents them from drowning when swimming).
1.20.223w33aChanged mob attack reach calculation.
In horizontal directions, mobs' attack reach are now their bounding box extended in horizontal directions, instead of using horizontal width to determine.
In vertical directions, mobs' attack reach are now the exact vertical range of their bounding box. When there's no overlap between their bounding box and their target's bounding box in vertical direction, they can not attack.
1.21.224w33aFixed an issue where wither skull's bounding box is wrongly positioned in the first tick, and cannot be selected with volume checks in commands.[16]
26.1snap2Changed rabbit hitbox sizes to match the new model (adult and baby variants).
Baby chicken's bounding box was tweaked to correctly align with their new model.​[more information needed]

Bedrock Edition

[edit | edit source]
This section needs expansion.
 
You can help by expanding it.

Entity hitboxes

[edit | edit source]
Bedrock Edition
26.0Preview 26.0.23Mob effect particles can now appear slightly outside of the mob's bounding box.

Issues

[edit | edit source]

Issues relating to "Hitbox" are maintained on the bug tracker. Issues should be reported and viewed there.

Trivia

[edit | edit source]
  • In Java Edition, the visually shown entity hitboxes that appear when F3 + B sometimes do not render where the hitbox actually is, as it is just highlighting the area relative to the position of the entity that has the hitbox. This can be quite prominent if the player runs /tick freeze when a mob is moving.
  • In Java Edition, if an entity has the Invisibility effect, its hitbox is not visually shown when F3 + B is pressed.
[edit | edit source]

Screenshots

[edit | edit source]

Notes

[edit | edit source]
  1. This is not exactly a list of all blocks without collision. It's possible for a block to have no collision because it has an empty interaction box (e.g., light). It is also possible that blocks in the list have a collision box, in case the collision box was created later (e.g., scaffolding and wall hanging signs). In the game's code, these blocks are defined in the Blocks class.
  2. The interaction box is considered with an empty context. Thus, for example, light will always have an empty collision box, even when the entity is holding the light item. However, block states are still considered
  3. In the table, trios like 1×2×3 represent a box in the shape of a cuboid with 1 pixel in X, 2 pixels in Y, and 3 pixels in Z. If the note column is empty, the center of XZ-plane is the same as the center of the block and starts at the base. For example, 16×16×16 is a full block.
  4. This calculation was performed using the formula 1 − F_X(x − 0.25), where F_X is the cumulative distribution function of X, X is the random variable with a triangular distribution with parameters a=0, b=2, c=1, and x is the vertical distance between the campfire and the block collision box. Thus, the probability of a smoke particle passing through a collision box that starts x>1 blocks above the campfire is 1 − (x − 0.25)^2 ÷ 2 if x ≤ 1.25, (2.25 − x)^2 ÷ 2 if 1.25 < x < 2.25, or 0 if x ≥ 2.25
  5. In the game's code, most entities bounding boxes are defined in EntityType class. Baby variant of mobs are not defined there, instead typically in each individual mob class.

References

[edit | edit source]
  1. "How crawling came to Minecraft" by Henrik Kniberg – Minecraft.net, July 21, 2020.
  2. MC-124459
  3. MC-158827
  4. MC-1332 — resolved as "Fixed".
  5. MC-106300 — resolved as "Fixed".
  6. MC-4504 — resolved as "Fixed".
  7. MC-2666 — resolved as "Fixed".
  8. MC-12000 — resolved as "Fixed".
  9. MC-59610 — resolved as "Fixed".
  10. MC-129205 — resolved as "Fixed".
  11. MC-163655 — resolved as "Fixed".
  12. MC-137336 — resolved as "Fixed".
  13. MC-153508 — resolved as "Fixed".
  14. MC-205543 — resolved as "Fixed".
  15. MC-205543 — resolved as "Fixed".
  16. MC-262112 — resolved as "Fixed".
[edit | edit source]