diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..c25862fe5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Built-Broken-Lib"] + path = Built-Broken-Lib + url = https://github.com/DarkGuardsman/Built-Broken-Lib.git diff --git a/Built-Broken-Lib b/Built-Broken-Lib new file mode 160000 index 000000000..d240823fa --- /dev/null +++ b/Built-Broken-Lib @@ -0,0 +1 @@ +Subproject commit d240823fa078ac48fa4a5bb846598666f7b5221f diff --git a/src/com/builtbroken/common/Group.java b/src/com/builtbroken/common/Group.java deleted file mode 100644 index a18cab131..000000000 --- a/src/com/builtbroken/common/Group.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.builtbroken.common; - -import java.util.ArrayList; -import java.util.List; - -/** Generic class for link objects of the same class type to each other. - * - * @author Robert Seifert */ -public class Group -{ - private String groupName; - protected List memebers = new ArrayList(); - - public Group(String name, J... js) - { - this.groupName = name; - if (js != null) - { - for (J obj : js) - { - this.addMemeber(obj); - } - } - } - - public List getMembers() - { - return this.memebers; - } - - protected boolean isValid(J obj) - { - return obj != null && !memebers.contains(obj); - } - - public boolean addMemeber(J obj) - { - if (this.isValid(obj)) - { - return memebers.add(obj); - } - return false; - } - - public boolean removeMemeber(J obj) - { - return memebers.remove(obj); - } - - public boolean isMemeber(J obj) - { - return memebers.contains(obj); - } - - public String getName() - { - return this.groupName; - } - - public void setName(String name) - { - this.groupName = name; - } -} diff --git a/src/com/builtbroken/common/Pair.java b/src/com/builtbroken/common/Pair.java deleted file mode 100644 index 28009aae9..000000000 --- a/src/com/builtbroken/common/Pair.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.builtbroken.common; - -/** Container for two objects - * - * @author Robert Seifert */ -public class Pair -{ - private L left; - private R right; - - public Pair(L left, R right) - { - this.left = left; - this.right = right; - } - - public L left() - { - return left; - } - - public R right() - { - return right; - } - - public void setLeft(L l) - { - left = l; - } - - public void setRight(R r) - { - right = r; - } - - @Override - public int hashCode() - { - if (left == null || right == null) - { - super.hashCode(); - } - return left.hashCode() ^ right.hashCode(); - } - - @Override - public boolean equals(Object o) - { - if (o == null) - return false; - if (!(o instanceof Pair)) - return false; - Pair pairo = (Pair) o; - return this.left.equals(pairo.left()) && this.right.equals(pairo.right()); - } - -} \ No newline at end of file diff --git a/src/com/builtbroken/common/Triple.java b/src/com/builtbroken/common/Triple.java deleted file mode 100644 index a240b7d7c..000000000 --- a/src/com/builtbroken/common/Triple.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.builtbroken.common; - -public class Triple -{ - private final A aaa; - private final B bbb; - private final C ccc; - - public Triple(A left, B right, C ccc) - { - this.aaa = left; - this.bbb = right; - this.ccc = ccc; - } - - public A getA() - { - return aaa; - } - - public B getB() - { - return bbb; - } - - public C getC() - { - return ccc; - } - - @Override - public int hashCode() - { - return aaa.hashCode() ^ bbb.hashCode() ^ ccc.hashCode(); - } - - @Override - public boolean equals(Object o) - { - if (o == null) - return false; - if (!(o instanceof Triple)) - return false; - Triple pairo = (Triple) o; - return this.aaa.equals(pairo.getA()) && this.bbb.equals(pairo.getB()) && this.ccc.equals(pairo.getC()); - } - -} \ No newline at end of file diff --git a/src/com/builtbroken/common/User.java b/src/com/builtbroken/common/User.java deleted file mode 100644 index 81ed53dbd..000000000 --- a/src/com/builtbroken/common/User.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.builtbroken.common; - -/** Class to track a user. Mainly used to create groups of users, and is mostly a prefab since it - * only stores a string name. People who use this class should extend it to make better use out of - * the class. - * - * @author Robert Seifert */ -public class User -{ - protected String username; - - public User(String username) - { - this.username = username; - } - - public String getName() - { - return this.username; - } -} diff --git a/src/com/builtbroken/common/Vector.java b/src/com/builtbroken/common/Vector.java deleted file mode 100644 index 615fd0d8e..000000000 --- a/src/com/builtbroken/common/Vector.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.builtbroken.common; - -/** Simple class uses to plot a vector on a line - * - * @author Robert seifert */ -public class Vector -{ - protected float x; - - public Vector(float x) - { - this.x = x; - } - - public int X() - { - return (int) x; - } - - public float XX() - { - return x; - } - - /** Magnitude between two points */ - public float mag(Vector vec) - { - return vec.x - x; - } - - /** Distance to another point */ - public float distance(Vector vec) - { - return Math.abs(mag(vec)); - } - - @Override - public String toString() - { - return super.toString() + "[" + x + "x]"; - } -} diff --git a/src/com/builtbroken/common/Vector2.java b/src/com/builtbroken/common/Vector2.java deleted file mode 100644 index 73c2fb9ba..000000000 --- a/src/com/builtbroken/common/Vector2.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.builtbroken.common; - -/** Simple class to plot a vector on a plane - * - * @author Robert Seifert */ -public class Vector2 extends Vector -{ - protected float y; - - public Vector2(float x, float y) - { - super(x); - this.y = y; - } - - public int Y() - { - return (int) y; - } - - public float YY() - { - return y; - } - - @Override - public String toString() - { - return super.toString() + "[" + y + "y]"; - } -} diff --git a/src/com/builtbroken/common/Vector3.java b/src/com/builtbroken/common/Vector3.java deleted file mode 100644 index 315075fb8..000000000 --- a/src/com/builtbroken/common/Vector3.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.builtbroken.common; - -/** Simple class to plot a vector in a 3D space - * - * @author Robert Seifert */ -public class Vector3 extends Vector2 -{ - protected float z; - - public Vector3(float x, float y, float z) - { - super(x, y); - this.z = z; - } - - public int Z() - { - return (int) z; - } - - public float ZZ() - { - return z; - } - - @Override - public String toString() - { - return super.toString() + "[" + z + "z]"; - } -} diff --git a/src/com/builtbroken/common/Vector4.java b/src/com/builtbroken/common/Vector4.java deleted file mode 100644 index ac5f3cda3..000000000 --- a/src/com/builtbroken/common/Vector4.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.builtbroken.common; - -/** class used to plot a point in a 3D space over time. Also used for ploting a vector in a 4D space - * - * @author Robert seifert */ -public class Vector4 extends Vector3 -{ - protected float time; - - public Vector4(float x, float y, float z, float time) - { - super(x, y, z); - this.time = time; - } - - public float time() - { - return time; - } - - @Override - public String toString() - { - return super.toString() + "[" + time + "t]"; - } -} diff --git a/src/com/builtbroken/common/animation/Joint.java b/src/com/builtbroken/common/animation/Joint.java deleted file mode 100644 index 1ab9ac864..000000000 --- a/src/com/builtbroken/common/animation/Joint.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.builtbroken.common.animation; - -import java.util.HashSet; -import java.util.Set; - -import com.builtbroken.common.Vector3; - -public class Joint -{ - protected Set childJoints = new HashSet(); - protected Joint parentJoint = null; - protected Vector3 offset, boxmin, boxmax, pose; - protected String name = "joint"; - - public Joint(String name, Vector3 boxmin, Vector3 boxmax, Vector3 pose, Joint... joints) - { - this.name = name; - this.boxmin = boxmin; - this.boxmax = boxmax; - this.pose = pose; - for (Joint joint : joints) - { - joint.setParent(this); - childJoints.add(joint); - } - } - - public Joint getParent() - { - return this.parentJoint; - } - - public Vector3 getOffset() - { - return this.offset; - } - - public Vector3 getBoxmin() - { - return this.boxmin; - } - - public Vector3 getBoxmax() - { - return this.boxmax; - } - - public Vector3 getPose() - { - return this.pose; - } - - public String getString() - { - return this.name; - } - - public void setParent(Joint joint) - { - this.parentJoint = joint; - } - -} diff --git a/src/com/builtbroken/common/animation/Skeleton.java b/src/com/builtbroken/common/animation/Skeleton.java deleted file mode 100644 index 4333c777e..000000000 --- a/src/com/builtbroken/common/animation/Skeleton.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.builtbroken.common.animation; - -import java.io.File; - -public class Skeleton -{ - - public void read(File file) - { - - } -} diff --git a/src/com/builtbroken/common/lang/TextHelper.java b/src/com/builtbroken/common/lang/TextHelper.java deleted file mode 100644 index 78b6885a8..000000000 --- a/src/com/builtbroken/common/lang/TextHelper.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.builtbroken.common.lang; - -import java.awt.Color; - -public final class TextHelper -{ - public enum TextColor - { - BLACK("\u00a70", 0x000000, 0, 0, 0), - DARKBLUE("\u00a71", 0x0000AA, 0, 0, 170), - DARKGREEN("\u00a72", 0x00AA00, 0, 170, 0), - DARKAQUA("\u00a73", 0x00AAAA, 0, 170, 170), - DARKRED("\u00a74", 0xAA0000, 170, 0, 0), - PURPLE("\u00a75", 0xAA00AA, 170, 0, 170), - GOLD("\u00a76", 0xFFAA00, 255, 170, 0), - GREY("\u00a77", 0xAAAAAA, 170, 170, 170), - DARKGREY("\u00a78", 0x555555, 85, 85, 85), - INDIGO("\u00a79", 0x5555FF, 85, 85, 255), - BRIGHTGREEN("\u00a7a", 0x55FF55, 85, 255, 85), - AQUA("\u00a7b", 0x55FFFF, 85, 255, 255), - RED("\u00a7c", 0xFF5555, 255, 85, 85), - PINK("\u00a7d", 0xFF55FF, 255, 85, 255), - YELLOW("\u00a7e", 0xFFFF55, 255, 255, 85), - WHITE("\u00a7f", 0xFFFFFF, 255, 255, 255); - - private String colorString; - private int hexadecimal; - private Color colorInstance; - - TextColor(String color, int hexadecimalColor, int red, int green, int blue) - { - colorString = color; - hexadecimal = hexadecimalColor; - colorInstance = new Color(red, green, blue); - } - - /** Retrieves the Hexadecimal integer value for the specified Color - * - * @return The Hexadecimal int for the Color **/ - public int getHexValue() - { - return hexadecimal; - } - - /** Retrieves the java.awt.Color instance for the Color - * - * @return the java.awt.Color instance for this color ***/ - public Color getColor() - { - return colorInstance; - } - - /** Retrieves the String that specifies the color of Text within Minecraft - * - * @return String that can be added to the beginning of another String to specify coloration - * in Minecraft **/ - public String getColorString() - { - return colorString; - } - - /** Retrieves an int Array to retrieve the RGB values for the specified Color. Index 0 is the - * Red value, Index 1 is the Green value, and Index 2 is the Blue value. - * - * @return Array of the primitive type int containing the RGB values for the specified color **/ - public int[] getRGBIntArray() - { - return new int[] { colorInstance.getRed(), colorInstance.getGreen(), colorInstance.getBlue() }; - } - } - - public enum TextFormat - { - RANDOMCHARS("\247k"), - BOLD("\247l"), - STRIKE("\247m"), - UNDERLINE("\247n"), - ITALICS("\247o"), - RESETFORMAT("\247r"); - - private final String formatString; - - TextFormat(String format) - { - this.formatString = format; - } - - public final String getFormatString() - { - return formatString; - } - } -} \ No newline at end of file diff --git a/src/com/builtbroken/common/science/ChemElement.java b/src/com/builtbroken/common/science/ChemElement.java deleted file mode 100644 index 2b7a74bad..000000000 --- a/src/com/builtbroken/common/science/ChemElement.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.builtbroken.common.science; - -/** List of element from the periodic table of elements for any kind of use. Is not complete for all - * parts but each element should have a listed names, symbol, and atomic mass. Atomic number should - * be the placement # in the list. Var ZERO should not be used as its designed to offset the - * placement of all elements by one. As well is returned instead of null. - * - * @Source http://www.periodictable.com/Properties/A/SpecificHeat.an.html - * @source http://www.chemicalelements.com/ - * @source http://www.lenntech.com/periodic/periodic-chart.htm - * @author Robert Seifert */ -public enum ChemElement -{ - /** Placeholder so that hydrogen starts as number one */ - ZERO("ZERO", "ZERO", 0, 0, null, null), - Hydrogen("Hydrogen", "H", 1.00794f, 0.08988f, ElementProperty.nonmetal, MatterPhase.gas, new HeatingData(14.01f, 20.28f, 0.558f, 0.558f, 14300f)), - Helium("Helium", "He", 4.002602f, 0.1785f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(0, 4.22f, 0.02f, 0.083f, 5193.1f)), - Lithium("Lithium", "Li", 6.941f, 0.53f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(543.69f, 1615f, 3f, 147f, 3570f)), - Beryllium("Beryllium", "Be", 9.012182f, 1.8477f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(1560f, 2743f, 7.95f, 297f, 1820f)), - Boron("Boron", "B", 10.811f, 2.46f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(2348f, 4273f, 50f, 507f, 1030f)), - Carbon("Carbon", "C", 12.0107f, 2.26f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(3823f, 4300f, 105f, 715f, 710f)), - Nitrogen("Nitrogen", "N", 14.0067f, 1.251f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(63.05f, 77.36f, 0.36f, 2.79f, 1040)), - Oxygen("Oxygen", "O", 15.9994f, 1.429f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(54.8f, 90.2f, 0.222f, 3.41f, 919f)), - Fluorine("Fluorine", "F", 18.9994f, 1.696f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(53.5f, 85.03f, 0.26f, 3.27f, 824f)), - Neon("Neon", "Ne", 20.1797f, 0.9f, ElementProperty.inertGas, MatterPhase.gas, new HeatingData(24.56f, 27.07f, 0.34f, 1.75f, 1030f)), - Sodium("Sodium", "Na", 22.98976928f, 0.968f, ElementProperty.alkaliMetal, MatterPhase.solid, new HeatingData(370.87f, 1156f, 2.6f, 97.7f, 1230f)), - - Magnesium("Magnesium", "Mg", 24.305f, 1.738f, ElementProperty.alkalineEarthMetal, MatterPhase.solid), - aluminium("aluminium", "Al", 26.9815386f, 2.7f, ElementProperty.otherMetal, MatterPhase.solid), - Silicon("Silicon", "Si", 28.0855f, 2.33f, ElementProperty.otherMetal, MatterPhase.solid), - - Phosphorus("Phosphorus", "P", 30.973762f, 1.823f, ElementProperty.nonmetal, MatterPhase.solid), - Sulphur("Sulphur", "S", 32.065f, 1.96f, ElementProperty.nonmetal, MatterPhase.solid), - Chlorine("Chlorine", "Cl", 35.453f, 3.214f, ElementProperty.halogen, MatterPhase.gas), - - Argon("Argon", "Ar", 39.948f, 1.784f, ElementProperty.inertGas, MatterPhase.gas), - Potassium("Potassium", "K", 39.0983f, 0.856f, ElementProperty.alkaliMetal, MatterPhase.solid), - Calcium("Calcium", "Ca", 40.078f, 1.55f, ElementProperty.alkalineEarthMetal, MatterPhase.solid), - Scandium("Scandium", "Sc", 44.955912f, 2.985f, ElementProperty.transitionMetal, MatterPhase.solid), - - Titanium("Titanium", "Ti", 47.867f, 4.507f, ElementProperty.transitionMetal, MatterPhase.solid), - Vanadium("Vanadium", "V", 50.9415f, 6.11f, ElementProperty.transitionMetal, MatterPhase.solid), - Chromium("Chromium", "Cr", 51.9961f, 7.14f, ElementProperty.transitionMetal, MatterPhase.solid), - - Manganese("Manganese", "Mn", 54.938045f, 7.47f, ElementProperty.transitionMetal, MatterPhase.solid), - Iron("Iron", "Fe", 55.845f, 7.874f, ElementProperty.transitionMetal, MatterPhase.solid), - Cobalt("Cobalt", "Co", 58.933195f, 8.9f, ElementProperty.transitionMetal, MatterPhase.solid), - - Nickel("Nickel", "Ni", 58.6934f, 8.908f, ElementProperty.transitionMetal, MatterPhase.solid), - Copper("Copper", "Cu", 63.546f, 8.92f, ElementProperty.transitionMetal, MatterPhase.solid), - Zinc("Zinc", "Zn", 65.38f, 7.14f, ElementProperty.transitionMetal, MatterPhase.solid), - - Gallium("Gallium", "Ga", 69.723f, 5.904f, ElementProperty.otherMetal, MatterPhase.solid), - Germanium("Germanium", "Ge", 72.64f, 5.323f, ElementProperty.semimetallic, MatterPhase.solid), - Arsenic("Arsenic", "As", 74.9216f, 5.727f, ElementProperty.semimetallic, MatterPhase.solid), - - Selenium("Selenium", "Se", 78.96f, 4.819f, ElementProperty.nonmetal, MatterPhase.solid), - Bromine("Bromine", "Br", 79.904f, 3.12f, ElementProperty.halogen, MatterPhase.liquid), - Krypton("Krypton", "Kr", 83.798f, 3.75f, ElementProperty.inertGas, MatterPhase.gas), - - Rubidium("Rubidium", "Rb", 85.4678f, 1.532f, ElementProperty.alkaliMetal, MatterPhase.solid), - Strontium("Strontium", "Sr", 87.62f, 2.63f, ElementProperty.alkalineEarthMetal, MatterPhase.solid), - Yttrium("Yttrium", "Y", 88.90585f, 4.472f, ElementProperty.transitionMetal, MatterPhase.solid), - - Zirkonium("Zirkonium", "Zr", 91.224f, 6.511f, ElementProperty.transitionMetal, MatterPhase.solid), - Niobium("Niobium", "Nb", 92.90638f, 8.57f, ElementProperty.transitionMetal, MatterPhase.solid), - Molybdaenum("Molybdaenum", "Mo", 95.96f, 10.28f, ElementProperty.transitionMetal, MatterPhase.solid), - - Technetium("Technetium", "Tc", 98f, 11.5f, ElementProperty.transitionMetal, MatterPhase.solid), - Ruthenium("Ruthenium", "Ru", 101.07f, 12.37f, ElementProperty.transitionMetal, MatterPhase.solid), - Rhodium("Rhodium", "Rh", 102.9055f, 12.45f, ElementProperty.transitionMetal, MatterPhase.solid), - - Palladium("Palladium", "Pd", 106.42f, 12.023f, ElementProperty.transitionMetal, MatterPhase.solid), - Silver("Silver", "Ag", 107.8682f, 10.49f, ElementProperty.transitionMetal, MatterPhase.solid), - Cadmium("Cadmium", "Cd", 112.411f, 8.65f, ElementProperty.transitionMetal, MatterPhase.solid), - - Indium("Indium", "In", 114.818f, 7.31f, ElementProperty.otherMetal, MatterPhase.solid), - Tin("Tin", "Sn", 118.71f, 7.31f, ElementProperty.otherMetal, MatterPhase.solid), - Antimony("Antimony", "Sb", 121.76f, 6.697f, ElementProperty.semimetallic, MatterPhase.solid), - - Tellurium("Tellurium", "Te", 127.6f, 6.24f, ElementProperty.semimetallic, MatterPhase.solid), - Iodine("Iodine", "I", 126.90447f, 4.94f, ElementProperty.halogen, MatterPhase.solid), - Xenon("Xenon", "Xe", 131.293f, 5.9f, ElementProperty.inertGas, MatterPhase.gas), - - Cesium("Cesium", "Cs", 132.9054519f, 1.879f, ElementProperty.alkaliMetal, MatterPhase.solid), - Barium("Barium", "Ba", 137.327f, 3.51f, ElementProperty.alkalineEarthMetal, MatterPhase.solid), - Lanthanum("Lanthanum", "La", 138.90547f, 6.146f, ElementProperty.lanthanide, MatterPhase.solid), - - Cerium("Cerium", "Ce", 140.116f, 6.689f, ElementProperty.lanthanide, MatterPhase.solid), - Praseodymium("Praseodymium", "Pr", 140.90765f, 6.64f, ElementProperty.lanthanide, MatterPhase.solid), - Neodymium("Neodymium", "Nd", 144.242f, 7.01f, ElementProperty.lanthanide, MatterPhase.solid), - - Promethium("Promethium", "Pm", 145f, 7.264f, ElementProperty.lanthanide, MatterPhase.solid), - Samarium("Samarium", "Sm", 150.36f, 7.353f, ElementProperty.lanthanide, MatterPhase.solid), - Europium("Europium", "Eu", 151.964f, 5.244f, ElementProperty.lanthanide, MatterPhase.solid), - - Gadolinium("Gadolinium", "Gd", 157.25f, 7.901f, ElementProperty.lanthanide, MatterPhase.solid), - Terbium("Terbium", "Tb", 158.92535f, 8.219f, ElementProperty.lanthanide, MatterPhase.solid), - Dysprosium("Dysprosium", "Dy", 162.5001f, 8.551f, ElementProperty.lanthanide, MatterPhase.solid), - - Holmium("Holmium", "Ho", 164.93032f, 8.795f, ElementProperty.lanthanide, MatterPhase.solid), - Erbium("Erbium", "Er", 167.259f, 9.066f, ElementProperty.lanthanide, MatterPhase.solid), - Thulium("Thulium", "Tm", 168.93421f, 9.321f, ElementProperty.lanthanide, MatterPhase.solid), - - Ytterbium("Ytterbium", "Yb", 173.054f, 6.57f, ElementProperty.lanthanide, MatterPhase.solid), - Lutetium("Lutetium", "Lu", 174.9668f, 9.841f, ElementProperty.lanthanide, MatterPhase.solid), - Hafnium("Hafnium", "Hf", 178.49f, 13.31f, ElementProperty.lanthanide, MatterPhase.solid), - - Tantalum("Tantalum", "Ta", 180.94788f, 16.65f, ElementProperty.transitionMetal, MatterPhase.solid), - Tungsten("Tungsten", "W", 183.84f, 19.25f, ElementProperty.transitionMetal, MatterPhase.solid), - Rhenium("Rhenium", "Re", 186.207f, 21.02f, ElementProperty.transitionMetal, MatterPhase.solid), - - Osmium("Osmium", "Os", 190.23f, 22.59f, ElementProperty.transitionMetal, MatterPhase.solid), - Iridium("Iridium", "Ir", 192.217f, 22.56f, ElementProperty.transitionMetal, MatterPhase.solid), - Platinum("Platinum", "Pt", 192.084f, 21.09f, ElementProperty.transitionMetal, MatterPhase.solid), - - Gold("Gold", "Au", 196.966569f, 19.3f, ElementProperty.transitionMetal, MatterPhase.solid), - Hydrargyrum("Hydrargyrum", "Hg", 200.59f, 13.534f, ElementProperty.transitionMetal, MatterPhase.solid), - Thallium("Thallium", "Tl", 204.3833f, 11.85f, ElementProperty.transitionMetal, MatterPhase.solid), - - Lead("Lead", "Pb", 207.2f, 11.34f, ElementProperty.otherMetal, MatterPhase.solid), - Bismuth("Bismuth", "Bi", 208.980401f, 9.78f, ElementProperty.otherMetal, MatterPhase.solid), - Polonium("Polonium", "Po", 210f, 9.196f, ElementProperty.semimetallic, MatterPhase.solid), - - Astatine("Astatine", "At", 210f, 0, ElementProperty.halogen, MatterPhase.solid), - Radon("Radon", "Rn", 220f, 9.73f, ElementProperty.inertGas, MatterPhase.gas), - Francium("Francium", "Fr", 223f, 0f, ElementProperty.alkaliMetal, MatterPhase.solid), - - Radium("Radium", "Ra", 226f, 5f, ElementProperty.alkalineEarthMetal, MatterPhase.solid), - Actinium("Actinium", "Ac", 227f, 10.07f, ElementProperty.actinide, MatterPhase.solid), - Thorium("Thorium", "Th", 232.03806f, 11.724f, ElementProperty.actinide, MatterPhase.solid), - - Protactinium("Protactinium", "Pa", 231.03588f, 15.37f, ElementProperty.actinide, MatterPhase.solid), - Uranium("Uranium", "U", 238.02891f, 19.05f, ElementProperty.actinide, MatterPhase.solid), - Neptunium("Neptunium", "Np", 237f, 20.45f, ElementProperty.actinide, MatterPhase.solid), - - Plutonium("Plutonium", "Pu", 244f, 19.816f, ElementProperty.actinide, MatterPhase.solid), - Americium("Americium", "Am", 243f, 13.67f, ElementProperty.actinide, MatterPhase.solid), - Curium("Curium", "Cm", 247f, 3.51f, ElementProperty.actinide, MatterPhase.solid), - - Berkelium("Berkelium", "Bk", 247f, 14.78f, ElementProperty.actinide, MatterPhase.solid), - Californium("Californium", "Cf", 251f, 15.1f, ElementProperty.actinide, MatterPhase.solid), - Einsteinium("Einsteinium", "Es", 252f, 0, ElementProperty.actinide, MatterPhase.solid), - - Fermium("Fermium", "Fm", 257f, 0, ElementProperty.actinide, MatterPhase.solid), - Mendelevium("Mendelevium", "Md", 0, 258f, ElementProperty.actinide, MatterPhase.solid), - Nobelium("Nobelium", "No", 259f, 0, ElementProperty.actinide, MatterPhase.solid), - - Lawrencium("Lawrencium", "Lr", 262f, 0, ElementProperty.actinide, MatterPhase.solid), - Rutherfordium("Rutherfordium", "Rf", 261f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Dubnium("Dubnium", "Db", 262f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - - Seaborgium("Seaborgium", "Sg", 266f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Bohrium("Bohrium", "Bh", 264f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Hassium("Hassium", "Hs", 277f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - - Meitnerium("Meitnerium", "Mt", 268f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Ununnilium("Ununnilium", "Ds", 271f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Unununium("Unununium", "Rg", 272f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - - Ununbium("Ununbium", "Uub", 285f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Ununtrium("Ununtrium", "Uut", 284f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Ununquadium("Ununquadium", "Uuq", 289f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - - Ununpentium("Ununpentium", "Uup", 288f, 0, ElementProperty.transitionMetal, MatterPhase.solid), - Ununhexium("Ununhexium", "Uuh", 292f, 0, ElementProperty.transitionMetal, MatterPhase.solid); - - /** value units are (g/cm^3) aka grams per centimeter cubed */ - public float density; - /** value units are (amu) aka atomic mass unit */ - public float atomicMass; - - public String elementName = "element"; - public String[] elementNames; - public String elementSymbol = "element"; - - public ElementProperty classification; - - public MatterPhase normalPhase; - - public HeatingData heatData; - - private ChemElement(String[] name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase) - { - this(name[0], symbol, atomicMass, density, type, defaultPhase); - this.elementNames = name; - } - - private ChemElement(String name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase) - { - this.elementName = name; - this.elementSymbol = symbol; - this.atomicMass = atomicMass; - this.classification = type; - this.normalPhase = defaultPhase; - this.density = density; - } - - private ChemElement(String name, String symbol, float atomicMass, float density, ElementProperty type, MatterPhase defaultPhase, HeatingData heatData) - { - this(name, symbol, atomicMass, density, type, defaultPhase); - this.heatData = heatData; - - } - -} diff --git a/src/com/builtbroken/common/science/ChemicalCompound.java b/src/com/builtbroken/common/science/ChemicalCompound.java deleted file mode 100644 index 90b997e45..000000000 --- a/src/com/builtbroken/common/science/ChemicalCompound.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.builtbroken.common.science; - -public enum ChemicalCompound -{ - /** http://encyclopedia.airliquide.com/encyclopedia.asp?GasID=8#GeneralData */ - BUTANE("Butane", "C4H10", MatterPhase.gas, 58.12f, 2.48f, new HeatingData(133f, 274f, 1379.23f, 6634.23f, 88f)), - METHANE("Methane", "CH4", MatterPhase.gas, 16.043f, 1.819f, new HeatingData(90.65f, 111.55f, 3656.67f, 31789.56f, 27f)), - WATER("Water", "H20", MatterPhase.liquid, 18.01528f, 1000f, new HeatingData(274.15f, 373.13f, 18539.817f, 126004.1476f, 4.24f)), - AIR("Air", "", MatterPhase.gas, 29f, .125f, null); - - /** Formula */ - public final String formula; - /** IUPAC ID */ - public final String compoundName; - /** g/mol */ - public final float molarMass; - /** g/cm^3 */ - public final float density; - - public final MatterPhase defaultPhase; - - public final HeatingData heatingData; - - private ChemicalCompound(String name, String formula, MatterPhase phase, float molarMass, float density, HeatingData data) - { - this.compoundName = name; - this.formula = formula; - this.molarMass = molarMass; - this.density = density; - this.defaultPhase = phase; - this.heatingData = data; - } -} diff --git a/src/com/builtbroken/common/science/ElementProperty.java b/src/com/builtbroken/common/science/ElementProperty.java deleted file mode 100644 index 89791ed5c..000000000 --- a/src/com/builtbroken/common/science/ElementProperty.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.builtbroken.common.science; - -public enum ElementProperty -{ - nonmetal("Non-metal"), - inertGas("Inert gas"), - halogen("Halogen"), - alkaliMetal("Alkali metal"), - alkalineEarthMetal("Alkaline earth metal"), - semimetallic("Metalloid"), - otherMetal("Other metal"), - transitionMetal("Transition metal"), - lanthanide("Lanthanide"), - actinide("Actinide"); - - final String name; - - private ElementProperty(String name) - { - this.name = name; - } - - @Override - public String toString() - { - return name; - } -} diff --git a/src/com/builtbroken/common/science/FormulaHelper.java b/src/com/builtbroken/common/science/FormulaHelper.java deleted file mode 100644 index 2bfe4a7ee..000000000 --- a/src/com/builtbroken/common/science/FormulaHelper.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.builtbroken.common.science; - -/** Helper class that does the work of basic formulas. - * - * @Note: Unless stated other wise the formulas don't care what the units are as long as the match - * up. Eg pressure can be in any unit as long as all pressures for the method are the same unit - * - * @Note: Some of these methods are very simple but they remove the confusion involved in rewriting - * the code for each use - * - * @author Robert Seifert */ -public class FormulaHelper -{ - public static final float ACCELERATION_EARTH = 9.80665f; - public static final float ACCELERATION_MOON = 1.622f; - - /** Gay-Lussac's Law (P1/T1 = P2/T2) - * - * @param pressure - original pressure - * @param temp - original tempature - * @param newTemp - new tempature - * @return pressure */ - public static float getPressure(float pressure, float temp, float newTemp) - { - return getPressure(pressure, delta(temp, newTemp)); - } - - public static float getPressure(float pressure, float deltaTemp) - { - return pressure * deltaTemp; - } - - public static float calcWeight(float mass, float gravity) - { - return mass * gravity; - } - - public static float calcForce(float mass, float acceleration) - { - return mass * acceleration; - } - - /** Gets the number of moles of the object from the mass of the object, and the materials - * molarMass - * - * @param molarMass - mass of one mole of the material - * @param objectMass - mass of the object made of the material - * @return number of moles of the material */ - public static float moles(float molarMass, float objectMass) - { - return objectMass / molarMass; - } - - /** Calculates change from original value to new value - * - * @param a - original value - * @param b - new value - * @return change in value from original to new */ - public static float delta(float a, float b) - { - //Yes i know its simple but it removes confusion - return b - a; - } -} diff --git a/src/com/builtbroken/common/science/HeatingData.java b/src/com/builtbroken/common/science/HeatingData.java deleted file mode 100644 index 2e06790d6..000000000 --- a/src/com/builtbroken/common/science/HeatingData.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.builtbroken.common.science; - -/** Used to store values related to temperature and heat of a material. Temperatures are in kelvin, - * and heat in joules - * - * @author DarkGuardsman */ -public class HeatingData -{ - /** (K) temperature kelvin that this material goes from solid to liquid, or back */ - public float meltingPoint; - /** (K) temperature kelvin that this material goes from liquid to gas, or back */ - public float boilingPoint; - /** (kJ/mol) Energy per gram needed to make the final leap from solid to liquid */ - public float fisionHeat; - /** (kJ/mol) Energy per gram needed to make the final leap from liquid to gas */ - public float vaporHeat; - /** (j/kg K) Heating rate, at constant volume if gas */ - public float specificHeat; - /** How much the material expands */ - public float thermalExpasion; - /** (W/(m K)) How well does the material conduct heat */ - public float thermalConductivity; - - public HeatingData(float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat) - { - this.meltingPoint = meltingPoint; - this.boilingPoint = boilingPoint; - this.fisionHeat = fisionHeat; - this.vaporHeat = vaporHeat; - this.specificHeat = specificHeat; - } - - public HeatingData(float meltingPoint, float boilingPoint, float fisionHeat, float vaporHeat, float specificHeat, float thermalExpansion, float thermalConductivity) - { - this(meltingPoint, boilingPoint, fisionHeat, vaporHeat, specificHeat); - this.thermalConductivity = thermalConductivity; - this.thermalExpasion = thermalExpansion; - } -} diff --git a/src/com/builtbroken/common/science/MatterPhase.java b/src/com/builtbroken/common/science/MatterPhase.java deleted file mode 100644 index 75b547b24..000000000 --- a/src/com/builtbroken/common/science/MatterPhase.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.builtbroken.common.science; - -public enum MatterPhase -{ - solid(), - liquid(), - gas(), - plasma(); -} diff --git a/src/com/builtbroken/common/science/units/ElectricUnit.java b/src/com/builtbroken/common/science/units/ElectricUnit.java deleted file mode 100644 index 49c455d61..000000000 --- a/src/com/builtbroken/common/science/units/ElectricUnit.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.builtbroken.common.science.units; - -/** Units of measure for work with electricity - * - * @author Robert Seifert */ -public enum ElectricUnit -{ - AMPERE("Amp", "I"), - AMP_HOUR("Amp Hour", "Ah"), - VOLTAGE("Volt", "V"), - WATT("Watt", "W"), - WATT_HOUR("Watt Hour", "Wh"), - RESISTANCE("Ohm", "R"), - CONDUCTANCE("Siemen", "S"), - JOULES("Joule", "J"); - - public String name; - public String symbol; - - private ElectricUnit(String name, String symbol) - { - this.name = name; - this.symbol = symbol; - } - - public String getPlural() - { - return this.name + "s"; - } -} diff --git a/src/com/builtbroken/common/science/units/ForceUnit.java b/src/com/builtbroken/common/science/units/ForceUnit.java deleted file mode 100644 index ed7509ecc..000000000 --- a/src/com/builtbroken/common/science/units/ForceUnit.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.builtbroken.common.science.units; - -/** Units of measure for force - * - * @author Rsobert Seifert */ -public enum ForceUnit -{ - N(), - dyn(), - kp(), - Ib(), - pdl(); -} diff --git a/src/com/builtbroken/common/science/units/ImperialUnits.java b/src/com/builtbroken/common/science/units/ImperialUnits.java deleted file mode 100644 index 0c30b81e8..000000000 --- a/src/com/builtbroken/common/science/units/ImperialUnits.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.builtbroken.common.science.units; - -/** @Source http://en.wikipedia.org/wiki/Imperial_units - * @author Robert Seifert */ -public enum ImperialUnits -{ - thou("thou", "th", (1 / 12000)), - inch("inch", "in", (1 / 12)), - foot("foot", "ft", 1), - yard("yard", "yd", 3), - chain("chain", "ch", 66), - furlong("furlong", "fur", 660), - mile("mile", "mi", 5280), - - /** Not official used anymore */ - league("league", "lea", 15840), - - /** Maritime units */ - fathom("fathom", "ftm", 6.08f), - /** Maritime units */ - cable("cable", "", 608), - /** Maritime units */ - nautical("nautical mile", "", 6080), - - /** Gunter's sruvey unit */ - link("link", "", (66 / 100)), - /** Gunter's sruvey unit */ - rod("rod", "", (66 / 4)); - - public String name, symbol; - float toFeet; - - public static final ImperialUnits[] mainUnits = { inch, foot, yard, mile }; - - private ImperialUnits(String name, String symbol, float toFeet) - { - this.name = name; - this.symbol = symbol; - this.toFeet = toFeet; - } - - public static float convert(ImperialUnits a, ImperialUnits b, float value) - { - value *= a.toFeet; - value /= b.toFeet; - return value; - } - - public float convert(ImperialUnits unit, float value) - { - return ImperialUnits.convert(this, unit, value); - } - -} diff --git a/src/com/builtbroken/common/science/units/MetricUnit.java b/src/com/builtbroken/common/science/units/MetricUnit.java deleted file mode 100644 index 1bcbd1ede..000000000 --- a/src/com/builtbroken/common/science/units/MetricUnit.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.builtbroken.common.science.units; - -/** Metric measurement system units - * - * @author Robert Seifert */ -public enum MetricUnit -{ - MICRO("Micro", "u", 0.000001f), - MILLI("Milli", "m", 0.001f), - BASE("", "", 1), - KILO("Kilo", "k", 1000f), - MEGA("Mega", "M", 1000000f), - GIGA("Giga", "G", 1000000000f), - TERA("Tera", "T", 1000000000000f), - PETA("Peta", "P", 1000000000000000f), - EXA("Exa", "E", 1000000000000000000f), - ZETTA("Zetta", "Z", 1000000000000000000000f), - YOTTA("Yotta", "Y", 1000000000000000000000000f); - - /** long name for the unit */ - public String name; - /** short unit version of the unit */ - public String symbol; - /** Point by which a number is consider to be of this unit */ - public float value; - - private MetricUnit(String name, String symbol, float value) - { - this.name = name; - this.symbol = symbol; - this.value = value; - } - - public String getName(boolean getShort) - { - if (getShort) - { - return symbol; - } - else - { - return name; - } - } - - /** Divides the value by the unit value start */ - public double process(double value) - { - return value / this.value; - } - - /** Checks if a value is above the unit value start */ - public boolean isAbove(float value) - { - return value > this.value; - } - - /** Checks if a value is lower than the unit value start */ - public boolean isBellow(float value) - { - return value < this.value; - } - - public static float convert(MetricUnit a, MetricUnit b, float value) - { - value *= a.value; - value /= b.value; - return value; - } - - public float convert(MetricUnit unit, float value) - { - return MetricUnit.convert(this, unit, value); - } - - public static String applyUnits(float value, int decimalPlaces, float multiplier) - { - String prefix = ""; - if (value < 0) - { - value = Math.abs(value); - prefix = "-"; - } - value *= multiplier; - - if (value == 0) - { - return value + " "; - } - else - { - for (int i = 0; i < MetricUnit.values().length; i++) - { - MetricUnit lowerMeasure = MetricUnit.values()[i]; - if (lowerMeasure.isBellow(value) && lowerMeasure.ordinal() == 0) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces); - } - if (lowerMeasure.ordinal() + 1 >= MetricUnit.values().length) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces); - } - MetricUnit upperMeasure = MetricUnit.values()[i + 1]; - if ((lowerMeasure.isAbove(value) && upperMeasure.isBellow(value)) || lowerMeasure.value == value) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces); - } - } - } - - return prefix + roundDecimals(value, decimalPlaces); - } - - /** Rounds a number to a specific number place places - * - * @param The number - * @return The rounded number */ - public static double roundDecimals(double d, int decimalPlaces) - { - int j = (int) (d * Math.pow(10, decimalPlaces)); - return j / Math.pow(10, decimalPlaces); - } -} diff --git a/src/com/builtbroken/common/science/units/PressureUnit.java b/src/com/builtbroken/common/science/units/PressureUnit.java deleted file mode 100644 index bb86fd665..000000000 --- a/src/com/builtbroken/common/science/units/PressureUnit.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.builtbroken.common.science.units; - -/** Enum that stores common units used to measure pressure. - * - * @source http://en.wikipedia.org/wiki/Atmosphere_(unit) - * @source http://en.wikipedia.org/wiki/Dyne - * @Source http://en.wikipedia.org/wiki/Kilogram-force - * @Source http://www.statman.info/conversions/pressure.html - * @author Robert Seifer */ -public enum PressureUnit -{ - Pa("Pascal", "Pa", "N/m^2", "Newtons over meter squared", 1f), - Bar("Bar", "bar", "", 100000f), - at("Technical atmoshphere", "at", "kp/cm^2", "kilopound over centimeter squared", 98066.5f), - atm("Standard atmosphere", "atm", "p", 101325f), - Torr("Torr", "Torr", "mmHg", "milimeters of mercury", 133.3224f), - psi("Pounds per square inch", "psi", "Ibf/in^2", "poundforce per square inch", 6894.8f); - - String units; - String unitsDetaled; - String symbol; - String name; - float conversionToPa; - - private PressureUnit(String name, String symbol, String units, float conversionToPa) - { - this.name = name; - this.symbol = symbol; - this.units = units; - this.conversionToPa = conversionToPa; - } - - private PressureUnit(String name, String symbol, String units, String detailedUnits, float conversionToPa) - { - this(name, symbol, units, conversionToPa); - this.unitsDetaled = detailedUnits; - } - - public static float convert(PressureUnit a, PressureUnit b, float pressure) - { - pressure *= a.conversionToPa; - pressure /= b.conversionToPa; - return pressure; - } - - public float convert(PressureUnit unit, float pressure) - { - return PressureUnit.convert(this, unit, pressure); - } - - public String toString(float pressure, boolean shortName) - { - return MetricUnit.applyUnits(pressure, 2, 1) + " " + (shortName ? this.symbol : this.name); - } - -} diff --git a/src/com/builtbroken/common/science/units/TemperatureUnit.java b/src/com/builtbroken/common/science/units/TemperatureUnit.java deleted file mode 100644 index 1e99a257f..000000000 --- a/src/com/builtbroken/common/science/units/TemperatureUnit.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.builtbroken.common.science.units; - -/** Units of measure for temperature - * - * @author Robert Seifert */ -public enum TemperatureUnit -{ - Fahrenheit("Fahrenheit", "F", new ITempConversion() - { - @Override - public float toKelvin(float temp) - { - return (float) ((temp + 459.67) * (5 / 9)); - } - - @Override - public float fromKelvin(float temp) - { - return (float) ((temp * (9 / 5)) - 459.67); - } - - }), - Celsius("Celsius", "C", new ITempConversion() - { - @Override - public float toKelvin(float temp) - { - return (float) (temp + 273.15); - } - - @Override - public float fromKelvin(float temp) - { - return (float) (temp - 273.15); - } - - }), - Rankine("Rankine", "R", new ITempConversion() - { - @Override - public float toKelvin(float temp) - { - return (temp * (5 / 9)); - } - - @Override - public float fromKelvin(float temp) - { - return temp * (9 / 5); - } - - }), - Kelvin("Degrees", "F", new ITempConversion() - { - @Override - public float toKelvin(float temp) - { - return temp; - } - - @Override - public float fromKelvin(float temp) - { - return temp; - } - - }); - - public String name, symbol; - public ITempConversion conversion; - - private TemperatureUnit(String name, String symbol, ITempConversion conversion) - { - this.name = name; - this.symbol = symbol; - this.conversion = conversion; - } - - public static float convert(TemperatureUnit a, TemperatureUnit b, float temperature) - { - temperature = a.conversion.toKelvin(temperature); - return b.conversion.fromKelvin(temperature); - } - - public float convert(TemperatureUnit unit, float temperature) - { - return TemperatureUnit.convert(this, unit, temperature); - } - - public static interface ITempConversion - { - public float toKelvin(float temp); - - public float fromKelvin(float temp); - } -} diff --git a/src/com/builtbroken/common/science/units/UnitHelper.java b/src/com/builtbroken/common/science/units/UnitHelper.java deleted file mode 100644 index 943719646..000000000 --- a/src/com/builtbroken/common/science/units/UnitHelper.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.builtbroken.common.science.units; - -import java.util.ArrayList; -import java.util.List; - -import com.builtbroken.common.Pair; - -public class UnitHelper -{ - public static final float FEET_TO_METERS = 0.3048f; - public static final float METERS_TO_FEET = 3.28084f; - - public static List numbers = new ArrayList(); - - static - { - numbers.add('0'); - numbers.add('1'); - numbers.add('2'); - numbers.add('3'); - numbers.add('4'); - numbers.add('5'); - numbers.add('6'); - numbers.add('7'); - numbers.add('8'); - numbers.add('9'); - } - - public float convert(ImperialUnits a, MetricUnit b, float value) - { - return b.convert(MetricUnit.BASE, a.convert(ImperialUnits.foot, value) * FEET_TO_METERS); - - } - - public float convert(MetricUnit a, ImperialUnits b, float value) - { - return b.convert(ImperialUnits.foot, a.convert(MetricUnit.BASE, value) * METERS_TO_FEET); - } - - public Pair parseString(String input) - { - Pair def = null; - if (input != null && !input.isEmpty()) - { - String editedString = input; - char[] chars = input.toCharArray(); - Object unitEnumValue = null; - - String numberAsString = ""; - float number = 0; - String units = ""; - int toPowerOf = 1; - int timeTenToPowerOF = 1; - - //Get number first - for (int i = 0; i < chars.length; i++) - { - char c = chars[i]; - if (numbers.contains(c)) - { - numberAsString += c; - } - else - { - break; - } - } - try - { - number = Float.parseFloat(numberAsString); - } - catch (Exception e) - { - - } - editedString.replaceAll("[0-9]", ""); - chars = editedString.toCharArray(); - //Check if number is being times by 10 to the power of something - if (chars != null) - { - if (chars.length >= 5 && chars[0] == 'x' && chars[1] == '1' && chars[2] == '0' && chars[3] == '^' && numbers.contains(chars[4])) - { - timeTenToPowerOF = Integer.parseInt("" + chars[4], 1); - editedString = editedString.substring(5); - } - else if (chars.length >= 2 && chars[0] == '^' && numbers.contains(chars[1])) - { - toPowerOf = Integer.parseInt("" + chars[1], 1); - editedString = editedString.substring(2); - } - } - - //TODO detect units - return new Pair(unitEnumValue, number); - } - - return def; - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double - * @param suggestValue - Used by string parsing in case it fails and you want to return a - * default value */ - public static int tryToParseInt(Object var, int suggestValue) - { - if (var instanceof String) - { - try - { - return Integer.parseInt((String) var); - } - catch (Exception e) - { - - } - } - if (var instanceof Integer || var instanceof Float || var instanceof Double) - { - return (Integer) var; - } - - return suggestValue; - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double */ - public static int tryToParseInt(Object var) - { - return tryToParseInt(var, 0); - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double - * @param suggestValue - Used by string parsing in case it fails and you want to return a - * default value */ - public static Double tryToParseDouble(Object var, double suggestValue) - { - if (var instanceof String) - { - try - { - return Double.parseDouble((String) var); - } - catch (Exception e) - { - - } - } - if (var instanceof Integer || var instanceof Float || var instanceof Double) - { - return (Double) var; - } - - return suggestValue; - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double */ - public static Double tryToParseDouble(Object var) - { - return tryToParseDouble(var, 0); - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double - * @param suggestValue - Used by string parsing in case it fails and you want to return a - * default value */ - public static Float tryToParseFloat(Object var, float suggestValue) - { - if (var instanceof String) - { - try - { - return Float.parseFloat((String) var); - } - catch (Exception e) - { - - } - } - if (var instanceof Integer || var instanceof Float || var instanceof Double) - { - return (Float) var; - } - - return suggestValue; - } - - /** Tries to parse a value that may be anything. - * - * @param var - String, Integer, Float, Double - * @return Zero if it fails to parse the value */ - public static Float tryToParseFloat(Object var) - { - return tryToParseFloat(var, 0); - } -} diff --git a/src/dark/core/prefab/invgui/GuiButtonImage (Robert Seifert's conflicted copy 2013-11-29).java b/src/dark/core/prefab/invgui/GuiButtonImage (Robert Seifert's conflicted copy 2013-11-29).java new file mode 100644 index 000000000..e45168b72 --- /dev/null +++ b/src/dark/core/prefab/invgui/GuiButtonImage (Robert Seifert's conflicted copy 2013-11-29).java @@ -0,0 +1,87 @@ +package dark.core.prefab.invgui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import dark.core.common.DarkMain; + +@SideOnly(Side.CLIENT) +public class GuiButtonImage extends GuiButton +{ + public static final ResourceLocation TEXTURE = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.GUI_DIRECTORY + "gui_button.png"); + + private ButtonIcon buttonIcon = ButtonIcon.BLANK; + + public GuiButtonImage(int buttonID, int xx, int yy, ButtonIcon icon) + { + super(buttonID, xx, yy, 20, 20, ""); + this.buttonIcon = icon; + this.width = icon.sizeX; + this.height = icon.sizeY; + } + + /** Draws this button to the screen. */ + @Override + public void drawButton(Minecraft mc, int width, int hight) + { + if (this.drawButton) + { + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean hovering = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height; + int vv = buttonIcon.vv; + int uu = buttonIcon.uu; + if (hovering) + { + vv += this.height; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, uu, vv, this.width, this.height); + } + } + + /** Checks to see if the x and y coords are intersecting with the button. */ + public boolean isIntersect(int x, int y) + { + return x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; + } + + public static enum ButtonIcon + { + PERSON(0, 0), + ARROW_LEFT(30, 0, 10, 10), + ARROW_RIGHT(20, 0, 10, 10), + ARROW_DOWN(30, 20, 10, 10), + ARROW_UP(20, 20, 10, 10), + CHEST(60, 0), + LOCKED(80, 0), + UNLOCKED(100, 0), + BLANK(120, 0), + RED_ON(140, 0), + RED_OFF(160, 0), + FURNACE_OFF(180, 0), + FURNACE_ON(200, 0); + + int vv, uu; + int sizeX = 20, sizeY = 20; + + private ButtonIcon(int xx, int yy) + { + this.vv = xx; + this.uu = yy; + } + + private ButtonIcon(int xx, int yy, int cx, int cy) + { + this(xx, yy); + this.sizeX = cx; + this.sizeY = cy; + } + } +} \ No newline at end of file