Skip to content

Commit

Permalink
Render liquid colors in tanks. Alpha not possible without complete re…
Browse files Browse the repository at this point in the history
…write.
  • Loading branch information
bonii-xx committed Nov 13, 2014
1 parent 2c7362e commit 5b2f1f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/main/java/tconstruct/client/BlockSkinRenderHelper.java
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;

public class BlockSkinRenderHelper
{
Expand Down Expand Up @@ -859,9 +860,10 @@ public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int
public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world, boolean extraBright, int color)
{
Block block = Blocks.stone;
float red = (float) (color >> 16 & 255) / 255.0F;
float alpha = (float) (color >> 24 & 255) / 255.0F;
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;

if (EntityRenderer.anaglyphEnable)
{
Expand Down Expand Up @@ -889,12 +891,19 @@ public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int
boolean raf = renderer.renderAllFaces;
renderer.renderAllFaces = true;

//Tessellator.instance.setColorRGBA_F(alpha, red, green, blue);

GL11.glEnable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);

boolean ret;
if (Minecraft.isAmbientOcclusionEnabled())
ret = renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world);
else
ret = renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world);

GL11.glDisable(GL11.GL_BLEND);

renderer.renderAllFaces = raf;
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/smeltery/model/TankRender.java
Expand Up @@ -45,7 +45,7 @@ public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block
FluidStack liquid = logic.tank.getFluid();
renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
Fluid fluid = liquid.getFluid();
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getStillIcon(), x, y, z, renderer, world, true, fluid.getColor(liquid));
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getStillIcon(), x, y, z, renderer, world, false, fluid.getColor(liquid));

renderer.setRenderBounds(0, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
}
Expand Down

0 comments on commit 5b2f1f5

Please sign in to comment.