blob: 6f73b5467a00977a40ae09927084617eb40db162 (
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
|
package gregtech.api.objects.overclockdescriber;
import static gregtech.api.util.GTUtility.trans;
import javax.annotation.ParametersAreNonnullByDefault;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MethodsReturnNonnullByDefault;
import gregtech.api.util.OverclockCalculator;
import gregtech.nei.RecipeDisplayInfo;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class EUNoOverclockDescriber extends OverclockDescriber {
/**
* Amperage of the recipemap.
*/
protected final int amperage;
public EUNoOverclockDescriber(byte tier, int amperage) {
super(tier);
if (amperage < 1) {
throw new IllegalArgumentException("Amperage cannot be lower than 1");
}
this.amperage = amperage;
}
@Override
public OverclockCalculator createCalculator(OverclockCalculator template, GTRecipe recipe) {
return OverclockCalculator.ofNoOverclock(recipe);
}
@Override
public String getTierString() {
return GTUtility.getColoredTierNameFromTier(tier);
}
@Override
public final void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {
if (recipeInfo.calculator.getDuration() > 0 && recipeInfo.calculator.getConsumption() > 0) {
recipeInfo.drawText(trans("152", "Total: ") + getTotalPowerString(recipeInfo.calculator));
}
drawEnergyInfoImpl(recipeInfo);
}
/**
* Override this to draw custom info about the energy this object can handle on NEI recipe GUI, minus total
* power usage.
*/
protected void drawEnergyInfoImpl(RecipeDisplayInfo recipeInfo) {
if (recipeInfo.calculator.getConsumption() <= 0) {
return;
}
recipeInfo.drawText(trans("153", "Usage: ") + getEUtDisplay(recipeInfo.calculator));
if (shouldShowAmperage(recipeInfo.calculator)) {
recipeInfo.drawText(trans("154", "Voltage: ") + getVoltageString(recipeInfo.calculator));
recipeInfo.drawText(trans("155", "Amperage: ") + getAmperageString(recipeInfo.calculator));
}
}
protected String getTotalPowerString(OverclockCalculator calculator) {
return GTUtility.formatNumbers(calculator.getConsumption() * calculator.getDuration()) + " EU";
}
/**
* @return If amperage should be shown on NEI.
*/
protected boolean shouldShowAmperage(OverclockCalculator calculator) {
return amperage != 1;
}
/**
* @return Whole EU/t usage, without tier display.
*/
protected String getEUtWithoutTier(OverclockCalculator calculator) {
return GTUtility.formatNumbers(calculator.getConsumption()) + " EU/t";
}
/**
* @return Whole EU/t usage, with tier display.
*/
protected String getEUtWithTier(OverclockCalculator calculator) {
return getEUtWithoutTier(calculator) + GTUtility.getTierNameWithParentheses(calculator.getConsumption());
}
/**
* @return Whole EU/t usage. Also displays voltage tier if it should be shown.
*/
protected String getEUtDisplay(OverclockCalculator calculator) {
return shouldShowAmperage(calculator) ? getEUtWithoutTier(calculator) : getEUtWithTier(calculator);
}
/**
* @return EU/t usage, divided by amperage. With tier display.
*/
protected String getVoltageString(OverclockCalculator calculator) {
long voltage = computeVoltageForEURate(calculator.getConsumption());
return GTUtility.formatNumbers(voltage) + " EU/t" + GTUtility.getTierNameWithParentheses(voltage);
}
protected String getAmperageString(OverclockCalculator calculator) {
return GTUtility.formatNumbers(amperage);
}
protected long computeVoltageForEURate(long euPerTick) {
return euPerTick / amperage;
}
}
|