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
|
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
import net.minecraft.entity.player.EntityPlayer;
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.Fluid;
import net.minecraftforge.fluids.FluidStack;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.MTEHatchInput;
import gregtech.api.objects.GTRenderedTexture;
import gregtech.api.objects.XSTR;
import gregtech.api.util.GTUtility;
import gtPlusPlus.core.lib.GTPPCore;
import gtPlusPlus.core.util.minecraft.FluidUtils;
public abstract class MTEHatchFluidGenerator extends MTEHatchInput {
protected static XSTR floatGen = new XSTR();
public int mProgresstime = 0, mMaxProgresstime = 0;
public MTEHatchFluidGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) {
super(aID, aName, aNameRegional, aTier);
}
public MTEHatchFluidGenerator(final String aName, final int aTier, final String[] aDescription,
final ITexture[][][] aTextures) {
super(aName, aTier, aDescription, aTextures);
}
public abstract String[] getCustomTooltip();
public abstract Fluid getFluidToGenerate();
public abstract int getAmountOfFluidToGenerate();
public abstract int getMaxTickTime();
@Override
public synchronized String[] getDescription() {
mDescriptionArray[1] = "Capacity: " + GTUtility.formatNumbers(getCapacity()) + "L";
final String[] hatchTierString = new String[] { "Hatch Tier: " + GTUtility.getColoredTierNameFromTier(mTier) };
String[] aCustomTips = getCustomTooltip();
final String[] desc = new String[mDescriptionArray.length + aCustomTips.length + 2];
System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length);
System.arraycopy(hatchTierString, 0, desc, mDescriptionArray.length, 1);
System.arraycopy(aCustomTips, 0, desc, mDescriptionArray.length + 1, aCustomTips.length);
desc[mDescriptionArray.length + aCustomTips.length + 1] = GTPPCore.GT_Tooltip.get();
return desc;
}
@Override
public ITexture[] getTexturesActive(final ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture, new GTRenderedTexture(Textures.BlockIcons.OVERLAY_MUFFLER) };
}
@Override
public ITexture[] getTexturesInactive(final ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture, new GTRenderedTexture(Textures.BlockIcons.OVERLAY_MUFFLER) };
}
@Override
public boolean isSimpleMachine() {
return true;
}
@Override
public boolean isFacingValid(final ForgeDirection facing) {
return true;
}
@Override
public boolean isAccessAllowed(final EntityPlayer aPlayer) {
return true;
}
@Override
public boolean isValidSlot(final int aIndex) {
return false;
}
@Override
public abstract MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity);
public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex,
final ForgeDirection side, final ItemStack aStack) {
return false;
}
public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex,
final ForgeDirection side, final ItemStack aStack) {
return false;
}
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
if (!aBaseMetaTileEntity.isAllowedToWork()) {
aBaseMetaTileEntity.setActive(false);
mProgresstime = 0;
mMaxProgresstime = 0;
} else {
aBaseMetaTileEntity.setActive(true);
mMaxProgresstime = getMaxTickTime();
if (++mProgresstime >= mMaxProgresstime) {
if (this.canTankBeFilled()) {
addFluidToHatch(aTick);
}
mProgresstime = 0;
}
}
}
@Override
public int getProgresstime() {
return mProgresstime;
}
@Override
public int maxProgresstime() {
return mMaxProgresstime;
}
@Override
public int increaseProgress(int aProgress) {
mProgresstime += aProgress;
return mMaxProgresstime - mProgresstime;
}
public abstract void generateParticles(final World aWorld, final String name);
@Override
public int getTankPressure() {
return 100;
}
@Override
public abstract int getCapacity();
@Override
public boolean canTankBeEmptied() {
return true;
}
public abstract boolean doesHatchMeetConditionsToGenerate();
public boolean addFluidToHatch(long aTick) {
if (!doesHatchMeetConditionsToGenerate()) {
return false;
}
int aFillAmount = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true);
if (aFillAmount > 0) {
if (this.getBaseMetaTileEntity()
.isClientSide()) {
generateParticles(
this.getBaseMetaTileEntity()
.getWorld(),
"cloud");
}
}
return aFillAmount > 0;
}
@Override
public boolean canTankBeFilled() {
return true;
}
@Override
public boolean doesEmptyContainers() {
return false;
}
@Override
public boolean doesFillContainers() {
return true;
}
@Override
public int fill(FluidStack aFluid, boolean doFill) {
if (aFluid == null || aFluid.getFluid()
.getID() <= 0 || aFluid.amount <= 0 || aFluid.getFluid() != getFluidToGenerate() || !canTankBeFilled()) {
return 0;
}
if (getFillableStack() == null || getFillableStack().getFluid()
.getID() <= 0) {
if (aFluid.amount <= getCapacity()) {
if (doFill) {
setFillableStack(aFluid.copy());
getBaseMetaTileEntity().markDirty();
}
return aFluid.amount;
}
if (doFill) {
setFillableStack(aFluid.copy());
getFillableStack().amount = getCapacity();
getBaseMetaTileEntity().markDirty();
}
return getCapacity();
}
if (!getFillableStack().isFluidEqual(aFluid)) return 0;
int space = getCapacity() - getFillableStack().amount;
if (aFluid.amount <= space) {
if (doFill) {
getFillableStack().amount += aFluid.amount;
getBaseMetaTileEntity().markDirty();
}
return aFluid.amount;
}
if (doFill) getFillableStack().amount = getCapacity();
return space;
}
@Override
public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
return false;
}
@Override
public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
return 0;
}
@Override
public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
return 0;
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setInteger("mProgresstime", mProgresstime);
aNBT.setInteger("mMaxProgresstime", mMaxProgresstime);
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
mProgresstime = aNBT.getInteger("mProgresstime");
mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
super.loadNBTData(aNBT);
}
}
|