Skip to content

Commit

Permalink
Render Tank/Window/.. Liquid and Block in two different renderpasses.…
Browse files Browse the repository at this point in the history
… This should fix the lava derpiness.
  • Loading branch information
bonii-xx committed Aug 21, 2014
1 parent fe30efe commit 8a8beaf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/main/java/tconstruct/smeltery/blocks/LavaTankBlock.java
Expand Up @@ -100,6 +100,12 @@ public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, in
// return true;
}

@Override
public boolean canRenderInPass(int pass) {
TankRender.renderPass = pass;
return true;
}

@Override
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
Expand Down
40 changes: 21 additions & 19 deletions src/main/java/tconstruct/smeltery/model/TankRender.java
Expand Up @@ -19,6 +19,7 @@
public class TankRender implements ISimpleBlockRenderingHandler
{
public static int tankModelID = RenderingRegistry.getNextAvailableRenderId();
public static int renderPass = 0;

@Override
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
Expand All @@ -40,29 +41,30 @@ public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block
if (modelID == tankModelID)
{
//Liquid
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(x, y, z);
if (logic.containsFluid())
{
FluidStack liquid = logic.tank.getFluid();
renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
Fluid fluid = liquid.getFluid();
if (fluid.canBePlacedInWorld())
BlockSkinRenderHelper.renderMetadataBlock(fluid.getBlock(), 0, x, y, z, renderer, world);
else
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);
if(renderPass == 0) {
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(x, y, z);
if (logic.containsFluid()) {
FluidStack liquid = logic.tank.getFluid();
renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
Fluid fluid = liquid.getFluid();
if (fluid.canBePlacedInWorld())
BlockSkinRenderHelper.renderMetadataBlock(fluid.getBlock(), 0, x, y, z, renderer, world);
else
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);

renderer.setRenderBounds(00, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
renderer.setRenderBounds(00, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
}
}

//Block
int meta = world.getBlockMetadata(x, y, z);
if (meta == 0 && world.getBlock(x, y + 1, z) == Blocks.air)
{
renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125);
renderer.renderStandardBlock(block, x, y + 1, z);
else {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 0 && world.getBlock(x, y + 1, z) == Blocks.air) {
renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125);
renderer.renderStandardBlock(block, x, y + 1, z);
}
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
renderer.renderStandardBlock(block, x, y, z);
}
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
renderer.renderStandardBlock(block, x, y, z);
}
return true;
}
Expand Down

0 comments on commit 8a8beaf

Please sign in to comment.