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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
package gregtech.common.tileentities.boilers;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_CoverBehavior;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
public abstract class GT_MetaTileEntity_Boiler
extends GT_MetaTileEntity_BasicTank
{
public int mTemperature = 20;
public int mProcessingEnergy = 0;
public int mLossTimer = 0;
public FluidStack mSteam = null;
public boolean mHadNoWater = false;
public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures)
{
super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures);
}
public GT_MetaTileEntity_Boiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures)
{
super(aName, aTier, 4, aDescription, aTextures);
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone)
{
ITexture[] tmp = mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte)(aActive ? 4 : 3)) : aSide][aColorIndex + 1];
//mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1];
if(aSide!=aFacing&&tmp.length==2){
tmp = new ITexture[]{tmp[0]};
}
return tmp;
}
public boolean isElectric()
{
return false;
}
public boolean isPneumatic()
{
return false;
}
public boolean isSteampowered()
{
return false;
}
public boolean isSimpleMachine()
{
return false;
}
public boolean isFacingValid(byte aFacing)
{
return aFacing > 1;
}
public boolean isAccessAllowed(EntityPlayer aPlayer)
{
return true;
}
public boolean isValidSlot(int aIndex)
{
return true;
}
public int getProgresstime()
{
return this.mTemperature;
}
public int maxProgresstime()
{
return 500;
}
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer)
{
if (aBaseMetaTileEntity.isClientSide()) {
return true;
}
if (aPlayer != null) {
if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1)))
{
fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true);
aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket);
}
else
{
aBaseMetaTileEntity.openGUI(aPlayer);
}
}
return true;
}
public boolean doesFillContainers()
{
return true;
}
public boolean doesEmptyContainers()
{
return true;
}
public boolean canTankBeFilled()
{
return true;
}
public boolean canTankBeEmptied()
{
return true;
}
public boolean displaysItemStack()
{
return false;
}
public boolean displaysStackSize()
{
return false;
}
public boolean isFluidInputAllowed(FluidStack aFluid)
{
return GT_ModHandler.isWater(aFluid);
}
public FluidStack getDrainableStack()
{
return this.mSteam;
}
public FluidStack setDrainableStack(FluidStack aFluid)
{
this.mSteam = aFluid;return this.mSteam;
}
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover)
{
return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover();
}
public void saveNBTData(NBTTagCompound aNBT)
{
super.saveNBTData(aNBT);
aNBT.setInteger("mLossTimer", this.mLossTimer);
aNBT.setInteger("mTemperature", this.mTemperature);
aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy);
if (this.mSteam != null) {
try
{
aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound()));
}
catch (Throwable e) {}
}
}
public void loadNBTData(NBTTagCompound aNBT)
{
super.loadNBTData(aNBT);
this.mLossTimer = aNBT.getInteger("mLossTimer");
this.mTemperature = aNBT.getInteger("mTemperature");
this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy");
this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam"));
}
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick)
{
if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L))
{
if (this.mTemperature <= 20)
{
this.mTemperature = 20;
this.mLossTimer = 0;
}
if (++this.mLossTimer > 40)
{
this.mTemperature -= 1;
this.mLossTimer = 0;
}
for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) {
if (i != aBaseMetaTileEntity.getFrontFacing())
{
IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i);
if (tTileEntity != null)
{
FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false);
if (tDrained != null)
{
int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false);
if (tFilledAmount > 0) {
tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true);
}
}
}
}
}
if (aTick % 10L == 0L) {
if (this.mTemperature > 100)
{
if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0))
{
this.mHadNoWater = true;
}
else
{
if (this.mHadNoWater)
{
aBaseMetaTileEntity.doExplosion(2048L);
return;
}
this.mFluid.amount -= 1;
if (this.mSteam == null) {
this.mSteam = GT_ModHandler.getSteam(150L);
} else if (GT_ModHandler.isSteam(this.mSteam)) {
this.mSteam.amount += 150;
} else {
this.mSteam = GT_ModHandler.getSteam(150L);
}
}
}
else {
this.mHadNoWater = false;
}
}
if ((this.mSteam != null) &&
(this.mSteam.amount > 32000))
{
sendSound((byte)1);
this.mSteam.amount = 24000;
}
if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) &&
(this.mInventory[2] != null)) {
if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal))))
{
this.mProcessingEnergy += 160;
aBaseMetaTileEntity.decrStackSize(2, 1);
if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
}
}
else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal)))
{
this.mProcessingEnergy += 160;
aBaseMetaTileEntity.decrStackSize(2, 1);
if (aBaseMetaTileEntity.getRandomNumber(3) == 0) {
aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
}
}
else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke"))
{
this.mProcessingEnergy += 640;
aBaseMetaTileEntity.decrStackSize(2, 1);
if (aBaseMetaTileEntity.getRandomNumber(2) == 0) {
aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L));
}
}
else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite))))
{
this.mProcessingEnergy += 40;
aBaseMetaTileEntity.decrStackSize(2, 1);
if (aBaseMetaTileEntity.getRandomNumber(8) == 0) {
aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L));
}
}
}
if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L))
{
this.mProcessingEnergy -= 2;
this.mTemperature += 1;
}
aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
}
}
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
{
return (aIndex == 1) || (aIndex == 3);
}
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
{
return aIndex == 2;
}
public void doSound(byte aIndex, double aX, double aY, double aZ)
{
if (aIndex == 1)
{
GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ);
for (int l = 0; l < 8; l++) {
getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5D + Math.random(), aY, aZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
}
}
}
public int getCapacity()
{
return 16000;
}
public int getTankPressure()
{
return 100;
}
}
|