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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
import static gregtech.api.enums.GT_Values.V;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_Container_1by1;
import gregtech.api.gui.GT_GUIContainer_1by1;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.items.GT_MetaBase_Item;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.player.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import ic2.api.item.IElectricItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity {
/*
* public GregtechMetaEnergyBuffer() { super.this
* setCreativeTab(GregTech_API.TAB_GREGTECH); }
*/
public boolean mCharge = false, mDecharge = false;
public int mBatteryCount = 1, mChargeableCount = 1;
public GregtechMetaEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) {
super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription);
}
public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) {
super(aName, aTier, aSlotCount, aDescription, aTextures);
}
@Override
public String[] getDescription() {
return new String[] {this.mDescription, CORE.GT_Tooltip};
}
/*
* MACHINE_STEEL_SIDE
*/
@Override
public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
final ITexture[][][] rTextures = new ITexture[10][17][];
for (byte i = -1; i < 16; i++) {
rTextures[0][i + 1] = this.getFront(i);
rTextures[1][i + 1] = this.getBack(i);
rTextures[2][i + 1] = this.getBottom(i);
rTextures[3][i + 1] = this.getTop(i);
rTextures[4][i + 1] = this.getSides(i);
rTextures[5][i + 1] = this.getFrontActive(i);
rTextures[6][i + 1] = this.getBackActive(i);
rTextures[7][i + 1] = this.getBottomActive(i);
rTextures[8][i + 1] = this.getTopActive(i);
rTextures[9][i + 1] = this.getSidesActive(i);
}
return rTextures;
}
@Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];
}
public ITexture[] getFront(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]};
}
public ITexture[] getBack(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
public ITexture[] getBottom(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
public ITexture[] getTop(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)};
}
public ITexture[] getSides(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
public ITexture[] getFrontActive(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]};
}
public ITexture[] getBackActive(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
public ITexture[] getBottomActive(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
public ITexture[] getTopActive(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)};
}
public ITexture[] getSidesActive(final byte aColor) {
return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)};
}
/*@Override
public ITexture[][][] getTextureSet(ITexture[] aTextures) {
ITexture[][][] rTextures = new ITexture[2][17][];
for (byte i = -1; i < 16; i++) {
rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture(
Textures.BlockIcons.MACHINE_HEATPROOFCASING) };
rTextures[1][i + 1] = new ITexture[] {
new GT_RenderedTexture(
Textures.BlockIcons.MACHINE_HEATPROOFCASING),
mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]
: Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] };
}
return rTextures;
}*/
/*
* @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) {
* ITexture[][][] rTextures = new ITexture[5][17][]; for (byte i = -1; i <
* 16; i = (byte) (i + 1)) { ITexture[] tmp0 = { new GT_RenderedTexture(
* Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i,
* Dyes._NULL.mRGBa)) }; rTextures[0][(i + 1)] = tmp0; ITexture[] tmp1 = {
* new GT_RenderedTexture( Textures.BlockIcons.MACHINE_STEEL_TOP) };
* rTextures[1][(i + 1)] = tmp1; ITexture[] tmp2 = { new GT_RenderedTexture(
* Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i,
* Dyes._NULL.mRGBa)), new
* GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i +
* 1)] = tmp2; ITexture[] tmp4 = { new GT_RenderedTexture(
* Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i,
* Dyes._NULL.mRGBa)), new
* GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; rTextures[3][(i +
* 1)] = tmp4; ITexture[] tmp5 = { new GT_RenderedTexture(
* Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i,
* Dyes._NULL.mRGBa)), new GT_RenderedTexture(
* Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; rTextures[4][(i + 1)] = tmp5;
* } return rTextures; }
*/
/*@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1];
}*/
@Override
public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
return new GregtechMetaEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length);
}
@Override public boolean isSimpleMachine() {return false;}
@Override public boolean isElectric() {return true;}
@Override public boolean isValidSlot(final int aIndex) {return true;}
@Override public boolean isFacingValid(final byte aFacing) {return true;}
@Override public boolean isEnetInput() {return true;}
@Override public boolean isEnetOutput() {return true;}
@Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();}
@Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();}
@Override public boolean isTeleporterCompatible() {return false;}
@Override public long getMinimumStoredEU() {return V[this.mTier]*2;}
@Override public long maxEUStore() {return V[this.mTier]*250000;}
@Override
public long maxEUInput() {
return V[this.mTier];
}
@Override
public long maxEUOutput() {
return V[this.mTier];
}
@Override
public long maxAmperesIn() {
return this.mChargeableCount * 4;
}
@Override
public long maxAmperesOut() {
return this.mChargeableCount * 4;
}
@Override public int rechargerSlotStartIndex() {return 0;}
@Override public int dechargerSlotStartIndex() {return 0;}
@Override public int rechargerSlotCount() {return this.mCharge?this.mInventory.length:0;}
@Override public int dechargerSlotCount() {return this.mDecharge?this.mInventory.length:0;}
@Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();}
@Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();}
@Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;}
@Override
public void saveNBTData(final NBTTagCompound aNBT) {
//
}
@Override
public void loadNBTData(final NBTTagCompound aNBT) {
//
}
@Override
public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
Utils.LOG_WARNING("Right Click on MTE by Player");
if (aBaseMetaTileEntity.isClientSide())
{
return true;
//aBaseMetaTileEntity.openGUI(aPlayer);
}
Utils.LOG_WARNING("MTE is Client-side");
this.showEnergy(aPlayer.getEntityWorld(), aPlayer);
return true;
}
private void showEnergy(final World worldIn, final EntityPlayer playerIn){
final long tempStorage = this.getStoredEnergy()[0];
final double c = ((double) tempStorage / this.maxEUStore()) * 100;
final double roundOff = Math.round(c * 100.00) / 100.00;
PlayerUtils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[this.mTier]+"v ("+roundOff+"%)");
}
//Utils.LOG_WARNING("Begin Show Energy");
/*
*
//Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c);
Utils.LOG_INFO("getProgressTime: "+getProgresstime());
Utils.LOG_INFO("maxProgressTime: "+maxProgresstime());
Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU());
Utils.LOG_INFO("maxEUStore: "+maxEUStore());*/
/*final long d = (tempStorage * 100L) / maxEUStore();
Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d);
final double roundOff2 = Math.round(d * 100.00) / 100.00;
Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff2+"%)");
Utils.LOG_WARNING("Making new instance of Guihandler");
GuiHandler block = new GuiHandler();
Utils.LOG_WARNING("Guihandler.toString(): "+block.toString());
block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);*/
@Override
public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity);
}
@Override
public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName());
}
@Override
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
}
@Override
public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) {
return false;
}
@Override
public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) {
return false;
}
public long[] getStoredEnergy(){
long tScale = this.getBaseMetaTileEntity().getEUCapacity();
long tStored = this.getBaseMetaTileEntity().getStoredEU();
if (this.mInventory != null) {
for (final ItemStack aStack : this.mInventory) {
if (GT_ModHandler.isElectricItem(aStack)) {
if (aStack.getItem() instanceof GT_MetaBase_Item) {
final Long[] stats = ((GT_MetaBase_Item) aStack.getItem())
.getElectricStats(aStack);
if (stats != null) {
tScale = tScale + stats[0];
tStored = tStored
+ ((GT_MetaBase_Item) aStack.getItem())
.getRealCharge(aStack);
}
} else if (aStack.getItem() instanceof IElectricItem) {
tStored = tStored
+ (long) ic2.api.item.ElectricItem.manager
.getCharge(aStack);
tScale = tScale
+ (long) ((IElectricItem) aStack.getItem())
.getMaxCharge(aStack);
}
}
}
}
return new long[] { tStored, tScale };
}
private long count=0;
private long mStored=0;
private long mMax=0;
@Override
public String[] getInfoData() {
this.count++;
if((this.mMax==0)||((this.count%20)==0)){
final long[] tmp = this.getStoredEnergy();
this.mStored=tmp[0];
this.mMax=tmp[1];
}
return new String[] {
this.getLocalName(),
GT_Utility.formatNumbers(this.mStored)+" EU /",
GT_Utility.formatNumbers(this.mMax)+" EU"};
}
@Override
public boolean isGivingInformation() {
return true;
}
@Override
public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
return null;
}
@Override
public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
return false;
}
@Override
public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
return false;
}
@Override
public int getSizeInventory() {
return 0;
}
@Override
public ItemStack getStackInSlot(final int p_70301_1_) {
return null;
}
@Override
public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) {
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(final int p_70304_1_) {
return null;
}
@Override
public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {
}
@Override
public String getInventoryName() {
return null;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 0;
}
@Override
public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) {
return false;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) {
return false;
}
}
|