-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mostly working block collision rotation
- Loading branch information
Showing
2 changed files
with
148 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
shared/src/main/java/org/geysermc/hydraulic/util/MathUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.geysermc.hydraulic.util; | ||
|
||
public class MathUtil { | ||
/** | ||
* Rounds a float to a specified number of decimal places. | ||
* | ||
* @param value the value to round | ||
* @param places the number of decimal places to round to | ||
* @return the rounded value | ||
*/ | ||
public static float round(float value, int places) { | ||
if (places < 0) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
long factor = (long) Math.pow(10, places); | ||
value = value * factor; | ||
long tmp = Math.round(value); | ||
return (float) tmp / factor; | ||
} | ||
} |