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
|
package gtnhlanth.common.hatch;
import static gregtech.api.enums.Dyes.MACHINE_METAL;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
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.objects.GTRenderedTexture;
import gtnhlanth.common.beamline.BeamLinePacket;
import gtnhlanth.common.beamline.IConnectsToBeamline;
import gtnhlanth.common.beamline.MTEBeamlinePipe;
import tectech.util.TTUtility;
public class MTEHatchOutputBeamline extends MTEHatchBeamlineConnector<BeamLinePacket> implements IConnectsToBeamline {
private static final String activeIconPath = "iconsets/OVERLAY_BO_ACTIVE";
private static final String sideIconPath = "iconsets/OVERLAY_BO_SIDES";
private static final String connIconPath = "iconsets/BO_CONN";
private static final Textures.BlockIcons.CustomIcon activeIcon = new Textures.BlockIcons.CustomIcon(activeIconPath);
private static final Textures.BlockIcons.CustomIcon sideIcon = new Textures.BlockIcons.CustomIcon(sideIconPath);
private static final Textures.BlockIcons.CustomIcon connIcon = new Textures.BlockIcons.CustomIcon(connIconPath);
public MTEHatchOutputBeamline(int id, String name, String nameRegional, int tier) {
super(id, name, nameRegional, tier, "");
TTUtility.setTier(tier, this);
}
public MTEHatchOutputBeamline(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aDescription, aTextures);
}
@Override
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture,
new GTRenderedTexture(
activeIcon,
Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())),
new GTRenderedTexture(connIcon) };
}
@Override
public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture,
new GTRenderedTexture(
sideIcon,
Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())),
new GTRenderedTexture(connIcon) };
}
@Override
public IConnectsToBeamline getNext(IConnectsToBeamline source) {
IGregTechTileEntity base = this.getBaseMetaTileEntity();
IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing());
if (next == null) {
return null;
}
IMetaTileEntity meta = next.getMetaTileEntity();
if (meta instanceof MTEBeamlinePipe) {
((MTEBeamlinePipe) meta).markUsed();
return (IConnectsToBeamline) meta;
} else if (meta instanceof MTEHatchInputBeamline && ((MTEHatchInputBeamline) meta).canConnect(
base.getFrontFacing()
.getOpposite())) {
return (IConnectsToBeamline) meta;
}
return null;
}
@Override
public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) {
IConnectsToBeamline current = this, source = this, next;
int range = 0;
ForgeDirection front = this.getBaseMetaTileEntity()
.getFrontFacing();
for (int distance = 1; distance <= 129; distance++) { // 128 pipes max
IGregTechTileEntity nextTE = (IGregTechTileEntity) this.getBaseMetaTileEntity()
.getTileEntityAtSideAndDistance(front, distance); // Straight line transmission only
if (nextTE == null) {
return;
}
IMetaTileEntity nextMeta = nextTE.getMetaTileEntity();
if (nextMeta == null || !(nextMeta instanceof IConnectsToBeamline)) { // Non-beamliney block
return;
}
if (((IConnectsToBeamline) nextMeta) instanceof MTEHatchInputBeamline) {
((MTEHatchInputBeamline) nextMeta).setContents(q); // Reached another multi
break;
} else if (((IConnectsToBeamline) nextMeta) instanceof MTEBeamlinePipe) { // Another pipe follows
if (((MTEBeamlinePipe) nextMeta).isDataInputFacing(front.getOpposite())) { // Connected to previous pipe
((MTEBeamlinePipe) nextMeta).markUsed();
} else {
return;
}
} else {
return;
}
}
/*
* while ((next = current.getNext(source)) != null && range++ < 100) {
* if (next instanceof TileHatchInputBeamline) {
* ((TileHatchInputBeamline) next).setContents(q);
* break;
* }
* source = current;
* current = next;
* }
*/
q = null;
}
@Override
protected BeamLinePacket loadPacketFromNBT(NBTTagCompound nbt) {
return new BeamLinePacket(nbt);
}
@Override
public boolean canConnect(ForgeDirection side) {
return this.isOutputFacing(side);
}
@Override
public boolean isDataInputFacing(ForgeDirection side) {
return this.isInputFacing(side);
}
@Override
public boolean isFacingValid(ForgeDirection facing) {
return true;
}
@Override
public boolean isInputFacing(ForgeDirection aSide) {
return false;
}
@Override
public boolean isOutputFacing(ForgeDirection side) {
return side == this.getBaseMetaTileEntity()
.getFrontFacing();
}
@Override
public String[] getDescription() {
return null;
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) {
return new MTEHatchOutputBeamline(mName, mTier, mDescriptionArray, mTextures);
}
}
|