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
|
package miscutil.gregtech.api.metatileentity.implementations;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import miscutil.core.block.ModBlocks;
import miscutil.gregtech.api.gui.CONTAINER_IronBlastFurnace;
import miscutil.gregtech.api.gui.GUI_IronBlastFurnace;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class GregtechMetaTileEntityIronBlastFurnace
extends MetaTileEntity {
private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL)};
private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT)};
private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE)};
public int mMaxProgresstime = 0;
public int mUpdate = 30;
public int mProgresstime = 0;
public boolean mMachine = false;
public ItemStack mOutputItem1;
public ItemStack mOutputItem2;
public GregtechMetaTileEntityIronBlastFurnace(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 4);
}
public GregtechMetaTileEntityIronBlastFurnace(String aName) {
super(aName, 4);
}
@Override
public String[] getDescription() {
return new String[]{"Slowly, Skip the Bronze age, Get some Steel!", "Multiblock: 3x3x5 hollow with opening on top", "40 Iron Plated Bricks required"};
}
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
return aActive ? FACING_ACTIVE : FACING_FRONT;
}
return FACING_SIDE;
}
@Override
public boolean isSteampowered() {
return false;
}
@Override
public boolean isElectric() {
return false;
}
@Override
public boolean isPneumatic() {
return false;
}
@Override
public boolean isEnetInput() {
return false;
}
@Override
public boolean isEnetOutput() {
return false;
}
@Override
public boolean isInputFacing(byte aSide) {
return false;
}
@Override
public boolean isOutputFacing(byte aSide) {
return false;
}
@Override
public boolean isTeleporterCompatible() {
return false;
}
@Override
public boolean isFacingValid(byte aFacing) {
return aFacing > 1;
}
@Override
public boolean isAccessAllowed(EntityPlayer aPlayer) {
return true;
}
@Override
public int getProgresstime() {
return this.mProgresstime;
}
@Override
public int maxProgresstime() {
return this.mMaxProgresstime;
}
@Override
public int increaseProgress(int aProgress) {
this.mProgresstime += aProgress;
return this.mMaxProgresstime - this.mProgresstime;
}
@Override
public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {
return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID));
}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GregtechMetaTileEntityIronBlastFurnace(this.mName);
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setInteger("mProgresstime", this.mProgresstime);
aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime);
if (this.mOutputItem1 != null) {
NBTTagCompound tNBT = new NBTTagCompound();
this.mOutputItem1.writeToNBT(tNBT);
aNBT.setTag("mOutputItem1", tNBT);
}
if (this.mOutputItem2 != null) {
NBTTagCompound tNBT = new NBTTagCompound();
this.mOutputItem2.writeToNBT(tNBT);
aNBT.setTag("mOutputItem2", tNBT);
}
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
this.mUpdate = 30;
this.mProgresstime = aNBT.getInteger("mProgresstime");
this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1");
this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2");
}
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
if (aBaseMetaTileEntity.isClientSide()) {
return true;
}
aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
@Override
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity);
}
private boolean checkMachine() {
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 4; j++) { //This is height
for (int k = -1; k < 2; k++) {
if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) {
if ((i != 0) || (j == -1) || (k != 0)) {
if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) {
return false;
}
} else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) {
return false;
}
}
}
}
}
return true;
}
@Override
public void onMachineBlockUpdate() {
this.mUpdate = 30;
}
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if ((aBaseMetaTileEntity.isClientSide()) &&
(aBaseMetaTileEntity.isActive())) {
aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D);
}
if (aBaseMetaTileEntity.isServerSide()) {
if (this.mUpdate-- == 0) {
this.mMachine = checkMachine();
}
if (this.mMachine) {
if (this.mMaxProgresstime > 0) {
if (++this.mProgresstime >= this.mMaxProgresstime) {
addOutputProducts();
this.mOutputItem1 = null;
this.mOutputItem2 = null;
this.mProgresstime = 0;
this.mMaxProgresstime = 0;
try {
// GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel");
} catch (Exception e) {
}
}
} else if (aBaseMetaTileEntity.isAllowedToWork()) {
checkRecipe();
}
}
aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine));
if (aBaseMetaTileEntity.isActive()) {
if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) {
aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2);
this.mUpdate = 1;
}
if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) {
aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2);
this.mUpdate = 1;
}
} else {
if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) {
aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2);
this.mUpdate = 1;
}
if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) {
aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2);
this.mUpdate = 1;
}
}
}
}
private void addOutputProducts() {
if (this.mOutputItem1 != null) {
if (this.mInventory[2] == null) {
this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1});
} else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) {
this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize);
}
}
if (this.mOutputItem2 != null) {
if (this.mInventory[3] == null) {
this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2});
} else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) {
this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize);
}
}
}
private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) {
if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && (
(this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) {
return true;
}
return false;
}
private boolean checkRecipe() {
if (!this.mMachine) {
return false;
}
if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) {
if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) {
if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 4*3);
this.mMaxProgresstime = 36000;
return true;
}
if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 2*3);
this.mMaxProgresstime = 4800*5;
return true;
}
if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 9);
getBaseMetaTileEntity().decrStackSize(1, 4*3);
this.mMaxProgresstime = 64800*5;
return true;
}
} else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) {
if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 2*3);
this.mMaxProgresstime = 3600*5;
return true;
}
if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 1*3);
this.mMaxProgresstime = 2400*5;
return true;
}
if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) {
getBaseMetaTileEntity().decrStackSize(0, 9);
getBaseMetaTileEntity().decrStackSize(1, 2*3);
this.mMaxProgresstime = 32400*5;
return true;
}
} else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) {
if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 64);
this.mMaxProgresstime = 64800*9;
return true;
}
if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 18*3);
this.mMaxProgresstime = 43200*5;
return true;
}
if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) {
getBaseMetaTileEntity().decrStackSize(0, 1);
getBaseMetaTileEntity().decrStackSize(1, 4*3);
this.mMaxProgresstime = 64800*5;
return true;
}
}
}
this.mOutputItem1 = null;
this.mOutputItem2 = null;
return false;
}
@Override
public boolean isGivingInformation() {
return false;
}
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return aIndex > 1;
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
if (aIndex < 2) {
}
return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]);
}
@Override
public byte getTileEntityBaseType() {
return 0;
}
}
|