Hitbox Api
Adding Advanced Collision Systems for Minecraft
The modification provides developers with a comprehensive set of geometric primitives for precise collision detection in the game environment.
Main Features:
- Oriented Bounding Boxes (OBB) - rectangular areas with arbitrary orientation
- Spheres - classic circular collision areas
- Capsules - cylindrical shapes with rounded ends
- Rays - linear segments for visibility checks and tracing
- Compound Colliders - ability to combine multiple primitives into one complex shape, including nested structures
Development Application
To use the functionality in any part of the game where collision checking is required, simply create a collider object and apply methods from ColliderUtil to determine intersection.
For working with entities, you can utilize the caching system by attaching HitboxDataAttachments#COLLISION. Stored collision shapes become visible when pressing the F3 + B key combination. Note that cache data is not preserved between game sessions.
System Performance
Testing Methodology:
- JMH benchmarking
Test Environment:
- Processor: AMD R5 5600G
- RAM: 32 GB
- JDK: Microsoft OpenJDK 21.0
Testing Parameters:
- Warm-up: 5 cycles
- Main measurements: 5 cycles
Testing Objects:
- Collision detection between similar colliders
Performance Results
| Collider Type | Result | Error | Unit |
|---|---|---|---|
| Axis-Aligned BBOX | 3561837865.930 | 157982649.213 | ops/s |
| Capsule | 22350681.198 | 238993.658 | ops/s |
| Rotated Capsule | 16842309.523 | 103959.918 | ops/s |
| Oriented BBOX | 5528493.224 | 64548.996 | ops/s |
| Rotated Oriented BBOX | 4648963.750 | 111369.535 | ops/s |
| Sphere | 119556589.705 | 1711146.560 | ops/s |
Important: higher values indicate better performance. The term "Rotated" means collider rotation with corresponding recalculation of vector quantities.
