use of buildcraft.factory.tile.TileHeatExchange.ExchangeSectionEnd in project BuildCraft by BuildCraft.
the class RenderHeatExchange method render.
@Override
public void render(TileHeatExchange tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
super.render(tile, x, y, z, partialTicks, destroyStage, alpha);
if (!tile.isStart()) {
return;
}
ExchangeSectionStart section = (ExchangeSectionStart) tile.getSection();
ExchangeSectionEnd sectionEnd = section.getEndSection();
IBlockState state = tile.getCurrentStateForBlock(BCFactoryBlocks.heatExchange);
if (state == null) {
return;
}
Profiler profiler = Minecraft.getMinecraft().mcProfiler;
profiler.startSection("bc");
profiler.startSection("heat_exchange");
int combinedLight = tile.getWorld().getCombinedLight(tile.getPos(), 0);
// gl state setup
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.enableBlend();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
// buffer setup
BufferBuilder bb = Tessellator.getInstance().getBuffer();
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
bb.setTranslation(x, y, z);
profiler.startSection("tank");
EnumFacing face = state.getValue(BlockBCBase_Neptune.PROP_FACING).rotateYCCW();
TankSideData sideTank = TANK_SIDES.get(face);
renderTank(TANK_BOTTOM, section.smoothedTankInput, combinedLight, partialTicks, bb);
renderTank(sideTank.start, section.smoothedTankOutput, combinedLight, partialTicks, bb);
int middles = section.middleCount;
if (sectionEnd != null) {
// TODO: Move this into the other renderer!
BlockPos diff = sectionEnd.tile.getPos().subtract(tile.getPos());
bb.setTranslation(x + diff.getX(), y + diff.getY(), z + diff.getZ());
renderTank(TANK_TOP, sectionEnd.smoothedTankOutput, combinedLight, partialTicks, bb);
renderTank(sideTank.end, sectionEnd.smoothedTankInput, combinedLight, partialTicks, bb);
bb.setTranslation(x, y, z);
}
profiler.endStartSection("flow");
if (middles > 0 && sectionEnd != null) {
EnumProgressState progressState = section.getProgressState();
double progress = section.getProgress(partialTicks);
if (progress > 0) {
double length = middles + 1 - 4 / 16.0 - 0.02;
double p0 = 2 / 16.0 + 0.01;
double p1 = p0 + length - 0.01;
double progressStart = p0;
double progressEnd = p0 + length * progress;
boolean flip = progressState == EnumProgressState.PREPARING;
flip ^= face.getAxisDirection() == AxisDirection.NEGATIVE;
if (flip) {
progressStart = p1 - length * progress;
progressEnd = p1;
}
BlockPos diff = BlockPos.ORIGIN;
if (face.getAxisDirection() == AxisDirection.NEGATIVE) {
diff = diff.offset(face, middles);
}
double otherStart = flip ? p0 : p1 - length * progress;
double otherEnd = flip ? p0 + length * progress : p1;
Vec3d vDiff = new Vec3d(diff).addVector(x, y, z);
renderFlow(vDiff, face, bb, progressStart + 0.01, progressEnd - 0.01, sectionEnd.smoothedTankInput.getFluidForRender(), 4, partialTicks);
renderFlow(vDiff, face.getOpposite(), bb, otherStart, otherEnd, section.smoothedTankInput.getFluidForRender(), 2, partialTicks);
}
}
// buffer finish
bb.setTranslation(0, 0, 0);
profiler.endStartSection("draw");
Tessellator.getInstance().draw();
// gl state finish
RenderHelper.enableStandardItemLighting();
profiler.endSection();
profiler.endSection();
profiler.endSection();
}
Aggregations