diff options
author | Alkalus <draknyte1@hotmail.com> | 2016-09-19 20:08:42 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-19 20:08:42 +1000 |
commit | 9f386c3c2914ba786ece2afddb8eaa6df80a1adc (patch) | |
tree | a46fe4cc2ccd26ff83f3de8eeba7d3abb7aea58c /src/Java/gtPlusPlus/core/material/Material.java | |
parent | 6c74b062034508a0ef00a68c5b4c164b3f155fc4 (diff) | |
parent | 2c4e3716a4b72f67be3bde170096394a39c80480 (diff) | |
download | GT5-Unofficial-9f386c3c2914ba786ece2afddb8eaa6df80a1adc.tar.gz GT5-Unofficial-9f386c3c2914ba786ece2afddb8eaa6df80a1adc.tar.bz2 GT5-Unofficial-9f386c3c2914ba786ece2afddb8eaa6df80a1adc.zip |
Merge pull request #13 from draknyte1/NewMatSystem
New Back-end systems for dynamic Material (Alloys) and Tool generation.
Also fixes a few issues with other things, which were noticed during development of the new systems.
Diffstat (limited to 'src/Java/gtPlusPlus/core/material/Material.java')
-rw-r--r-- | src/Java/gtPlusPlus/core/material/Material.java | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java new file mode 100644 index 0000000000..2939016798 --- /dev/null +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -0,0 +1,154 @@ +package gtPlusPlus.core.material; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.item.ItemStack; + +public class Material { + + final String unlocalizedName; + final String localizedName; + + private MaterialStack[] materialInput = new MaterialStack[4]; + + final short[] RGBA; + + final boolean usesBlastFurnace; + + final int meltingPointK; + final int boilingPointK; + final int meltingPointC; + final int boilingPointC; + final long vProtons; + final long vNeutrons; + final long vMass; + + public Material(String materialName, short[] rgba, int meltingPoint, int boilingPoint, long protons, long neutrons, boolean blastFurnace, MaterialStack[] inputs){ + + this.unlocalizedName = Utils.sanitizeString(materialName); + this.localizedName = materialName; + this.RGBA = rgba; + this.meltingPointC = meltingPoint; + if (boilingPoint == 0){ + boilingPoint = meltingPoint*4; + } + this.boilingPointC = boilingPoint; + this.meltingPointK = (int) MathUtils.celsiusToKelvin(meltingPointC); + this.boilingPointK = (int) MathUtils.celsiusToKelvin(boilingPointC); + this.vProtons = protons; + this.vNeutrons = neutrons; + this.vMass = getMass(); + this.usesBlastFurnace = blastFurnace; + + if (inputs == null){ + this.materialInput = null; + } + else { + if (inputs.length != 0){ + for (int i=0; i < inputs.length; i++){ + if (inputs[i] != null){ + this.materialInput[i] = inputs[i]; + } + } + } + } + Utils.LOG_INFO("Creating a Material instance for "+materialName); + Utils.LOG_INFO("Protons: "+vProtons); + Utils.LOG_INFO("Neutrons: "+vNeutrons); + Utils.LOG_INFO("Mass: "+vMass+"/units"); + Utils.LOG_INFO("Melting Point: "+meltingPointC+"C."); + Utils.LOG_INFO("Boiling Point: "+boilingPointC+"C."); + } + + public String getLocalizedName(){ + return localizedName; + } + + public String getUnlocalizedName(){ + return unlocalizedName; + } + + public short[] getRGBA(){ + return RGBA; + } + + public long getProtons() { + return vProtons; + } + + public long getNeutrons() { + return vNeutrons; + } + + public long getMass() { + return vProtons + vNeutrons; + } + + public int getMeltingPoint_C() { + return meltingPointC; + } + + public int getBoilingPoint_C() { + return boilingPointC; + } + + public boolean requiresBlastFurnace(){ + return usesBlastFurnace; + } + + public ItemStack getDust(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+unlocalizedName, stacksize); + } + + public ItemStack getSmallDust(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+unlocalizedName, stacksize); + } + + public ItemStack getTinyDust(int stacksize){ + return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+unlocalizedName, stacksize); + } + + public ItemStack[] getValidInputStacks(){ + return UtilsItems.validItemsForOreDict(unlocalizedName); + } + + public ItemStack[] getMaterialComposites(){ + //Utils.LOG_INFO("Something requested the materials needed for "+localizedName); + if (materialInput != null && materialInput.length >= 1){ + ItemStack[] temp = new ItemStack[materialInput.length]; + for (int i=0;i<materialInput.length;i++){ + //Utils.LOG_INFO("i:"+i); + ItemStack testNull = null; + try { + testNull = materialInput[i].getDustStack(); + } catch (Throwable r){ + Utils.LOG_INFO("Failed gathering material stack for "+localizedName+"."); + Utils.LOG_INFO("What Failed: Length:"+materialInput.length+" current:"+i); + } + try { + if (testNull != null){ + //Utils.LOG_INFO("not null"); + temp[i] = materialInput[i].getDustStack(); + } + } catch (Throwable r){ + Utils.LOG_INFO("Failed setting slot "+i+", using "+localizedName); + } + } + return temp; + } + return new ItemStack[]{}; + } + + public int[] getMaterialCompositeStackSizes(){ + if (materialInput != null && materialInput.length >= 1){ + int[] temp = new int[materialInput.length]; + for (int i=0;i<materialInput.length;i++){ + temp[i] = materialInput[i].getDustStack().stackSize; + } + return temp; + } + return new int[]{}; + } + +} |