Wunderlib Wiki › Guides › Use Math Helpers for Common Calculations
Use Math Helpers for Common Calculations
Available Math Utilities
WunderLib provides a collection of helper functions for calculations frequently needed in Minecraft modding. These include vector operations, interpolation, clamping, and angle normalization—all optimized and ready to use without writing them yourself.
Practical Applications
- Interpolation: Smoothly transition values over time for animations or gradual changes
- Vector Math: Calculate distances, normalize directions, and perform rotations
- Clamping: Restrict values to a valid range without conditional statements
- Angle Handling: Convert and normalize angles to avoid wraparound issues
Integration in Your Code
Import the math helper classes and call static methods directly. These utilities integrate seamlessly with Minecraft's existing math classes and coordinate systems, so you can use them alongside vanilla calculations without conversion overhead.
Benefits
- Reduces code duplication across your mod
- Improves performance with optimized implementations
- Makes complex calculations more readable
- Ensures consistent behavior across different features