aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/material/MaterialStack.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core/material/MaterialStack.java')
-rw-r--r--src/Java/gtPlusPlus/core/material/MaterialStack.java123
1 files changed, 70 insertions, 53 deletions
diff --git a/src/Java/gtPlusPlus/core/material/MaterialStack.java b/src/Java/gtPlusPlus/core/material/MaterialStack.java
index f8b9b35bd8..f2f8ff4e5a 100644
--- a/src/Java/gtPlusPlus/core/material/MaterialStack.java
+++ b/src/Java/gtPlusPlus/core/material/MaterialStack.java
@@ -1,72 +1,89 @@
package gtPlusPlus.core.material;
-import gtPlusPlus.core.util.item.UtilsItems;
+import gtPlusPlus.core.util.item.ItemUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
import net.minecraft.item.ItemStack;
public class MaterialStack {
+
+ private transient final int[] vAmount;
+ private final Material stackMaterial;
+ private final double vPercentageToUse;
+
+ public MaterialStack(final Material inputs, final double partOutOf100){
+ this.stackMaterial = inputs;
+ this.vPercentageToUse = partOutOf100;
+ this.vAmount = math(partOutOf100);
+ }
+
+ @SuppressWarnings("static-method")
+ private int[] math(final double val){
+ double i;
+ //Cast to a BigDecimal to round it.
+ final BigDecimal bd = new BigDecimal(val).setScale(2, RoundingMode.HALF_EVEN);
+ i = bd.doubleValue();
+ //Split the string into xx.xx
+ final String[] arr=String.valueOf(i).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]);
+ }
- final Material materialInput;
- final double percentageToUse;
+ public ItemStack getDustStack(final int amount){
+ return this.stackMaterial.getDust(amount);
+ }
- public MaterialStack(Material inputs, double percentage){
-
- this.materialInput = inputs;
- this.percentageToUse = percentage;
-
-
+ public Material getStackMaterial(){
+ return this.stackMaterial;
}
- public ItemStack getDustStack(){
- int caseStatus = 0;
- int amount = 0;
- if (percentageToUse >= 0 && percentageToUse <= 0.99){
- caseStatus = 1;
- amount = (int) (1/percentageToUse);
- //amount = Integer.valueOf(String.valueOf(percentageToUse).charAt(2));
- }
- else if (percentageToUse >= 1 && percentageToUse <= 9.99){
- caseStatus = 2;
- amount = (int) (percentageToUse);
- //amount = Integer.valueOf(String.valueOf(percentageToUse).charAt(0));
+ public double getvPercentageToUse(){
+ return this.vPercentageToUse;
+ }
+
+ public long[] getSmallestStackSizes(){
+ return this.stackMaterial.getSmallestRatio(stackMaterial.getComposites());
+ }
+
+ public int getPartsPerOneHundred(){
+ if (this.vAmount != null){
+ if (this.vAmount[0] >= 1 && this.vAmount[0] <= 100){
+ return this.vAmount[0];
+ }
}
- else if (percentageToUse >= 10 && percentageToUse <= 99.99){
- caseStatus = 3;
- amount = (int) (percentageToUse/10);
- //amount = Integer.valueOf(String.valueOf(percentageToUse).charAt(0));
+ return 100;
+ }
+ public ItemStack getLeftOverStacksFromDecimalValue(){
+ final int temp = this.vAmount[1];
+ int getCount;
+ if (temp >= 25 && temp <=99){
+ getCount = temp/25;
+ return this.stackMaterial.getSmallDust(getCount);
}
- else if (percentageToUse == 100){
- caseStatus = 4;
- amount = 10;
+ else if (temp >= 11 && temp <= 24){
+ getCount = temp/11;
+ return this.stackMaterial.getTinyDust(getCount);
}
else {
- amount = 0;
- }
- switch (caseStatus) {
- case 1: {
- return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+materialInput.unlocalizedName, amount);
- }
- case 2: {
- return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+materialInput.unlocalizedName, amount);
- }
- case 3: {
- return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+materialInput.unlocalizedName, amount);
- }
- case 4: {
- return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+materialInput.unlocalizedName, amount);
- }
- default:
return null;
- }
-
+ }
}
-
+
public ItemStack[] getValidItemStacks(){
- return UtilsItems.validItemsForOreDict(materialInput.unlocalizedName);
+ return ItemUtils.validItemsForOreDict(stackMaterial.getUnlocalizedName());
}
-
-
-
-
-
+
+
+
+
+
}