diff --git a/src/main/java/crazypants/render/ConnectedTextureRenderer.java b/src/main/java/crazypants/render/ConnectedTextureRenderer.java index 8cfc19e0..30eb1c88 100644 --- a/src/main/java/crazypants/render/ConnectedTextureRenderer.java +++ b/src/main/java/crazypants/render/ConnectedTextureRenderer.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; @@ -191,7 +192,7 @@ public class ConnectedTextureRenderer implements IRenderFace { } } - RenderUtil.addVerticesToTessellator(finalVerts, rb.getDefaultTesselator()); + RenderUtil.addVerticesToTessellator(finalVerts, Tessellator.instance); } private Vertex getClosestVertex(List vertices, Vector3d corner) { diff --git a/src/main/java/crazypants/render/CustomCubeRenderer.java b/src/main/java/crazypants/render/CustomCubeRenderer.java index d45ee402..fce70240 100644 --- a/src/main/java/crazypants/render/CustomCubeRenderer.java +++ b/src/main/java/crazypants/render/CustomCubeRenderer.java @@ -22,33 +22,27 @@ public class CustomCubeRenderer { if(rb == null) { rb = new CustomRenderBlocks(ba); } - try { - rb.blockAccess = ba; - rb.setOverrideTexture(getOverrideTexture()); - rb.setFaceRenderers(null); - if(renderer != null) { - rb.addFaceRenderer(renderer); - } - rb.setRenderBoundsFromBlock(par1Block); - rb.renderStandardBlock(par1Block, par2, par3, par4); - } finally { - rb.setDefaultTesselatorEnabled(true); + + rb.blockAccess = ba; + rb.setOverrideTexture(getOverrideTexture()); + rb.setFaceRenderers(null); + if(renderer != null) { + rb.addFaceRenderer(renderer); } + rb.setRenderBoundsFromBlock(par1Block); + rb.renderStandardBlock(par1Block, par2, par3, par4); + } public void renderBlock(IBlockAccess ba, Block par1Block, int par2, int par3, int par4, Collection renderers) { if(rb == null) { rb = new CustomRenderBlocks(ba); } - try { - rb.blockAccess = ba; - rb.setOverrideTexture(getOverrideTexture()); - rb.setFaceRenderers(renderers); - rb.setRenderBoundsFromBlock(par1Block); - rb.renderStandardBlock(par1Block, par2, par3, par4); - } finally { - rb.setDefaultTesselatorEnabled(true); - } + rb.blockAccess = ba; + rb.setOverrideTexture(getOverrideTexture()); + rb.setFaceRenderers(renderers); + rb.setRenderBoundsFromBlock(par1Block); + rb.renderStandardBlock(par1Block, par2, par3, par4); } diff --git a/src/main/java/crazypants/render/CustomRenderBlocks.java b/src/main/java/crazypants/render/CustomRenderBlocks.java index 4a95a9c6..fb8ea8c6 100644 --- a/src/main/java/crazypants/render/CustomRenderBlocks.java +++ b/src/main/java/crazypants/render/CustomRenderBlocks.java @@ -1,8 +1,8 @@ package crazypants.render; -import java.awt.Color; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import net.minecraft.block.Block; @@ -11,16 +11,10 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; -import crazypants.vecmath.Vector3f; -import crazypants.vecmath.Vector4f; import crazypants.vecmath.Vertex; public class CustomRenderBlocks extends RenderBlocks { - private static final Tessellator DEFAULT_TES = Tessellator.instance; - - private static final MockTesselator BUF_TES = new MockTesselator(); - boolean translateToXYZ = true; private final List renderFaceCallbacks = new ArrayList(); @@ -45,15 +39,6 @@ public class CustomRenderBlocks extends RenderBlocks { renderFaceCallbacks.remove(renderer); } - public void setDefaultTesselatorEnabled(boolean enabled) { - //TODO:1.7: Need to fix up not having a double buffer - // if(enabled) { - // Tessellator.instance = DEFAULT_TES; - // } else { - // Tessellator.instance = BUF_TES; - // } - } - public boolean isTranslateToXYZ() { return translateToXYZ; } @@ -70,30 +55,36 @@ public class CustomRenderBlocks extends RenderBlocks { this.overrideTexture = overrideTexture; } - private void resetTesForFace() { - BUF_TES.reset(); - } - private void renderFace(ForgeDirection face, Block par1Block, double x, double y, double z, IIcon texture) { if(renderFaceCallbacks.isEmpty()) { - setDefaultTesselatorEnabled(true); doDefaultRenderFace(face, par1Block, x, y, z, overrideTexture == null ? texture : overrideTexture); } else { - doDefaultRenderFaceToBuffer(face, par1Block, x, y, z, overrideTexture == null ? texture : overrideTexture); + List faceVertices = createVerticesForFace(face, par1Block, x, y, z, overrideTexture == null ? texture : overrideTexture); for (IRenderFace rf : renderFaceCallbacks) { - rf.renderFace(this, face, par1Block, x, y, z, overrideTexture == null ? texture : overrideTexture, getBufferVertices(), translateToXYZ); + rf.renderFace(this, face, par1Block, x, y, z, overrideTexture == null ? texture : overrideTexture, faceVertices, translateToXYZ); } } } - public void doDefaultRenderFaceToBuffer(ForgeDirection face, Block par1Block, double par2, double par4, double par6, IIcon par8Icon) { - try { - setDefaultTesselatorEnabled(false); - BUF_TES.reset(); - doDefaultRenderFace(face, par1Block, par2, par4, par6, par8Icon); - } finally { - setDefaultTesselatorEnabled(true); + public List createVerticesForFace(ForgeDirection face, Block par1Block, double x, double y, double z, IIcon icon) { + switch (face) { + case DOWN: + return calcFaceYNeg(par1Block, x, y, z, icon); + case EAST: + return calcFaceXPos(par1Block, x, y, z, icon); + case NORTH: + return calcFaceZNeg(par1Block, x, y, z, icon); + case SOUTH: + return calcFaceZPos(par1Block, x, y, z, icon); + case UP: + return calcFaceYPos(par1Block, x, y, z, icon); + case WEST: + return calcFaceXNeg(par1Block, x, y, z, icon); + case UNKNOWN: + default: + break; } + return Collections.emptyList(); } public void doDefaultRenderFace(ForgeDirection face, Block par1Block, double par2, double par4, double par6, IIcon par8Icon) { @@ -152,97 +143,558 @@ public class CustomRenderBlocks extends RenderBlocks { renderFace(ForgeDirection.EAST, par1Block, par2, par4, par6, par8Icon); } - private static class MockTesselator extends Tessellator { + private List calcFaceXNeg(Block par1Block, double par2, double par4, double par6, IIcon par8Icon) { - private final List vertices = new ArrayList(); - - private boolean hasTexture; - private double textureU; - private double textureV; - private boolean hasBrightness; - private int brightness; - private boolean hasColor; - private Vector4f color; - private boolean hasNormals; - private Vector3f normal; - - public List getVertices() { - return vertices; + if(hasOverrideBlockTexture()) { + par8Icon = this.overrideBlockTexture; } - @Override - public void setTextureUV(double par1, double par3) { - super.setTextureUV(par1, par3); - this.hasTexture = true; - this.textureU = par1; - this.textureV = par3; + double d3 = par8Icon.getInterpolatedU(this.renderMinZ * 16.0D); + double d4 = par8Icon.getInterpolatedU(this.renderMaxZ * 16.0D); + double d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if(this.flipTexture) { + d7 = d3; + d3 = d4; + d4 = d7; } - @Override - public void setBrightness(int par1) { - super.setBrightness(par1); - this.hasBrightness = true; - this.brightness = par1; + if(this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) { + d3 = par8Icon.getMinU(); + d4 = par8Icon.getMaxU(); } - /** - * Sets the RGBA values for the color. Also clamps them to 0-255. - */ - @Override - public void setColorRGBA(int r, int g, int b, int a) { - super.setColorRGBA(r, g, b, a); - hasColor = true; - color = ColorUtil.toFloat(new Color(r, g, b, a)); + if(this.renderMinY < 0.0D || this.renderMaxY > 1.0D) { + d5 = par8Icon.getMinV(); + d6 = par8Icon.getMaxV(); } - /** - * Sets the normal for the current draw call. - */ - @Override - public void setNormal(float par1, float par2, float par3) { - super.setNormal(par1, par2, par3); - hasNormals = true; - normal = new Vector3f(par1, par2, par3); + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if(this.uvRotateNorth == 1) { + d3 = par8Icon.getInterpolatedU(this.renderMinY * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d4 = par8Icon.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } else if(this.uvRotateNorth == 2) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMinZ * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMaxZ * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } else if(this.uvRotateNorth == 3) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; } - public void reset() { - hasNormals = false; - this.hasColor = false; - this.hasTexture = false; - this.hasBrightness = false; - vertices.clear(); - } + double d11 = par2 + this.renderMinX; + double d12 = par4 + this.renderMinY; + double d13 = par4 + this.renderMaxY; + double d14 = par6 + this.renderMinZ; + double d15 = par6 + this.renderMaxZ; - @Override - public void addVertex(double x, double y, double z) { - Vertex v = new Vertex(); - v.setXYZ(x, y, z); - if(hasTexture) { - v.setUV(textureU, textureV); - } - if(hasBrightness) { - v.setBrightness(brightness); - } - if(this.hasColor) { - v.setColor(this.color); - } - if(hasNormals) { - v.setNormal(normal); - } - vertices.add(v); + List result = new ArrayList(4); + Vertex v; + if(enableAO) { + result.add(new Vertex(d11, d13, d15, d7, d9, brightnessTopLeft, colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, 1)); + result.add(new Vertex(d11, d13, d14, d3, d5, brightnessBottomLeft, colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, 1)); + result.add(new Vertex(d11, d12, d14, d8, d10, brightnessBottomRight, colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, 1)); + result.add(new Vertex(d11, d12, d15, d4, d6, brightnessTopRight, colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, 1)); + } else { + result.add(new Vertex(d11, d13, d15, d7, d9)); + result.add(new Vertex(d11, d13, d14, d3, d5)); + result.add(new Vertex(d11, d12, d14, d8, d10)); + result.add(new Vertex(d11, d12, d15, d4, d6)); } - + return result; } - public List getBufferVertices() { - return BUF_TES.getVertices(); + private List calcFaceYPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon) { + + if(this.hasOverrideBlockTexture()) { + par8Icon = this.overrideBlockTexture; + } + + double d3 = par8Icon.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = par8Icon.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = par8Icon.getInterpolatedV(this.renderMinZ * 16.0D); + double d6 = par8Icon.getInterpolatedV(this.renderMaxZ * 16.0D); + + if(this.renderMinX < 0.0D || this.renderMaxX > 1.0D) { + d3 = par8Icon.getMinU(); + d4 = par8Icon.getMaxU(); + } + + if(this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) { + d5 = par8Icon.getMinV(); + d6 = par8Icon.getMaxV(); + } + + double d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if(this.uvRotateTop == 1) { + d3 = par8Icon.getInterpolatedU(this.renderMinZ * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d4 = par8Icon.getInterpolatedU(this.renderMaxZ * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } else if(this.uvRotateTop == 2) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } else if(this.uvRotateTop == 3) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = par2 + this.renderMinX; + double d12 = par2 + this.renderMaxX; + double d13 = par4 + this.renderMaxY; + double d14 = par6 + this.renderMinZ; + double d15 = par6 + this.renderMaxZ; + + List result = new ArrayList(4); + Vertex v; + if(enableAO) { + v = new Vertex(d12, d13, d15, d4, d6, brightnessTopLeft, colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, 1); + result.add(v); + v = new Vertex(d12, d13, d14, d7, d9, brightnessBottomLeft, colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, 1); + result.add(v); + v = new Vertex(d11, d13, d14, d3, d5, brightnessBottomRight, colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, 1); + result.add(v); + v = new Vertex(d11, d13, d15, d8, d10, brightnessTopRight, colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, 1); + result.add(v); + } else { + v = new Vertex(d12, d13, d15, d4, d6); + result.add(v); + v = new Vertex(d12, d13, d14, d7, d9); + result.add(v); + v = new Vertex(d11, d13, d14, d3, d5); + result.add(v); + v = new Vertex(d11, d13, d15, d8, d10); + result.add(v); + } + return result; } - public Tessellator getBufferTesselator() { - return BUF_TES; + private List calcFaceZPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon) + { + Tessellator tessellator = Tessellator.instance; + + if(this.hasOverrideBlockTexture()) + { + par8Icon = this.overrideBlockTexture; + } + + double d3 = par8Icon.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = par8Icon.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if(this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if(this.renderMinX < 0.0D || this.renderMaxX > 1.0D) + { + d3 = par8Icon.getMinU(); + d4 = par8Icon.getMaxU(); + } + + if(this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = par8Icon.getMinV(); + d6 = par8Icon.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if(this.uvRotateWest == 1) + { + d3 = par8Icon.getInterpolatedU(this.renderMinY * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(this.renderMaxY * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if(this.uvRotateWest == 2) + { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if(this.uvRotateWest == 3) + { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = par2 + this.renderMinX; + double d12 = par2 + this.renderMaxX; + double d13 = par4 + this.renderMinY; + double d14 = par4 + this.renderMaxY; + double d15 = par6 + this.renderMaxZ; + + List result = new ArrayList(); + Vertex v; + if(enableAO) { + result.add(new Vertex(d11, d14, d15, d3, d5, brightnessTopLeft, colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, 1)); + result.add(new Vertex(d11, d13, d15, d8, d10, brightnessBottomLeft, this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, 1)); + result.add(new Vertex(d12, d13, d15, d4, d6, brightnessBottomRight, colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, 1)); + result.add(new Vertex(d12, d14, d15, d7, d9, brightnessTopRight, colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, 1)); + } else { + result.add(new Vertex(d11, d14, d15, d3, d5)); + result.add(new Vertex(d11, d13, d15, d8, d10)); + result.add(new Vertex(d12, d13, d15, d4, d6)); + result.add(new Vertex(d12, d14, d15, d7, d9)); + } + return result; } - public Tessellator getDefaultTesselator() { - return DEFAULT_TES; + private List calcFaceZNeg(Block par1Block, double par2, double par4, double par6, IIcon par8Icon) { + + if(this.hasOverrideBlockTexture()) + { + par8Icon = this.overrideBlockTexture; + } + + double d3 = par8Icon.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = par8Icon.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if(this.flipTexture) { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if(this.renderMinX < 0.0D || this.renderMaxX > 1.0D) { + d3 = par8Icon.getMinU(); + d4 = par8Icon.getMaxU(); + } + + if(this.renderMinY < 0.0D || this.renderMaxY > 1.0D) { + d5 = par8Icon.getMinV(); + d6 = par8Icon.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if(this.uvRotateEast == 2) { + d3 = par8Icon.getInterpolatedU(this.renderMinY * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } else if(this.uvRotateEast == 1) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } else if(this.uvRotateEast == 3) { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = par2 + this.renderMinX; + double d12 = par2 + this.renderMaxX; + double d13 = par4 + this.renderMinY; + double d14 = par4 + this.renderMaxY; + double d15 = par6 + this.renderMinZ; + + List result = new ArrayList(); + Vertex v; + if(enableAO) { + result.add(new Vertex(d11, d14, d15, d7, d9, brightnessTopLeft, colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, 1)); + result.add(new Vertex(d12, d14, d15, d3, d5, brightnessBottomLeft, colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, 1)); + result.add(new Vertex(d12, d13, d15, d8, d10, brightnessBottomRight, colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, 1)); + result.add(new Vertex(d11, d13, d15, d4, d6, brightnessTopRight, colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, 1)); + } else { + result.add(new Vertex(d11, d14, d15, d7, d9)); + result.add(new Vertex(d12, d14, d15, d3, d5)); + result.add(new Vertex(d12, d13, d15, d8, d10)); + result.add(new Vertex(d11, d13, d15, d4, d6)); + } + return result; } + + private List calcFaceXPos(Block par1Block, double par2, double par4, double par6, IIcon par8Icon) + { + Tessellator tessellator = Tessellator.instance; + + if(this.hasOverrideBlockTexture()) + { + par8Icon = this.overrideBlockTexture; + } + + double d3 = par8Icon.getInterpolatedU(this.renderMinZ * 16.0D); + double d4 = par8Icon.getInterpolatedU(this.renderMaxZ * 16.0D); + double d5 = par8Icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = par8Icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if(this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if(this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + d3 = par8Icon.getMinU(); + d4 = par8Icon.getMaxU(); + } + + if(this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = par8Icon.getMinV(); + d6 = par8Icon.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if(this.uvRotateSouth == 2) + { + d3 = par8Icon.getInterpolatedU(this.renderMinY * 16.0D); + d5 = par8Icon.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d4 = par8Icon.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if(this.uvRotateSouth == 1) + { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxZ * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinZ * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if(this.uvRotateSouth == 3) + { + d3 = par8Icon.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d4 = par8Icon.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = par8Icon.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = par8Icon.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = par2 + this.renderMaxX; + double d12 = par4 + this.renderMinY; + double d13 = par4 + this.renderMaxY; + double d14 = par6 + this.renderMinZ; + double d15 = par6 + this.renderMaxZ; + + List result = new ArrayList(4); + Vertex v; + if(enableAO) { + result.add(new Vertex(d11, d12, d15, d8, d10, brightnessTopLeft, colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft, 1)); + result.add(new Vertex(d11, d12, d14, d4, d6, brightnessBottomLeft, colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft, 1)); + result.add(new Vertex(d11, d13, d14, d7, d9, brightnessBottomRight, colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight, 1)); + result.add(new Vertex(d11, d13, d15, d3, d5, brightnessTopRight, colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight, 1)); + } else { + result.add(new Vertex(d11, d12, d15, d8, d10)); + result.add(new Vertex(d11, d12, d14, d4, d6)); + result.add(new Vertex(d11, d13, d14, d7, d9)); + result.add(new Vertex(d11, d13, d15, d3, d5)); + } + return result; + } + + private List calcFaceYNeg(Block par1Block, double x, double y, double z, IIcon icon) { + + if(hasOverrideBlockTexture()) { + icon = this.overrideBlockTexture; + } + + double minU = icon.getInterpolatedU(this.renderMinX * 16.0D); + double maxU = icon.getInterpolatedU(this.renderMaxX * 16.0D); + double minV = icon.getInterpolatedV(this.renderMinZ * 16.0D); + double maxV = icon.getInterpolatedV(this.renderMaxZ * 16.0D); + + if(renderMinX < 0.0D || renderMaxX > 1.0D) { + minU = icon.getMinU(); + maxU = icon.getMaxU(); + } + + if(this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) { + minV = icon.getMinV(); + maxV = icon.getMaxV(); + } + + double d7 = maxU; + double d8 = minU; + double d9 = minV; + double d10 = maxV; + + if(uvRotateBottom == 2) { + minU = icon.getInterpolatedU(this.renderMinZ * 16.0D); + minV = icon.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + maxU = icon.getInterpolatedU(this.renderMaxZ * 16.0D); + maxV = icon.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d9 = minV; + d10 = maxV; + d7 = minU; + d8 = maxU; + minV = maxV; + maxV = d9; + } else if(uvRotateBottom == 1) { + + minU = icon.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + minV = icon.getInterpolatedV(this.renderMinX * 16.0D); + maxU = icon.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + maxV = icon.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = maxU; + d8 = minU; + minU = maxU; + maxU = d8; + d9 = maxV; + d10 = minV; + } else if(uvRotateBottom == 3) { + minU = icon.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + maxU = icon.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + minV = icon.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + maxV = icon.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d7 = maxU; + d8 = minU; + d9 = minV; + d10 = maxV; + } + + double minX = x + this.renderMinX; + double maxX = x + this.renderMaxX; + double minY = y + this.renderMinY; + double minZ = z + this.renderMinZ; + double maxZ = z + this.renderMaxZ; + + List result = new ArrayList(4); + Vertex v; + if(this.enableAO) { + v = new Vertex(minX, minY, maxZ, d8, d10, brightnessTopLeft, colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, 1f); + result.add(v); + v = new Vertex(minX, minY, minZ, minU, minV, brightnessBottomLeft, colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, 1f); + result.add(v); + v = new Vertex(maxX, minY, minZ, d7, d9, brightnessBottomRight, colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, 1f); + result.add(v); + v = new Vertex(maxX, minY, maxZ, maxU, maxV, brightnessTopRight, colorRedTopRight, colorGreenTopRight, colorBlueTopRight, 1f); + result.add(v); + } else { + v = new Vertex(minX, minY, maxZ, d8, d10); + result.add(v); + v = new Vertex(minX, minY, minZ, minU, minV); + result.add(v); + v = new Vertex(maxX, minY, minZ, d7, d9); + result.add(v); + v = new Vertex(maxX, minY, maxZ, maxU, maxV); + result.add(v); + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/crazypants/vecmath/Vertex.java b/src/main/java/crazypants/vecmath/Vertex.java index 175e352a..cb39708d 100644 --- a/src/main/java/crazypants/vecmath/Vertex.java +++ b/src/main/java/crazypants/vecmath/Vertex.java @@ -32,6 +32,18 @@ public class Vertex { this.uv = new Vector2f(uv); } + public Vertex(double x, double y, double z, double u, double v, int brightness, float r, float g, float b, float a) { + xyz.set(x, y, z); + uv = new Vector2f(u, v); + this.brightness = brightness; + color = new Vector4f(r, g, b, a); + } + + public Vertex(double x, double y, double z, double u, double v) { + xyz.set(x, y, z); + uv = new Vector2f(u, v); + } + public void setXYZ(double x, double y, double z) { xyz.set(x, y, z); }