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
|
package common.tileentities;
import java.util.ArrayList;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import util.Vector3i;
import util.Vector3ic;
import common.Blocks;
import gregtech.api.enums.Dyes;
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;
public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
private static final Block BASE_BLOCK = Blocks.spaceElevatorStructure;
private static final Block CAP_BLOCK = Blocks.spaceElevatorCapacitor;
private static final Block TETHER_BLOCK = Blocks.spaceElevatorTether;
private static final int BASE_META = 0;
private static final int COIL_HOLDER_META = 1;
private static final String glassNameBorosilicate = "BW_GlasBlocks";
private static final int HATCH_OVERLAY_ID = 16;
// Scan positions for capacitor banks
// Start with top left bank, clockwise
// Start with top middle pillar within bank, clockwise, middle last
private static final int[] bankOffsetsX = { -7, 5, 5, -7 };
private static final int[] bankOffsetsY = { -7, -7, 5, 5 };
private static final int[] scanOffsetsX = { 1, 2, 1, 0, 1 };
private static final int[] scanOffsetsY = { 0, 1, 2, 1, 1 };
private final HashSet<TE_SpaceElevatorCapacitor> capacitors = new HashSet<>();
private long lastLaunchEUCost = 0;
public GTMTE_SpaceElevator(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GTMTE_SpaceElevator(String aName) {
super(aName);
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
return new GTMTE_SpaceElevator((super.mName));
}
@Override
public String[] getDescription() {
return new String[] { "Disabled" };
/*
* final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
* b.addInfo("Access for your Space Station!")
* .addInfo("Check out the wiki on my github if you are having trouble with the structure")
* .addInfo("Regenerative Breaking will recover up to X% of the energy spent on launch")
* .addInfo("Energy recovered depends on coil tier: +10% per coil tier, up to 90%") .addSeparator()
* .beginStructureBlock(15, 11, 15) .addController("Bottom Center")
* .addEnergyHatch("Instead of any casing in the bottom floor")
* .addMaintenanceHatch("Instead of any casing in the bottom floor")
* .addCasingInfo("Solid Steel Machine Casing", 320) .addOtherStructurePart("Any EBF coil",
* "40x, have to be all the same") .addOtherStructurePart("Space Elevator Tether", "4x")
* .addOtherStructurePart("Space Elevator Cabin Block", "42x")
* .addOtherStructurePart("Space Elevator Cabin Guide", "8x") .signAndFinalize("Kekzdealer");
* if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { return b.getInformation(); } else { return
* b.getStructureInformation(); }
*/
}
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
boolean aActive, boolean aRedstone) {
ITexture[] sTexture = new ITexture[] { new GT_RenderedTexture(
Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS,
Dyes.getModulation(-1, Dyes._NULL.mRGBa)) };
if (aSide == aFacing && aActive) {
sTexture = new ITexture[] { new GT_RenderedTexture(
Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW,
Dyes.getModulation(-1, Dyes._NULL.mRGBa)) };
}
return sTexture;
}
@Override
public boolean isCorrectMachinePart(ItemStack stack) {
return true;
}
@Override
public boolean checkRecipe(ItemStack stack) {
this.mProgresstime = 1;
this.mMaxProgresstime = 1;
this.mEUt = 0;
this.mEfficiencyIncrease = 10000;
return true;
}
public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) {
final Vector3i offset = new Vector3i(0, 0, 0);
// either direction on y-axis
if (forgeDirection.y() == -1) {
offset.x = x;
offset.y = z;
offset.z = y;
}
return offset;
}
@Override
public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
// Make sure the controller is either facing up or down
if (thisController.getFrontFacing() > 1) {
return false;
}
// Figure out the vector for the direction the back face of the controller is facing
final Vector3ic forgeDirection = new Vector3i(
ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX,
ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY,
ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ);
boolean formationChecklist = true;
int minCasingAmount = 320;
int firstCoilMeta = -1;
capacitors.clear();
// Base floor
for (int X = -7; X <= 7; X++) {
for (int Y = -7; Y <= 7; Y++) {
if (X == 0 && Y == 0) {
continue; // Skip controller
}
final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0);
final IGregTechTileEntity currentTE = thisController
.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
// Tries to add TE as either of those kinds of hatches.
// The number is the texture index number for the texture that needs to be painted over the hatch
// texture
if (!super.addMaintenanceToMachineList(currentTE, HATCH_OVERLAY_ID)
&& !this.addEnergyInputToMachineList(currentTE, HATCH_OVERLAY_ID)) {
// If it's not a hatch, is it the right casing for this machine? Check block and block meta.
if ((thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == BASE_BLOCK)
&& (thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == BASE_META)) {
// Seems to be valid casing. Decrement counter.
minCasingAmount--;
} else {
formationChecklist = false;
}
}
}
}
System.out.println("");
// Capacitor banks
for (int bank = 0; bank < 4; bank++) {
for (int Z = 1; Z <= 5; Z++) {
for (int scan = 0; scan < 5; scan++) {
final Vector3ic offset = rotateOffsetVector(
forgeDirection,
bankOffsetsX[bank] + scanOffsetsX[scan],
bankOffsetsY[bank] + scanOffsetsY[scan],
Z);
if (Z == 1 || Z == 5) {
// Check for casings
if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == BASE_BLOCK
&& thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == BASE_META) {
minCasingAmount--;
} else {
formationChecklist = false;
}
} else {
if (scan == 4) {
// Check for capacitors
final TileEntity te = thisController
.getTileEntityOffset(offset.x(), offset.y(), offset.z());
if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CAP_BLOCK
&& te instanceof TE_SpaceElevatorCapacitor) {
capacitors.add((TE_SpaceElevatorCapacitor) te);
} else {
formationChecklist = false;
}
} else {
// Check for Glass
if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
.equals(glassNameBorosilicate)) {
formationChecklist = false;
}
}
}
}
}
}
// Anchor
// Coil holders
// Coils
if (minCasingAmount > 0) {
formationChecklist = false;
}
for (TE_SpaceElevatorCapacitor cap : capacitors) {
cap.setIsDamaged(false);
}
return formationChecklist;
}
@Override
public String[] getInfoData() {
final ArrayList<String> ll = new ArrayList<>();
ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
ll.add(
"Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
: EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
ll.add("---------------------------------------------");
final String[] a = new String[ll.size()];
return ll.toArray(a);
}
@Override
public boolean isGivingInformation() {
return true;
}
@Override
public int getMaxEfficiency(ItemStack stack) {
return 10000;
}
@Override
public int getPollutionPerTick(ItemStack stack) {
return 0;
}
@Override
public int getDamageToComponent(ItemStack stack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack stack) {
return false;
}
}
|