use of buildcraft.lib.client.model.MutableVertex in project BuildCraft by BuildCraft.
the class RenderZonePlanner method render.
@Override
public final void render(TileZonePlanner tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Minecraft.getMinecraft().mcProfiler.startSection("bc");
Minecraft.getMinecraft().mcProfiler.startSection("zone");
double offset = 0.001;
double minX = 3 / 16D - offset;
double maxX = 13 / 16D + offset;
double minY = 5 / 16D - offset;
double maxY = 13 / 16D + offset;
double minZ = -offset;
double maxZ = 1 + offset;
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
if (state.getBlock() != BCRoboticsBlocks.zonePlanner) {
return;
}
EnumFacing side = state.getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
DynamicTextureBC texture = getTexture(tile, side);
if (texture == null) {
return;
}
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
texture.updateTexture();
texture.bindGlTexture();
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.disableTexture2D();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
GlStateManager.disableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
buffer.setTranslation(x, y, z);
Vec3d min;
Vec3d max;
float minU = 0;
float maxU = texture.getMaxU();
float minV = 0;
float maxV = texture.getMaxV();
switch(side) {
case NORTH:
min = new Vec3d(minX, minY, maxZ);
max = new Vec3d(maxX, maxY, maxZ);
break;
case EAST:
min = new Vec3d(minZ, minY, minX);
max = new Vec3d(minZ, maxY, maxX);
break;
case SOUTH:
min = new Vec3d(minX, minY, minZ);
max = new Vec3d(maxX, maxY, minZ);
break;
case WEST:
default:
min = new Vec3d(maxZ, minY, minX);
max = new Vec3d(maxZ, maxY, maxX);
break;
}
MutableVertex vertex = new MutableVertex();
vertex.colouri(-1);
vertex.lighti(0xF, 0xF);
vertex.positiond(min.x, min.y, min.z).texf(minU, minV).render(buffer);
vertex.positiond(max.x, min.y, max.z).texf(maxU, minV).render(buffer);
vertex.positiond(max.x, max.y, max.z).texf(maxU, maxV).render(buffer);
vertex.positiond(min.x, max.y, min.z).texf(minU, maxV).render(buffer);
buffer.setTranslation(0, 0, 0);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
Minecraft.getMinecraft().mcProfiler.endSection();
Minecraft.getMinecraft().mcProfiler.endSection();
}
Aggregations