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
|
package GoodGenerator.Blocks.TEs;
import GoodGenerator.Loader.Loaders;
import GoodGenerator.util.MyRecipeAdder;
import com.github.bartimaeusnek.bartworks.util.Coords;
import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
import com.github.technus.tectech.mechanics.constructable.IConstructable;
import com.github.technus.tectech.mechanics.structure.IStructureDefinition;
import com.github.technus.tectech.mechanics.structure.StructureDefinition;
import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti;
import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel;
import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.*;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import static com.github.technus.tectech.mechanics.structure.StructureUtility.*;
public class FuelRefineFactory extends GT_MetaTileEntity_MultiblockBase_EM implements TecTechEnabledMulti, IConstructable {
@SideOnly(Side.CLIENT)
protected String name;
private IStructureDefinition<FuelRefineFactory> multiDefinition = null;
private int Tier = -1;
private final HashSet<Coords> vis = new HashSet<>(64);
public FuelRefineFactory(String name){super(name);}
public FuelRefineFactory(int id, String name, String nameRegional){
super(id,name,nameRegional);
this.name = name;
}
@Override
public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
return this.mEnergyHatches;
}
@Override
public List<GT_MetaTileEntity_Hatch_EnergyTunnel> getTecTechEnergyTunnels() {
return new ArrayList<>();
}
@Override
public List<GT_MetaTileEntity_Hatch_EnergyMulti> getTecTechEnergyMultis() {
return new ArrayList<>();
}
@Override
public void construct(ItemStack itemStack, boolean hintsOnly) {
structureBuild_EM(name, 7,12,1, hintsOnly, itemStack);
}
@Override
public IStructureDefinition<FuelRefineFactory> getStructure_EM() {
if(multiDefinition == null) {
multiDefinition = StructureDefinition
.<FuelRefineFactory>builder()
.addShape(name,
transpose(new String[][]{
{" "," CCC "," "},
{" XGX "," CCFFFCC "," XGX "},
{" CC CC "," CFFCCCFFC "," CC CC "},
{" C C "," CFCC CCFC "," C C "},
{" C C "," CFC CFC "," C C "},
{" C C "," CFC CFC "," C C "},
{" X X ","CFC CFC"," X X "},
{" G G ","CFC CFC"," G G "},
{" X X ","CFC CFC"," X X "},
{" C C "," CFC CFC "," C C "},
{" C C "," CFC CFC "," C C "},
{" C C "," CFCC CCFC "," C C "},
{" CC CC "," CFFC~CFFC "," CC CC "},
{" XGX "," CCFFFCC "," XGX "},
{" "," CCC "," "}
})
).addElement(
'X',
ofChain(
ofHatchAdder(
FuelRefineFactory::addToFRFList,60,
Loaders.FRF_Casings,0
),
ofBlock(
Loaders.FRF_Casings,0
)
)
).addElement(
'C',
ofBlockAnyMeta(
Loaders.FRF_Casings
)
).addElement(
'G',
ofBlockAnyMeta(
Loaders.fieldRestrictingGlass
)
).addElement(
'F',
ofChain(
ofBlock(
Loaders.FRF_Coil_1,0
),
ofBlock(
Loaders.FRF_Coil_2,0
),
ofBlock(
Loaders.FRF_Coil_2,0
),
ofBlockHint(
Loaders.FRF_Coil_1,0
)
)
)
.build();
}
return multiDefinition;
}
//In fact, this check method can't check structure correctly...
public boolean checkCoil(){
IGregTechTileEntity aTile = this.getBaseMetaTileEntity();
Block[] block = {Loaders.FRF_Coil_1,Loaders.FRF_Coil_2,Loaders.FRF_Coil_3};
int[] dx = {1,-1,0,0,0,0};
int[] dy = {0,0,1,-1,0,0};
int[] dz = {0,0,0,0,1,-1};
for (int i = 0; i < 6; i ++)
for (int j = 0; j < 3; j ++){
vis.clear();
if (aTile.getBlockOffset(dx[i],dy[i],dz[i]) == block[j])
if (dfs(block[j], aTile.getWorld(),aTile.getXCoord() + dx[i],aTile.getYCoord() + dy[i],aTile.getZCoord() + dz[i],32)){
Tier = j;
return true;
}
}
return false;
}
public boolean dfs(Block e, World w,int x,int y,int z, int cnt){
if (cnt == 0) return true;
if (w.getBlock(x,y,z) != e) return false;
int[] dx = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int[] dy = { 1, 1, 1,-1,-1,-1, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0};
int[] dz = { 1, 0,-1, 1, 0,-1, 1,-1, 1, 0,-1, 1, 0,-1, 1, 0,-1, 1, 0,-1, 1, 0,-1, 1, 0,-1};
vis.add(new Coords(x,y,z,w.provider.dimensionId));
for (int i = 0; i < 26; i ++){
if (vis.contains(new Coords(x + dx[i],y + dy[i], z + dz[i],w.provider.dimensionId))) continue;
if (dfs(e,w,x + dx[i],y + dy[i], z + dz[i], cnt - 1)) return true;
}
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(name, 7,12,1) && checkCoil();
}
@Override
public boolean checkRecipe_EM(ItemStack aStack){
ArrayList<FluidStack> tFluids = getStoredFluids();
ArrayList<ItemStack> tItems = getStoredInputs();
Collection<GT_Recipe> tRecipes = MyRecipeAdder.instance.FRF.mRecipeList;
long maxVoltage = getMaxInputVoltage();
for (int i = 0; i < tFluids.size() - 1; i++) {
for (int j = i + 1; j < tFluids.size(); j++) {
if (GT_Utility.areFluidsEqual(tFluids.get(i), tFluids.get(j))) {
if ((tFluids.get(i)).amount >= (tFluids.get(j)).amount) {
tFluids.remove(j--);
} else {
tFluids.remove(i--);
break;
}
}
}
}
for (int i = 0; i < tItems.size() - 1; i++) {
for (int j = i + 1; j < tItems.size(); j++) {
if (GT_Utility.areStacksEqual(tItems.get(i), tItems.get(j))) {
if ((tItems.get(i)).stackSize >= (tItems.get(j)).stackSize) {
tItems.remove(j--);
} else {
tItems.remove(i--);
break;
}
}
}
}
for (GT_Recipe recipe : tRecipes){
checkCoil();
if (recipe.mSpecialValue > Tier) continue;
if (recipe.isRecipeInputEqual(true, tFluids.toArray(new FluidStack[tFluids.size()]), tItems.toArray(new ItemStack[tItems.size()]))){
calculatePerfectOverclockedNessMulti(recipe.mEUt, recipe.mDuration / (Tier - recipe.mSpecialValue + 1), 1, maxVoltage);
this.mOutputFluids = recipe.mFluidOutputs;
this.updateSlots();
return true;
}
}
return false;
}
public final boolean addToFRFList(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) {
((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
}
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity);
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity);
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity);
} else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) {
return this.eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti)aMetaTileEntity);
} else {
return false;
}
}
}
}
@Override
public boolean onRunningTick(ItemStack stack) {
return true;
}
@Override
public String[] getStructureDescription(ItemStack itemStack) {
return new String[0];
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new FuelRefineFactory(this.mName);
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 0;
}
@Override
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return true;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
@SuppressWarnings("ALL")
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if(aSide == aFacing){
if(aActive) return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE)};
return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)};
}
return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL)};
}
}
|