diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-24 02:39:52 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-10-24 02:39:52 +1000 |
commit | e76f9156bea6c2f17d7e2a06744f475de7252da9 (patch) | |
tree | 39b21e7bf9ef8545155713f34aee8b1206417cd8 /src/Java/gtPlusPlus/core/material/MaterialStack.java | |
parent | 4c30de81baeb39872215a5af47feab8378e9b627 (diff) | |
download | GT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.tar.gz GT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.tar.bz2 GT5-Unofficial-e76f9156bea6c2f17d7e2a06744f475de7252da9.zip |
+ Finally finished the Chemical Compound Tooltips. Still needs formatting improvements, but the figures and compound should be correct.
☼ Broke Mixer recipes.
Diffstat (limited to 'src/Java/gtPlusPlus/core/material/MaterialStack.java')
-rw-r--r-- | src/Java/gtPlusPlus/core/material/MaterialStack.java | 100 |
1 files changed, 77 insertions, 23 deletions
diff --git a/src/Java/gtPlusPlus/core/material/MaterialStack.java b/src/Java/gtPlusPlus/core/material/MaterialStack.java index 5e076e6e70..8d9de3faf4 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/Java/gtPlusPlus/core/material/MaterialStack.java @@ -1,24 +1,67 @@ package gtPlusPlus.core.material; import gtPlusPlus.core.util.item.UtilsItems; + +import java.math.BigDecimal; +import java.math.RoundingMode; + import net.minecraft.item.ItemStack; public class MaterialStack { - - final int vAmount; + + final int[] vAmount; final Material stackMaterial; final double percentageToUse; - - public MaterialStack(Material inputs, double percentage){ + + public MaterialStack(Material inputs, double partOutOf100){ this.stackMaterial = inputs; - this.percentageToUse = percentage; - this.vAmount = getDustCount(); - - + this.percentageToUse = partOutOf100; + this.vAmount = math(partOutOf100); + + + } + + private int[] math(double val){ + //Cast to a BigDecimal to round it. + BigDecimal bd = new BigDecimal(val).setScale(2, RoundingMode.HALF_EVEN); + val = bd.doubleValue(); + //Split the string into xx.xx + String[] arr=String.valueOf(val).split("\\."); + int[] intArr=new int[2]; + intArr[0]=Integer.parseInt(arr[0]); + intArr[1]=Integer.parseInt(arr[1]); + return intArr; } - + public ItemStack getDustStack(){ + return this.stackMaterial.getDust(this.vAmount[0]); + } + public int getPartsPerOneHundred(){ + if (this.vAmount != null){ + if (this.vAmount[0] >= 1 && this.vAmount[0] <= 100){ + return this.vAmount[0]; + } + } + return 100; + } + public ItemStack getLeftOverStacksFromDecimalValue(){ + int temp = this.vAmount[1]; + int getCount; + if (temp >= 25 && temp <=99){ + getCount = temp/25; + return this.stackMaterial.getSmallDust(getCount); + } + else if (temp >= 11 && temp <= 24){ + getCount = temp/11; + return this.stackMaterial.getTinyDust(getCount); + } + else { + return null; + } + } + + /*public ItemStack getDustStack(){ int caseStatus = 0; int amount = 0; if (percentageToUse >= 0 && percentageToUse <= 0.99){ @@ -59,36 +102,47 @@ public class MaterialStack { default: return null; } - - } - - public int getDustCount(){ + + }*/ + + /*public int getDustCount(){ int amount = 0; - if (percentageToUse >= 0 && percentageToUse <= 0.99){ - amount = (int) (1/percentageToUse); + + //No Dust + if (percentageToUse >= 0 && percentageToUse <= 11.1111111111111111111111110){ + //amount = (int) (1/percentageToUse); + amount = 0; //Less than a tiny dust. } - else if (percentageToUse >= 1 && percentageToUse <= 9.99){ + + //Tiny Dust + else if (percentageToUse >= 11.1111111111111111111111111 && percentageToUse <= 25){ amount = (int) (percentageToUse); } + + //Small Dust else if (percentageToUse >= 10 && percentageToUse <= 99.99){ amount = (int) (percentageToUse/10); } + + //Dust else if (percentageToUse == 100){ amount = 10; } + + //Error - Nothing else { amount = 0; } return amount; - } - + }*/ + public ItemStack[] getValidItemStacks(){ return UtilsItems.validItemsForOreDict(stackMaterial.unlocalizedName); } - - - - - + + + + + } |