diff options
author | draknyte1 <draknyte1@hotmail.com> | 2017-02-07 14:16:52 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2017-02-07 14:16:52 +1000 |
commit | 018fc6e51683545fbdb4c0d76d80d6db3a982fbb (patch) | |
tree | 9bb8d88435b6ec689c743eaba15123ee3b3e4598 /src/Java/gtPlusPlus/core/util | |
parent | 2a688e006c07c1240966c2829906a1752031153c (diff) | |
download | GT5-Unofficial-018fc6e51683545fbdb4c0d76d80d6db3a982fbb.tar.gz GT5-Unofficial-018fc6e51683545fbdb4c0d76d80d6db3a982fbb.tar.bz2 GT5-Unofficial-018fc6e51683545fbdb4c0d76d80d6db3a982fbb.zip |
+ Added a returnLargestNumber function to MathUtils.java
+ Wrote up some really bad version parsing code, will replace with a Regex function later.
% Changed Growthcraft FishTrap handling to support newer versions.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 86 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/math/MathUtils.java | 13 |
2 files changed, 99 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 1e9661dd30..db8ed87231 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -19,6 +19,7 @@ import java.lang.reflect.Method; import java.util.*; import net.minecraft.block.Block; +import net.minecraft.block.Block.SoundType; import net.minecraft.entity.Entity; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; @@ -536,6 +537,66 @@ public class Utils { return output; } + + public static String[] parseVersion(String version){ + return parseVersion(version, "//."); + } + + public static String[] parseVersion(String version, String delimiter){ + String[] versionArray = version.split(delimiter); + return versionArray; + } + + public static Versioning compareModVersion (String currentVersion, String expectedVersion){ + return compareModVersion(currentVersion, expectedVersion, "//."); + } + + public static Versioning compareModVersion (String currentVersion, String expectedVersion, String delimiter){ + String[] a = parseVersion(currentVersion, delimiter); + String[] b = parseVersion(expectedVersion, delimiter); + int[] c = new int[a.length]; + int[] d = new int[b.length]; + for (int r=0;r<a.length;r++){ + c[r]=Integer.parseInt(a[r]); + } + for (int r=0;r<b.length;r++){ + d[r]=Integer.parseInt(b[r]); + } + Versioning[] e = new Versioning[MathUtils.returnLargestNumber(c.length, d.length)]; + for (int r=0;r<e.length;r++){ + + + if (c[r] > d[r]){ + e[r] = Versioning.NEWER; + } + else if (c[r] < d[r]){ + e[r] = Versioning.OLDER; + } + else if (c[r] == d[r]){ + e[r] = Versioning.EQUAL; + } + } + + for (int r=0;r<e.length;r++){ + if (e[0] == Versioning.NEWER){ + return Versioning.NEWER; + } + else if (e[0] == Versioning.OLDER){ + return Versioning.OLDER; + } + else { + if (e[r] == Versioning.OLDER){ + + } + + return Versioning.NEWER; + } + } + + return null; + } + + public static ToolMaterial generateToolMaterialFromGT(Materials gtMaterial){ String name = Utils.sanitizeString(gtMaterial.mDefaultLocalName); @@ -561,6 +622,31 @@ public class Utils { return temp; } + + + + + + + + + + + + + public static enum Versioning { + EQUAL(0), + NEWER(1), + OLDER(-1); + private int versioningInfo; + private Versioning (final int versionStatus){ + this.versioningInfo = versionStatus; + } + public int getTexture() { + return versioningInfo; + } + } + } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index c864df491c..a7cb916d0d 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -266,5 +266,18 @@ public class MathUtils { } return Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); } + + + public final static int returnLargestNumber(int a, int b){ + if (a > b){ + return a; + } + else if (a == b){ + return a; + } + else { + return b; + } + } } |