-
Notifications
You must be signed in to change notification settings - Fork 497
/
PlugPluggable.java
120 lines (95 loc) · 3.67 KB
/
PlugPluggable.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
111
112
113
114
115
116
117
118
119
120
package buildcraft.transport;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.pipes.IPipe;
import buildcraft.api.pipes.IPipeContainer;
import buildcraft.api.pipes.IPipePluggableRenderer;
import buildcraft.api.pipes.PipePluggable;
import buildcraft.core.utils.MatrixTranformations;
public class PlugPluggable extends PipePluggable {
public class PlugPluggableRenderer implements IPipePluggableRenderer {
private float zFightOffset = 1 / 4096.0F;
@Override
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, ITextureStates blockStateMachine, int renderPass, int x, int y, int z) {
if (renderPass != 0) {
return;
}
float[][] zeroState = new float[3][2];
// X START - END
zeroState[0][0] = 0.25F + zFightOffset;
zeroState[0][1] = 0.75F - zFightOffset;
// Y START - END
zeroState[1][0] = 0.125F;
zeroState[1][1] = 0.251F;
// Z START - END
zeroState[2][0] = 0.25F + zFightOffset;
zeroState[2][1] = 0.75F - zFightOffset;
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
float[][] rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, side);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
// X START - END
zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset;
zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset;
// Y START - END
zeroState[1][0] = 0.25F;
zeroState[1][1] = 0.25F + 0.125F;
// Z START - END
zeroState[2][0] = 0.25F + 0.125F / 2;
zeroState[2][1] = 0.75F - 0.125F / 2;
blockStateMachine.getTextureState().set(BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal())); // Structure Pipe
rotated = MatrixTranformations.deepClone(zeroState);
MatrixTranformations.transform(rotated, side);
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
}
}
public PlugPluggable() {
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
}
@Override
public ItemStack[] getDropItems(IPipeContainer pipe) {
return new ItemStack[] { new ItemStack(BuildCraftTransport.plugItem) };
}
@Override
public boolean isBlocking(IPipeContainer pipe, ForgeDirection direction) {
return true;
}
@Override
public AxisAlignedBB getBoundingBox(ForgeDirection side) {
float[][] bounds = new float[3][2];
// X START - END
bounds[0][0] = 0.25F;
bounds[0][1] = 0.75F;
// Y START - END
bounds[1][0] = 0.125F;
bounds[1][1] = 0.251F;
// Z START - END
bounds[2][0] = 0.25F;
bounds[2][1] = 0.75F;
MatrixTranformations.transform(bounds, side);
return AxisAlignedBB.getBoundingBox(bounds[0][0], bounds[1][0], bounds[2][0], bounds[0][1], bounds[1][1], bounds[2][1]);
}
@Override
public IPipePluggableRenderer getRenderer() {
return new PlugPluggableRenderer();
}
@Override
public void writeData(ByteBuf data) {
}
@Override
public void readData(ByteBuf data) {
}
}