blob: e43f80913e762427df95613319ca7fd6f8f35e84 (
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
|
package gregtech.api.objects;
import static gregtech.common.GT_UndergroundOil.DIVIDER;
import java.util.Random;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class GT_UO_Fluid {
public String Registry = "null";
public int MaxAmount = 0;
public int MinAmount = 0;
public int Chance = 0;
public int DecreasePerOperationAmount = 5;
public GT_UO_Fluid(ConfigCategory aConfigCategory) { // TODO CONFIGURE
if (aConfigCategory.containsKey("Registry")) {
aConfigCategory.get("Registry").comment = "Fluid registry name";
Registry = aConfigCategory.get("Registry").getString();
}
if (aConfigCategory.containsKey("MaxAmount")) {
aConfigCategory.get("MaxAmount").comment =
"Max amount generation (per operation, sets the VeinData) 80000 MAX";
MaxAmount = aConfigCategory.get("MaxAmount").getInt(0);
}
if (aConfigCategory.containsKey("MinAmount")) {
aConfigCategory.get("MinAmount").comment = "Min amount generation (per operation, sets the VeinData) 0 MIN";
MinAmount = aConfigCategory.get("MinAmount").getInt(0);
}
if (aConfigCategory.containsKey("Chance")) {
aConfigCategory.get("Chance").comment =
"Chance generating (weighted chance!, there will be a fluid in chunk always!)";
Chance = aConfigCategory.get("Chance").getInt(0);
}
if (aConfigCategory.containsKey("DecreasePerOperationAmount")) {
aConfigCategory.get("DecreasePerOperationAmount").comment =
"Decrease per operation (actual fluid gained works like (Litre)VeinData/5000)";
DecreasePerOperationAmount =
aConfigCategory.get("DecreasePerOperationAmount").getInt(5);
}
// GT_FML_LOGGER.info("GT UO "+aConfigCategory.getName()+" Fluid:"+Registry+" Max:"+MaxAmount+"
// Min:"+MinAmount+" Chance:"+Chance);
}
public Fluid getFluid() {
try {
return FluidRegistry.getFluid(this.Registry);
} catch (Exception e) {
return null;
}
}
public int getRandomAmount(
Random aRandom) { // generates some random ass number that correlates to extraction speeds
int smax = (int) Math.floor(Math.pow(
MaxAmount * 100.d * DIVIDER,
0.2d)); // use scaled max and min values for the randomness to make high values more rare.
double smin = Math.pow(MinAmount * 100.d * DIVIDER, 0.2d);
double samount = Math.max(smin, aRandom.nextInt(smax) + aRandom.nextDouble());
return (int) (Math.pow(samount, 5) / 100); // reverses the computation above
}
}
|