-
Notifications
You must be signed in to change notification settings - Fork 497
/
PipeRenderState.java
110 lines (89 loc) · 2.83 KB
/
PipeRenderState.java
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
package buildcraft.transport;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.util.Icon;
import buildcraft.core.DefaultProps;
import buildcraft.core.network.IClientState;
import buildcraft.transport.utils.ConnectionMatrix;
import buildcraft.transport.utils.FacadeMatrix;
import buildcraft.transport.utils.TextureMatrix;
import buildcraft.transport.utils.WireMatrix;
public class PipeRenderState implements IClientState {
private String textureFile = DefaultProps.TEXTURE_BLOCKS;
private boolean hasGate = false;
private int gateTextureIndex = 0;
public final ConnectionMatrix pipeConnectionMatrix = new ConnectionMatrix();
public final TextureMatrix textureMatrix = new TextureMatrix();
public final WireMatrix wireMatrix = new WireMatrix();
public final FacadeMatrix facadeMatrix = new FacadeMatrix();
private boolean dirty = false;
/*
* This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will then return the the WorldRenderer
*/
public Icon currentTexture;
public PipeRenderState() {
// for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
// facadeMatrix.setConnected(direction, true);
// facadeMatrix.setTextureFile(direction, "/terrain.png");
// facadeMatrix.setTextureIndex(direction, direction.ordinal());
// }
}
public void setTextureFile(String textureFile) {
if (this.textureFile != textureFile) {
this.textureFile = textureFile;
this.dirty = true;
}
}
public String getTextureFile() {
return this.textureFile;
}
public void setHasGate(boolean value) {
if (hasGate != value) {
hasGate = value;
dirty = true;
}
}
public boolean hasGate() {
return hasGate;
}
public void setGateTexture(int value) {
if (gateTextureIndex != value) {
gateTextureIndex = value;
dirty = true;
}
}
public int getGateTextureIndex() {
return gateTextureIndex;
}
public void clean() {
dirty = false;
pipeConnectionMatrix.clean();
textureMatrix.clean();
wireMatrix.clean();
facadeMatrix.clean();
}
public boolean isDirty() {
return dirty || pipeConnectionMatrix.isDirty() || textureMatrix.isDirty() || wireMatrix.isDirty() || facadeMatrix.isDirty();
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeUTF(textureFile);
data.writeBoolean(hasGate);
data.writeInt(gateTextureIndex);
pipeConnectionMatrix.writeData(data);
textureMatrix.writeData(data);
wireMatrix.writeData(data);
facadeMatrix.writeData(data);
}
@Override
public void readData(DataInputStream data) throws IOException {
textureFile = data.readUTF();
hasGate = data.readBoolean();
gateTextureIndex = data.readInt();
pipeConnectionMatrix.readData(data);
textureMatrix.readData(data);
wireMatrix.readData(data);
facadeMatrix.readData(data);
}
}