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
|
package gregtech.common.tileentities.machines.basic;
import static gregtech.api.enums.GTValues.V;
import net.minecraft.item.ItemStack;
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.BaseMetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTUtility;
/**
* Created by danie_000 on 15.10.2016.
*/
public class MTETurboCharger extends MTECharger {
public MTETurboCharger(int aID, String aName, String aNameRegional, int aTier, String aDescription,
int aSlotCount) {
super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount);
}
public MTETurboCharger(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) {
super(aName, aTier, aDescription, aTextures, aSlotCount);
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTETurboCharger(mName, mTier, mDescriptionArray, mTextures, mInventory.length);
}
@Override
public ITexture[][][] getTextureSet(ITexture[] aTextures) {
ITexture[][][] rTextures = new ITexture[2][17][];
for (byte b = -1; b < 16; b++) {
rTextures[0][b + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][b + 1] };
rTextures[1][b + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][b + 1],
Textures.BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] };
}
return rTextures;
}
@Override
public long getMinimumStoredEU() {
return V[mTier] * 1536L * mInventory.length;
}
@Override
public long maxEUStore() {
return V[mTier] * 6144L * mInventory.length;
}
@Override
public long maxAmperesIn() {
return 16L * mInventory.length;
}
@Override
public long maxAmperesOut() {
return 4L * mInventory.length;
}
@Override
public long maxEUInput() {
return V[mTier];
}
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3
|| !aBaseMetaTileEntity.isAllowedToWork();
mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3
&& aBaseMetaTileEntity.isAllowedToWork();
mBatteryCount = 0;
mChargeableCount = 0;
for (ItemStack tStack : mInventory) {
if (GTModHandler.isElectricItem(tStack, mTier)) {
if (GTModHandler.isChargerItem(tStack)) {
mBatteryCount++;
}
mChargeableCount++;
}
}
if (getBaseMetaTileEntity() instanceof BaseMetaTileEntity) {
BaseMetaTileEntity mBaseMetaTileEntity = (BaseMetaTileEntity) getBaseMetaTileEntity();
if (mBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) {
MetaTileEntity mMetaTileEntity = (MetaTileEntity) mBaseMetaTileEntity.getMetaTileEntity();
if (mMetaTileEntity.dechargerSlotCount() > 0
&& mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) {
for (int i = mMetaTileEntity.dechargerSlotStartIndex(),
k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) {
if (mMetaTileEntity.mInventory[i] != null
&& mBaseMetaTileEntity.getStoredEU() < mBaseMetaTileEntity.getEUCapacity()) {
// CODE
mBaseMetaTileEntity.increaseStoredEnergyUnits(
GTModHandler.dischargeElectricItem(
mMetaTileEntity.mInventory[i],
GTUtility.safeInt(
Math.min(
V[mTier] * 120,
mBaseMetaTileEntity.getEUCapacity()
- mBaseMetaTileEntity.getStoredEU())),
(int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()),
true,
false,
false),
true);
if (mMetaTileEntity.mInventory[i].stackSize <= 0) {
mMetaTileEntity.mInventory[i] = null;
}
}
}
}
if (mMetaTileEntity.rechargerSlotCount() > 0 && mBaseMetaTileEntity.getStoredEU() > 0) {
for (int i = mMetaTileEntity.rechargerSlotStartIndex(),
k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) {
if (mBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
// CODE
mBaseMetaTileEntity
.decreaseStoredEU(
GTModHandler.chargeElectricItem(
mMetaTileEntity.mInventory[i],
GTUtility
.safeInt(Math.min(V[mTier] * 120, mBaseMetaTileEntity.getStoredEU())),
(int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()),
true,
false),
true);
if (mMetaTileEntity.mInventory[i].stackSize <= 0) {
mMetaTileEntity.mInventory[i] = null;
}
}
}
}
}
}
}
}
}
|