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
|
package GoodGenerator.Blocks.TEs;
import GoodGenerator.Items.MyMaterial;
import GoodGenerator.Loader.Loaders;
import GoodGenerator.Main.GoodGenerator;
import GoodGenerator.util.MyRecipeAdder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
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.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
import java.util.Collection;
public class MultiNqGenerator extends GT_MetaTileEntity_MultiBlockBase {
@SideOnly(Side.CLIENT)
protected String textureNames;
protected String name;
public MultiNqGenerator(String name){super(name);}
public MultiNqGenerator(int id, String name, String nameRegional){
super(id,name,nameRegional);
this.name = name;
textureNames = GoodGenerator.MOD_ID+":"+name;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public boolean checkRecipe(ItemStack aStack) {
ArrayList<FluidStack> tFluids = getStoredFluids();
Collection<GT_Recipe> tRecipes = MyRecipeAdder.instance.NqGFuels.mRecipeList;
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;
}
}
}
}
FluidStack f1=null,f2=null;
float booster = 1.0f;
int times = 1;
if(tFluids.size() > 0){
if(tFluids.contains(FluidRegistry.getFluidStack("cryotheum", 50)) && tFluids.get(tFluids.indexOf(FluidRegistry.getFluidStack("cryotheum", 50))).amount >= 50){
booster = 2.75f;
f1=FluidRegistry.getFluidStack("cryotheum", 50);
}
else if(tFluids.contains(Materials.SuperCoolant.getFluid(50L)) && tFluids.get(tFluids.indexOf(Materials.SuperCoolant.getFluid(50L))).amount >= 50){
booster = 1.5f;
f1=Materials.SuperCoolant.getFluid(50L);
}
else if(tFluids.contains(FluidRegistry.getFluidStack("ic2coolant",50)) && tFluids.get(tFluids.indexOf(FluidRegistry.getFluidStack("ic2coolant",50))).amount >= 50){
booster = 1.05f;
f1=FluidRegistry.getFluidStack("ic2coolant",50);
}
}
if(tFluids.size() > 0){
if(tFluids.contains(Materials.Naquadah.getMolten(1L)) && tFluids.get(tFluids.indexOf(Materials.Naquadah.getMolten(1L))).amount >= 1){
times = 4;
f2=Materials.Naquadah.getMolten(1L);
}
else if(tFluids.contains(Materials.Uranium235.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Uranium235.getMolten(9L))).amount >= 9){
times = 3;
f2=Materials.Uranium235.getMolten(9L);
}
else if (tFluids.contains(Materials.Caesium.getMolten(9L)) && tFluids.get(tFluids.indexOf(Materials.Caesium.getMolten(9L))).amount >= 9){
times = 2;
f2=Materials.Caesium.getMolten(9L);
}
}
if (tFluids.size()>0 && tRecipes != null){
for (GT_Recipe recipe : tRecipes){
FluidStack recipeFluid = recipe.mFluidInputs[0].copy();
FluidStack recipeFluidOut = recipe.mFluidOutputs[0].copy();
recipeFluid.amount = times;
recipeFluidOut.amount = times;
int lasting = recipe.mDuration;
int outputEU = recipe.mSpecialValue;
if (tFluids.contains(recipeFluid) && tFluids.get(tFluids.indexOf(recipeFluid)).amount >= times){
if(f1 != null)
depleteInput(f1);
if(f2 != null)
depleteInput(f2);
if (mRuntime == 0 || mRuntime%lasting == 0){
depleteInput(recipeFluid);
this.mOutputFluids = new FluidStack[]{recipeFluidOut};
}
else this.mOutputFluids = null;
if (tFluids.contains(Materials.LiquidAir.getFluid(120)) && tFluids.get(tFluids.indexOf(Materials.LiquidAir.getFluid(120))).amount >= 120){
depleteInput(Materials.LiquidAir.getFluid(120));
addEnergyOutput((long)(outputEU*times*booster));
this.mEUt = (int)(outputEU*times*booster);
}
else{
addEnergyOutput(0);
this.mEUt = 0;
}
this.mProgresstime = 1;
this.mMaxProgresstime = 1;
return true;
}
}
}
this.mEUt = 0;
return false;
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2;
int casingAmount = 0;
for (int x = -2; x <= 2; x++) {
for (int z = -2; z <= 2; z++) {
for (int y = 0; y <= 8; y++) {
if (x + xDir == 0 && y == 0 && z + zDir == 0) {
continue;
}
IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x + xDir, y, z + zDir);
Block block = aBaseMetaTileEntity.getBlockOffset(x + xDir, y, z + zDir);
if (y != 0 && y != 8 && x != -2 && x != 2 && z != -2 && z != 2) {
if (block == Blocks.air) continue;
else return false;
}
if (y != 0){
if(block == Loaders.MAR_Casing) continue;
else return false;
}
if (!addInputToMachineList(tileEntity, 44) && !addOutputToMachineList(tileEntity, 44)
&& !addMaintenanceToMachineList(tileEntity, 44)
&& !addDynamoToMachineList(tileEntity,44)) {
if (block == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12) {
casingAmount++;
} else {
return false;
}
}
}
}
}
return casingAmount >= 10 && mDynamoHatches.size() == 1 ;
}
@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 false;
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MultiNqGenerator(this.mName);
}
@Override
public String[] getDescription() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Naquadah Reactor")
.addInfo("Controller block for the Naquadah Reactor")
.addInfo("Environmental Friendly!")
.addInfo("Generate power with the High-energy molten metal.")
.addInfo("Input molten naquadria or enriched naquadah.")
.addInfo("Consume coolant 50mb/t to increase the efficiency:")
.addInfo("IC2 Coolant 105%, Super Coolant 150%, Cryotheum 275%")
.addInfo("Consume excited liquid to increase the output voltage:")
.addInfo("molten caesium | 2x output | 9mb/t ")
.addInfo("molten uranium-235 | 3x output | 9mb/t")
.addInfo("molten naquadah | 4x output | 1mb/t")
.addSeparator()
.beginStructureBlock(5, 9, 5, true)
.addController("Front bottom")
.addOtherStructurePart("Radiation Proof Machine Casing","Bottom, at least 10")
.addOtherStructurePart("Field Restricting Casing Block","The rest part of the machine")
.addEnergyHatch("Any bottom layer casing, only accept ONE!")
.addInputHatch("Any bottom layer casing")
.addOutputHatch("Any bottom layer casing")
.addMaintenanceHatch("Any bottom layer casing")
.toolTipFinisher("Good Generator");
if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
return tt.getInformation();
} else {
return tt.getStructureInformation();
}
}
@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[]{Textures.BlockIcons.CASING_BLOCKS[44],new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE)};
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[44],new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT)};
}
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[44]};
}
}
|