-
Notifications
You must be signed in to change notification settings - Fork 1
Blockbench plugin
To help with the creation of hitboxes I have created a small blockbench plugin. For now the plugin can be found in this repo.
Once you have installed the plugin you first have to load a model with the bedrock or the GeckoLib format.
Next you will want to create a top-level bone called hitboxes. Each cube that gets added to the bone will be exported as a hitbox. To work properly a hitbox/cube must have a matching X and Z size which you can see in this screenshot with three example hitboxes.

On their own these cubes will be enough to create simple hitboxes that rotate around the mob.

Due to limitations in mc, hitboxes can't be too large, which is why this 14 blocks tall mob has 2 body hitboxes (each about 4 blocks tall). On top of that a mob that is longer than it is wide might need multiple cubes for their tails/heads.

Depending on the mobs animations this might be enough, but if not, the next part will explain how to attach the hitboxes to animations.
To attach the hitboxes to animations you will need to add a bone named {hitbox_name}_hitbox to a fitting parent bone.

Now begins the first tedious part, as you need to align the bones pivot point with the bottom center of the matching cube in hitboxes.

If you were to export the hitboxes now, the position of the hitbox in game would follow this bone even during animations.
{
"elements": [
{
"name": "head",
"pos": [0.1, 21.7, 20.6],
"width": 15.6,
"height": 23,
"ref": "head_hitbox"
}
]
}There are however a lot of animations where this will not work out of the box because of the placement of the pivot point or the size of the box. For this reason, the next part will deal with adding an animation.
First you will want to add a cube to the _hitbox bone that will help with the animation. To do this run Tools -> Copy hitbox cube to bone. This will create a copy attached to your new bone and rotate it correctly. Now all you must do is move the new cube until it overlaps the the old one. This cube will be your reference point while animating.
Next find an animation where the new cube(red in the screenshot) does not follow the body part correctly, select its bone and run Animation -> Create Hitbox Animation. This will visually rotate the bone to match, how it would look ingame. This rotation has no effect on the actual hitbox in game, so you can leave it or remove it when done.

Have the bone roughly overlap with the body part during the animation.
This example shows a drinking animation with updated positions.

This one shows a sleeping animation with a scaled head and body hitbox. These can look weird in blockbench but will look fine in game.

To export the hitboxes run the File -> Export -> Export Hitboxes. The resulting file will look something like this and needs to be placed into resources/data/modid/hitboxes
{
"elements": [
{
"name": "body",
"pos": [-0.2, 0, 1.7],
"width": 20.2,
"height": 31.8,
},
{
"name": "head",
"pos": [0.1, 21.7, 20.6],
"width": 15.6,
"height": 23,
},
{
"name": "tail",
"pos": [0, 10.4, -15.1],
"width": 11.2,
"height": 15,
}
]
}If you have added animation bones you will also need to export the GeckoLib model and the animations. Exporting the model will not export the hitboxes bone or the cubes inside the _hitbox bones.