diff options
author | â€huajijam <strhuaji@gmail.com> | 2019-04-25 23:37:09 +0800 |
---|---|---|
committer | â€huajijam <strhuaji@gmail.com> | 2019-04-25 23:37:09 +0800 |
commit | ff60c00c1fc17acf9200cdf794c185ee329b8446 (patch) | |
tree | 1372baf2a6a08cc34e9771e5826bb6ee492b2428 /src/Java/gtPlusPlus/core/util | |
parent | de9f7710d6f32af0d941085e1029a106b5bc22ff (diff) | |
parent | fccb5447bc424c482f45d3d41e037bdbbd99d823 (diff) | |
download | GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.tar.gz GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.tar.bz2 GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.zip |
Automatic synchronization
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 13 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/math/MathUtils.java | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index d032384638..3b3ba88e88 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -31,6 +31,7 @@ import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -959,5 +960,17 @@ public class Utils { public static long getTicksFromSeconds(long aSeconds) { return (aSeconds*20); } + + public static byte getTier(long l) { + byte i = -1; + do { + ++i; + if (i >= GT_Values.V.length) { + return i; + } + } while (l > GT_Values.V[i]); + i = (byte) MathUtils.getValueWithinRange(i, 0, 15); + return i; + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index f9a4d8f548..4ba9d54271 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -692,4 +692,9 @@ public class MathUtils { return Math.max(Math.min(aInput, aMax), aMin); } + public static int getValueWithinRange(byte aInput, int aMin, int aMax) { + int aAmount = Math.max(Math.min(aInput, aMax), aMin); + return aAmount; + } + } |