use of mods.railcraft.common.blocks.logic.FluidLogic in project Railcraft by Railcraft.
the class TESRHollowTank method render.
@Override
public void render(TileTank tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
tile.getLogic(StructureLogic.class).filter(StructureLogic::isStructureValid).ifPresent(structure -> {
structure.getLogic(ValveLogic.class).ifPresent(valve -> {
StandardTank fillTank = valve.getFillTank();
FluidStack fillStack = fillTank.getFluid();
if (fillStack != null && fillStack.amount > 0) {
OpenGL.glPushMatrix();
if (structure.getPattern().getPatternMarkerChecked(structure.getPatternPosition().down()) == 'A') {
// prepFillTexture(fillStack);
int height = getTankHeight(structure);
float yOffset = height / 2f;
float vScale = height;
OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset - height + 1, (float) z + 0.5F);
OpenGL.glScalef(FILL_SCALE, vScale, FILL_SCALE);
draw(fillStack, tile.getPos().down());
} else if (structure.getPattern().getPatternMarkerChecked(structure.getPatternPosition().west()) == 'A') {
// prepFillTexture(fillStack);
float vScale = getVerticalScaleSide(structure);
float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
OpenGL.glTranslatef((float) x - 0.5F + RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
OpenGL.glScalef(FILL_SCALE, vScale, FILL_SCALE);
draw(fillStack, tile.getPos().west());
} else if (structure.getPattern().getPatternMarkerChecked(structure.getPatternPosition().east()) == 'A') {
// prepFillTexture(fillStack);
float vScale = getVerticalScaleSide(structure);
float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
OpenGL.glTranslatef((float) x + 1.5F - RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
OpenGL.glScalef(FILL_SCALE, vScale, FILL_SCALE);
draw(fillStack, tile.getPos().east());
} else if (structure.getPattern().getPatternMarkerChecked(structure.getPatternPosition().north()) == 'A') {
// prepFillTexture(fillStack);
float vScale = getVerticalScaleSide(structure);
float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z - 0.5F + RenderTools.PIXEL * 5);
OpenGL.glScalef(FILL_SCALE, vScale, FILL_SCALE);
draw(fillStack, tile.getPos().north());
} else if (structure.getPattern().getPatternMarkerChecked(structure.getPatternPosition().south()) == 'A') {
// prepFillTexture(fillStack);
float vScale = getVerticalScaleSide(structure);
float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z + 1.5F - RenderTools.PIXEL * 5);
OpenGL.glScalef(FILL_SCALE, vScale, FILL_SCALE);
draw(fillStack, tile.getPos().south());
}
OpenGL.glPopMatrix();
}
});
if (!structure.isValidMaster() || tile.isInvalid())
return;
int height = getTankHeight(structure);
float yOffset = height / 2f;
float vScale = height - 2;
float hScale = structure.getPattern().getPatternWidthX() - 2;
structure.getFunctionalLogic(FluidLogic.class).map(fluidLogic -> fluidLogic.getTankManager().get(0)).ifPresent(tank -> {
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null && fluidStack.amount > 0) {
preGL(fluidStack, tile.getPos().up());
OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset + 0.01f, (float) z + 0.5F);
OpenGL.glScalef(hScale, vScale, hScale);
OpenGL.glScalef(0.999f, 1, 0.999f);
// int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack); this broke
// OpenGL.glPushMatrix();
//
OpenGL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
float cap = tank.getCapacity();
OpenGL.glTranslatef(-0.5F, -0.501F, -0.5F);
float level = Math.min(fluidStack.amount / cap, 1.0F);
FluidModelRenderer.INSTANCE.renderFluid(fluidStack, Math.min(16, (int) Math.ceil(level * 16F)));
//
// bindTexture(FluidRenderer.getFluidSheet(fluidStack));
// FluidRenderer.setColorForFluid(fluidStack);
// OpenGL.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]);
postGL();
// OpenGL.glPopMatrix();
}
});
});
}
Aggregations