blob: 8d9de3faf4abd270b436d1a5056599851fdf89a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
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 Material stackMaterial;
final double percentageToUse;
public MaterialStack(Material inputs, double partOutOf100){
this.stackMaterial = inputs;
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){
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));
}
else if (percentageToUse >= 10 && percentageToUse <= 99.99){
caseStatus = 3;
amount = (int) (percentageToUse/10);
//amount = Integer.valueOf(String.valueOf(percentageToUse).charAt(0));
}
else if (percentageToUse == 100){
caseStatus = 4;
amount = 10;
}
else {
amount = 0;
}
switch (caseStatus) {
case 1: {
return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+stackMaterial.unlocalizedName, amount);
}
case 2: {
return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+stackMaterial.unlocalizedName, amount);
}
case 3: {
return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+stackMaterial.unlocalizedName, amount);
}
case 4: {
return UtilsItems.getItemStackOfAmountFromOreDictNoBroken("dust"+stackMaterial.unlocalizedName, amount);
}
default:
return null;
}
}*/
/*public int getDustCount(){
int amount = 0;
//No Dust
if (percentageToUse >= 0 && percentageToUse <= 11.1111111111111111111111110){
//amount = (int) (1/percentageToUse);
amount = 0; //Less than a tiny dust.
}
//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);
}
}
|