aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks/tileEntity/CoolantTower.java
blob: 3cee14c86f3d70139fa251b0c8402732c58cf45f (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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
package goodgenerator.blocks.tileEntity;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
import static gregtech.api.enums.Textures.BlockIcons.*;
import static gregtech.api.util.GT_StructureUtility.*;

import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IItemSource;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import goodgenerator.blocks.tileEntity.base.GT_MetaTileEntity_TooltipMultiBlockBase_EM;
import goodgenerator.util.DescTextLocalization;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_HatchElement;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

public class CoolantTower extends GT_MetaTileEntity_TooltipMultiBlockBase_EM
        implements IConstructable, ISurvivalConstructable {

    protected IStructureDefinition<CoolantTower> multiDefinition = null;
    private final int CASING_INDEX = 1542;

    public CoolantTower(int aID, String aName, String aNameRegional) {
        super(aID, aName, aNameRegional);
    }

    public CoolantTower(String name) {
        super(name);
    }

    @Override
    public IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM() {
        if (multiDefinition == null) {
            multiDefinition = StructureDefinition.<CoolantTower>builder()
                    .addShape(mName, transpose(new String[][] {
                        {
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "  B     B  ",
                            "  B     B  ",
                            "  B     B  ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   BBBBB   ",
                            "  BB   BB  ",
                            "  BB   BB  ",
                            "  BB   BB  ",
                            "   BBBBB   ",
                            "    BBB    ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "   B   B   ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "   B   B   ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "   B   B   ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   BBBBB   ",
                            "  BB   BB  ",
                            "  BB   BB  ",
                            "  BB   BB  ",
                            "   BBBBB   ",
                            "    BBB    ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "  B     B  ",
                            "  B     B  ",
                            "  B     B  ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "  B     B  ",
                            "  B     B  ",
                            "  B     B  ",
                            "   B   B   ",
                            "    BBB    ",
                            "           ",
                            "           "
                        },
                        {
                            "           ",
                            "    BBB    ",
                            "   BBBBB   ",
                            "  BB   BB  ",
                            " BB     BB ",
                            " BB     BB ",
                            " BB     BB ",
                            "  BB   BB  ",
                            "   BBBBB   ",
                            "    BBB    ",
                            "           "
                        },
                        {
                            "           ",
                            "    BBB    ",
                            "   B   B   ",
                            "  B     B  ",
                            " B       B ",
                            " B       B ",
                            " B       B ",
                            "  B     B  ",
                            "   B   B   ",
                            "    BBB    ",
                            "           "
                        },
                        {
                            "           ",
                            "   BBBBB   ",
                            "  BB   BB  ",
                            " BB     BB ",
                            " B       B ",
                            " B       B ",
                            " B       B ",
                            " BB     BB ",
                            "  BB   BB  ",
                            "   BBBBB   ",
                            "           "
                        },
                        {
                            "   HH~HH   ",
                            "  HBBBBBH  ",
                            " HB     BH ",
                            "HB       BH",
                            "HB       BH",
                            "HB       BH",
                            "HB       BH",
                            "HB       BH",
                            " HB     BH ",
                            "  HBBBBBH  ",
                            "   HHHHH   "
                        },
                        {
                            "   CCCCC   ",
                            "  C     C  ",
                            " C       C ",
                            "C         C",
                            "C         C",
                            "C         C",
                            "C         C",
                            "C         C",
                            " C       C ",
                            "  C     C  ",
                            "   CCCCC   "
                        },
                    }))
                    .addElement('B', ofBlockAnyMeta(GregTech_API.sBlockConcretes, 8))
                    .addElement('C', ofFrame(Materials.TungstenCarbide))
                    .addElement(
                            'H',
                            ofChain(buildHatchAdder(CoolantTower.class)
                                    .atLeast(GT_HatchElement.InputHatch, GT_HatchElement.OutputHatch)
                                    .casingIndex(CASING_INDEX)
                                    .dot(1)
                                    .buildAndChain(ofBlockAnyMeta(GregTech_API.sBlockConcretes, 8))))
                    .build();
        }
        return multiDefinition;
    }

    public final boolean addIOFluidToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        } else {
            IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
            if (aMetaTileEntity == null) {
                return false;
            } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
                ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
                return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
            } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
                ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
                return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity);
            } else {
                return false;
            }
        }
    }

    @Override
    public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
        mWrench = true;
        mScrewdriver = true;
        mSoftHammer = true;
        mHardHammer = true;
        mSolderingTool = true;
        mCrowbar = true;
        return structureCheck_EM(mName, 5, 11, 0);
    }

    @Override
    protected GT_Multiblock_Tooltip_Builder createTooltip() {
        final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
        tt.addMachineType("Coolant Tower")
                .addInfo("Controller block for the Coolant Tower.")
                .addInfo("Turn Steam back to Distilled Water.")
                .addInfo(BLUE_PRINT_INFO)
                .addSeparator()
                .addController("Mid of the second layer.")
                .addInputHatch("Input Hatch", 1)
                .addOutputHatch("Output Hatch", 1)
                .toolTipFinisher("Good Generator");
        return tt;
    }

    @Override
    public void construct(ItemStack stackSize, boolean hintsOnly) {
        structureBuild_EM(mName, 5, 11, 0, stackSize, hintsOnly);
    }

    @Override
    public String[] getStructureDescription(ItemStack stackSize) {
        return DescTextLocalization.addText("CoolantTower.hint", 3);
    }

    @Override
    public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
        return new CoolantTower(mName);
    }

    @Override
    public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
        super.onPostTick(aBaseMetaTileEntity, aTick);
        if (aTick % 72000 == 0) {
            mWrench = true;
            mScrewdriver = true;
            mSoftHammer = true;
            mHardHammer = true;
            mSolderingTool = true;
            mCrowbar = true;
        }
    }

    @Override
    public int getMaxEfficiency(ItemStack aStack) {
        return 10000;
    }

    @Override
    public boolean onRunningTick(ItemStack aStack) {
        return true;
    }

    @Override
    public boolean checkRecipe_EM(ItemStack aStack) {
        this.mMaxProgresstime = 100;
        int steam = 0;
        for (FluidStack steams : getStoredFluids()) {
            if (GT_Utility.areFluidsEqual(steams, GT_ModHandler.getSteam(1))) {
                steam += steams.amount;
            }
        }
        steam = steam / 160 * 160;
        depleteInput(GT_ModHandler.getSteam(steam));
        addOutput(GT_ModHandler.getDistilledWater(steam / 160));
        return true;
    }

    @Override
    public ITexture[] getTexture(
            IGregTechTileEntity aBaseMetaTileEntity,
            byte aSide,
            byte aFacing,
            byte aColorIndex,
            boolean aActive,
            boolean aRedstone) {
        if (aSide == aFacing) {
            if (aActive)
                return new ITexture[] {
                    casingTexturePages[12][6],
                    TextureFactory.builder()
                            .addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE)
                            .extFacing()
                            .build(),
                    TextureFactory.builder()
                            .addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW)
                            .extFacing()
                            .glow()
                            .build()
                };
            return new ITexture[] {
                casingTexturePages[12][6],
                TextureFactory.builder()
                        .addIcon(OVERLAY_FRONT_HEAT_EXCHANGER)
                        .extFacing()
                        .build(),
                TextureFactory.builder()
                        .addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_GLOW)
                        .extFacing()
                        .glow()
                        .build()
            };
        }
        return new ITexture[] {casingTexturePages[12][6]};
    }

    @Override
    public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) {
        if (mMachine) return -1;
        return survivialBuildPiece(mName, stackSize, 5, 11, 0, elementBudget, source, actor, false, true);
    }
}