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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW5;
import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW_ACTIVE5;
import static gregtech.api.enums.Textures.BlockIcons.LARGETURBINE_NEW_EMPTY5;
import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS;
import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages;
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import gregtech.GTMod;
import gregtech.api.GregTechAPI;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.TurbineStatCalculator;
public class MTELargeTurbineHPSteam extends MTELargeTurbine {
public boolean achievement = false;
private boolean looseFit = false;
public MTELargeTurbineHPSteam(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public MTELargeTurbineHPSteam(String aName) {
super(aName);
}
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing,
int colorIndex, boolean aActive, boolean redstoneLevel) {
return new ITexture[] { MACHINE_CASINGS[1][colorIndex + 1],
aFacing == side ? (aActive ? TextureFactory.builder()
.addIcon(LARGETURBINE_NEW_ACTIVE5)
.build()
: hasTurbine() ? TextureFactory.builder()
.addIcon(LARGETURBINE_NEW5)
.build()
: TextureFactory.builder()
.addIcon(LARGETURBINE_NEW_EMPTY5)
.build())
: casingTexturePages[0][59] };
}
@Override
protected MultiblockTooltipBuilder createTooltip() {
final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Steam Turbine")
.addInfo("Controller block for the Large High Pressure Steam Turbine")
.addInfo("Needs a Turbine, place inside controller")
.addInfo("Outputs Steam as well as producing power")
.addInfo("Power output depends on turbine and fitting")
.addInfo("Use screwdriver to adjust fitting of turbine")
.addSeparator()
.beginStructureBlock(3, 3, 4, true)
.addController("Front center")
.addCasingInfoRange("Titanium Turbine Casing", 8, 31, false)
.addDynamoHatch("Back center", 1)
.addMaintenanceHatch("Side centered", 2)
.addInputHatch("Superheated Steam, Side centered", 2)
.addOutputHatch("Steam, Side centered", 2)
.toolTipFinisher("Gregtech");
return tt;
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTELargeTurbineHPSteam(mName);
}
@Override
public Block getCasingBlock() {
return GregTechAPI.sBlockCasings4;
}
@Override
public byte getCasingMeta() {
return 11;
}
@Override
public int getCasingTextureIndex() {
return 59;
}
@Override
public boolean isNewStyleRendering() {
return true;
}
@Override
int fluidIntoPower(ArrayList<FluidStack> aFluids, TurbineStatCalculator turbine) {
int tEU = 0;
int totalFlow = 0; // Byproducts are based on actual flow
int flow = 0;
// Allowed to use up to 300% optimal flow rate, depending on the value of overflowMultiplier.
// This value is chosen because the highest EU/t possible depends on the overflowMultiplier, and the formula
// used
// makes it so the flow rate for that max, per value of overflowMultiplier, is (percentage of optimal flow
// rate):
// - 200% if it is 1
// - 250% if it is 2
// - 300% if it is 3
// Variable required outside of loop for multi-hatch scenarios.
this.realOptFlow = looseFit ? turbine.getOptimalLooseSteamFlow() : turbine.getOptimalSteamFlow();
int remainingFlow = GTUtility.safeInt((long) (realOptFlow * (0.5f * turbine.getOverflowEfficiency() + 1.5)));
storedFluid = 0;
for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) {
final FluidStack aFluidStack = aFluids.get(i);
if (GTModHandler.isSuperHeatedSteam(aFluidStack)) {
flow = Math.min(aFluidStack.amount, remainingFlow); // try to use up to the max flow defined just above
depleteInput(new FluidStack(aFluidStack, flow)); // deplete that amount
this.storedFluid += aFluidStack.amount;
remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches
totalFlow += flow; // track total input used
if (!achievement) {
try {
GTMod.achievements.issueAchievement(
this.getBaseMetaTileEntity()
.getWorld()
.getPlayerEntityByName(
this.getBaseMetaTileEntity()
.getOwnerName()),
"efficientsteam");
} catch (Exception ignored) {}
achievement = true;
}
} else if (GTModHandler.isAnySteam(aFluidStack)) {
depleteInput(new FluidStack(aFluidStack, aFluidStack.amount));
}
}
if (totalFlow <= 0) return 0;
tEU = totalFlow;
addOutput(GTModHandler.getSteam(totalFlow));
if (totalFlow == (GTUtility.safeInt((long) realOptFlow))) {
tEU = GTUtility
.safeInt((long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency())));
} else {
float efficiency = getOverflowEfficiency(
totalFlow,
(GTUtility.safeInt((long) realOptFlow)),
overflowMultiplier);
tEU *= efficiency;
tEU = Math.max(
1,
GTUtility.safeInt(
(long) (tEU * (looseFit ? turbine.getLooseSteamEfficiency() : turbine.getSteamEfficiency()))));
}
// If next output is above the maximum the dynamo can handle, set it to the maximum instead of exploding the
// turbine
// Raising the maximum allowed flow rate to account for the efficiency changes beyond the optimal flow rate can
// explode turbines on world load
if (tEU > getMaximumOutput()) {
tEU = GTUtility.safeInt(getMaximumOutput());
}
return tEU;
}
@Override
float getOverflowEfficiency(int totalFlow, int actualOptimalFlow, int overflowMultiplier) {
// overflowMultiplier changes how quickly the turbine loses efficiency after flow goes beyond the optimal value
// At the default value of 1, any flow will generate less EU/t than optimal flow, regardless of the amount of
// fuel used
// The bigger this number is, the slower efficiency loss happens as flow moves beyond the optimal value
// Superheated steam is the second least efficient out of all turbine fuels in this regard, with steam being the
// least efficient
float efficiency = 0;
if (totalFlow > actualOptimalFlow) {
efficiency = 1.0f
- Math.abs((totalFlow - actualOptimalFlow)) / ((float) actualOptimalFlow * (overflowMultiplier + 2));
} else {
efficiency = 1.0f - Math.abs((totalFlow - actualOptimalFlow) / (float) actualOptimalFlow);
}
return efficiency;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return (looseFit && XSTR_INSTANCE.nextInt(4) == 0) ? 0 : 1;
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("turbineFitting", looseFit);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
looseFit = aNBT.getBoolean("turbineFitting");
}
}
|