Skip to content

Commit c4f602d

Browse files
documentation, i guess?
1 parent fe0ab7f commit c4f602d

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apply plugin: 'eclipse'
1515
apply plugin: 'maven'
1616
apply plugin: 'maven-publish'
1717

18-
version = '1.16.5-0.0.1.2'
18+
version = '1.16.5-0.0.1.3'
1919
group = 'multiteam.multicorelib' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2020
archivesBaseName = 'multicore_lib'
2121

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
package multiteam.multicore_lib.setup.utilities;
22

3+
import net.minecraft.util.math.vector.Vector3f;
4+
35
public class MathF { //Why MathF? Because in unity, there was a class with Mathematical functions, and i grown quiet fond of this name. In the honor of my C# past, you shall now be named MathF!
46

5-
public float rescaleValues(float minFrom, float maxFrom, float minTo, float maxTo, float valueToScale){
7+
/**
8+
* Calculates a number in between two scales.
9+
* Useful for minecraft's float values where it uses a scale between 0-1 instead of 0-16 for blocks and such.
10+
* To a quicker acces to a solution for the problem mentioned above, see BlockToFloatScale()
11+
**/
12+
public static float rescaleValues(float minFrom, float maxFrom, float minTo, float maxTo, float valueToScale){
613
float OldRange = (maxFrom - minFrom);
714
float NewRange = (maxTo - minTo);
815

916
return (((valueToScale - minFrom) * NewRange) / OldRange) + minTo;
1017
}
1118

19+
/**
20+
* Used to calculate quickly from 0-16 to 0-1 with less values
21+
**/
22+
public static float BlockToFloatScale(float value){
23+
return rescaleValues(0.0f, 16.0f, 0.0f, 1.0f, value);
24+
}
25+
26+
/**
27+
* Does the same as above except with a Vector3f
28+
**/
29+
public static Vector3f BlockToFloatScaleVector3f(Vector3f BlockScaledVector){
30+
return new Vector3f(BlockToFloatScale(BlockScaledVector.x()),BlockToFloatScale(BlockScaledVector.y()),BlockToFloatScale(BlockScaledVector.z()));
31+
}
32+
1233
}

0 commit comments

Comments
 (0)