Galacticraft
Galacticraft copied to clipboard
refactor: make use of Mth methods
This is an attempt to make the math faster and more readable by utilizing some of the methods offered by the net.minecraft.util.Mth class as well as other math related optimizations.
Notable changes:
- Use
Mth.clamp(x, L, U)rather thanMath.min(Math.max(x, L), U)orMath.max(Math.min(x, U), L)for example. - Use existing
Mth.DEG_TO_RADorMth.RAD_TO_DEGrather than definingConstant.RADIANS_TO_DEGREESourselves. - Use
Mth.PIrather than(float) Math.PIas well as other constants such asMth.HALF_PIandMth.TWO_PI. - Prefer
Mth.sinandMth.cosoverMath.sinandMath.cos, which should be faster as these methods use cached values. - Make use of trigonometric identities to simplify calculations.
- Change some doubles to floats where it seems like they should have been floats in the first place.