Merge pull request #2314 from ganymedes01/6.3.x

Fix mirrored hollow facade texture.
This commit is contained in:
Adrian Siekierka 2014-12-17 06:45:23 +01:00
commit 071e65e337
2 changed files with 27 additions and 22 deletions

View file

@ -8,8 +8,6 @@
*/ */
package buildcraft.transport.render; package buildcraft.transport.render;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@ -17,6 +15,9 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.facades.FacadeType; import buildcraft.api.facades.FacadeType;
import buildcraft.api.facades.IFacadeItem; import buildcraft.api.facades.IFacadeItem;
@ -25,10 +26,10 @@ import buildcraft.core.render.RenderUtils;
import buildcraft.transport.ItemFacade; import buildcraft.transport.ItemFacade;
import buildcraft.transport.ItemFacade.FacadeState; import buildcraft.transport.ItemFacade.FacadeState;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.TransportConstants;
public class FacadeItemRenderer implements IItemRenderer { public class FacadeItemRenderer implements IItemRenderer {
private static final float zFightOffset = 1F / 4096F;
private long lastTime = 0L; private long lastTime = 0L;
private int renderState = 0; private int renderState = 0;
@ -68,8 +69,8 @@ public class FacadeItemRenderer implements IItemRenderer {
IIcon icon4 = tryGetBlockIcon(block, 4, decodedMeta); IIcon icon4 = tryGetBlockIcon(block, 4, decodedMeta);
IIcon icon5 = tryGetBlockIcon(block, 5, decodedMeta); IIcon icon5 = tryGetBlockIcon(block, 5, decodedMeta);
float width = 14F / 16F; float width = 1 - TransportConstants.FACADE_THICKNESS;
float cavity = 4F / 16F; float cavity = (CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS) / 2F;
double innerWidth = 1 - cavity; double innerWidth = 1 - cavity;
tessellator.startDrawingQuads(); tessellator.startDrawingQuads();
@ -96,6 +97,7 @@ public class FacadeItemRenderer implements IItemRenderer {
render.renderFaceXPos(block, -innerWidth, 0, 0, icon5); render.renderFaceXPos(block, -innerWidth, 0, 0, icon5);
//Hollow //Hollow
render.field_152631_f = true;
render.setRenderBounds(0, 0, width, cavity, 1, 1); render.setRenderBounds(0, 0, width, cavity, 1, 1);
tessellator.setNormal(0, 0, -1); tessellator.setNormal(0, 0, -1);
render.renderFaceZNeg(block, 0, 0, 0, icon2); render.renderFaceZNeg(block, 0, 0, 0, icon2);
@ -106,6 +108,7 @@ public class FacadeItemRenderer implements IItemRenderer {
render.renderFaceZNeg(block, 0, 0, 0, icon2); render.renderFaceZNeg(block, 0, 0, 0, icon2);
tessellator.setNormal(0, 0, 1); tessellator.setNormal(0, 0, 1);
render.renderFaceZPos(block, 0, 0, 0, icon3); render.renderFaceZPos(block, 0, 0, 0, icon3);
render.field_152631_f = false;
render.setRenderBounds(cavity, 0, width, innerWidth, cavity, 1); render.setRenderBounds(cavity, 0, width, innerWidth, cavity, 1);
tessellator.setNormal(0, 0, -1); tessellator.setNormal(0, 0, -1);
@ -171,7 +174,7 @@ public class FacadeItemRenderer implements IItemRenderer {
GL11.glTranslatef(translateX, translateY, translateZ); GL11.glTranslatef(translateX, translateY, translateZ);
drawHollowCube(tessellator, render, block, decodedMeta); drawHollowCube(tessellator, render, block, decodedMeta);
} else { } else {
render.setRenderBounds(0F, 0F, 14F / 16F, 1F, 1F, 1F); render.setRenderBounds(0F, 0F, 1 - TransportConstants.FACADE_THICKNESS, 1F, 1F, 1F);
GL11.glTranslatef(translateX, translateY, translateZ); GL11.glTranslatef(translateX, translateY, translateZ);
drawCube(tessellator, render, block, decodedMeta); drawCube(tessellator, render, block, decodedMeta);
} }

View file

@ -149,6 +149,7 @@ public final class FacadeRenderHelper {
// Hollow facade // Hollow facade
if (pluggable.isHollow()) { if (pluggable.isHollow()) {
renderblocks.field_152631_f = true;
float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade); float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade);
rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4; rotated[0][0] = CoreConstants.PIPE_MIN_POS - zFightOffset * 4;
rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4; rotated[0][1] = CoreConstants.PIPE_MAX_POS + zFightOffset * 4;
@ -179,6 +180,7 @@ public final class FacadeRenderHelper {
MatrixTranformations.transform(rotated, direction); MatrixTranformations.transform(rotated, direction);
setRenderBounds(renderblocks, rotated, direction); setRenderBounds(renderblocks, rotated, direction);
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z); renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
renderblocks.field_152631_f = false;
} else { // Solid facade } else { // Solid facade
float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade); float[][] rotated = MatrixTranformations.deepClone(zeroStateFacade);
MatrixTranformations.transform(rotated, direction); MatrixTranformations.transform(rotated, direction);