use of mods.railcraft.api.tracks.ITrackSwitch in project Railcraft by Railcraft.
the class RenderTrack method renderWorldBlock.
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderblocks) {
int meta = ((BlockRailBase) block).getBasicRailMetadata(world, null, x, y, z);
IIcon icon;
TileEntity tile = world.getTileEntity(x, y, z);
ITrackInstance track = null;
if (tile instanceof TileTrack) {
track = ((TileTrack) tile).getTrackInstance();
icon = renderblocks.getIconSafe(track.getIcon());
} else {
icon = Blocks.RAIL.getIcon(0, 0);
}
if (renderblocks.hasOverrideBlockTexture()) {
icon = renderblocks.overrideBlockTexture;
}
float minU = icon.getMinU();
float minV = icon.getMinV();
float maxU = icon.getMaxU();
float maxV = icon.getMaxV();
double pix = 0.0625D;
double vertX1 = x + 1;
double vertX2 = x + 1;
double vertX3 = x + 0;
double vertX4 = x + 0;
double vertZ1 = z + 0;
double vertZ2 = z + 1;
double vertZ3 = z + 1;
double vertZ4 = z + 0;
double vertY1 = y + pix;
double vertY2 = y + pix;
double vertY3 = y + pix;
double vertY4 = y + pix;
if (meta != 1 && meta != 2 && meta != 3 && meta != 7) {
if (meta == 8) {
vertX1 = vertX2 = x + 0;
vertX3 = vertX4 = x + 1;
vertZ1 = vertZ4 = z + 1;
vertZ2 = vertZ3 = z + 0;
} else if (meta == 9) {
vertX1 = vertX4 = x + 0;
vertX2 = vertX3 = x + 1;
vertZ1 = vertZ2 = z + 0;
vertZ3 = vertZ4 = z + 1;
}
} else {
vertX1 = vertX4 = x + 1;
vertX2 = vertX3 = x + 0;
vertZ1 = vertZ2 = z + 1;
vertZ3 = vertZ4 = z + 0;
}
if (meta != 2 && meta != 4) {
if (meta == 3 || meta == 5) {
vertY2++;
vertY3++;
}
} else {
vertY1++;
vertY4++;
}
if (track != null) {
if (track instanceof ITrackSwitch) {
ITrackSwitch switchTrack = (ITrackSwitch) track;
if (switchTrack.isMirrored()) {
float temp = minU;
minU = maxU;
maxU = temp;
temp = minV;
minV = maxV;
maxV = temp;
}
} else if (track instanceof TrackGated) {
renderGatedTrack(renderblocks, (TrackGated) track, x, y, z, meta);
}
}
Tessellator tess = Tessellator.instance;
tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tess.setColorOpaque_F(1.0F, 1.0F, 1.0F);
tess.addVertexWithUV(vertX1, vertY1, vertZ1, maxU, minV);
tess.addVertexWithUV(vertX2, vertY2, vertZ2, maxU, maxV);
tess.addVertexWithUV(vertX3, vertY3, vertZ3, minU, maxV);
tess.addVertexWithUV(vertX4, vertY4, vertZ4, minU, minV);
tess.addVertexWithUV(vertX4, vertY4, vertZ4, minU, minV);
tess.addVertexWithUV(vertX3, vertY3, vertZ3, minU, maxV);
tess.addVertexWithUV(vertX2, vertY2, vertZ2, maxU, maxV);
tess.addVertexWithUV(vertX1, vertY1, vertZ1, maxU, minV);
return true;
}
Aggregations