From f173222edccaf63cd53426668fb8eb7d25f298bb Mon Sep 17 00:00:00 2001 From: CptSpaceToaster Date: Wed, 4 Mar 2015 00:27:19 -0500 Subject: [PATCH] This should be all of the changes I made AFTER I ran the bogus merge, clearying out tterag's work --- .../chisel/client/render/CTM.java | 298 ++++++++---------- .../chisel/client/render/RenderBlocksCTM.java | 270 +++++++++------- .../chisel/config/Configurations.java | 50 +-- 3 files changed, 316 insertions(+), 302 deletions(-) diff --git a/src/main/java/com/cricketcraft/chisel/client/render/CTM.java b/src/main/java/com/cricketcraft/chisel/client/render/CTM.java index dfc3ac30..e0f3f763 100644 --- a/src/main/java/com/cricketcraft/chisel/client/render/CTM.java +++ b/src/main/java/com/cricketcraft/chisel/client/render/CTM.java @@ -1,201 +1,165 @@ package com.cricketcraft.chisel.client.render; +import com.cricketcraft.chisel.config.Configurations; import net.minecraft.block.Block; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; import com.cricketcraft.chisel.api.IFacade; + /** * The CTM renderer will draw the block's FACE using by assembling 4 quadrants from the 5 available block * textures. The normal Texture.png is the blocks "unconnected" texture, and is used when CTM is disabled or the block * has nothing to connect to. This texture has all of the outside corner quadrants The texture-ctm.png contains the * rest of the quadrants. * - * ┌─────────────────┐ ┌────────────────────────────────┐ - * │ texture.png │ │ texture-ctm.png │ - * │ ╔══════╤══════╗ │ │ ──────┼────── ║ ─────┼───── ║ │ - * │ ║ │ ║ │ │ │ │ │║ │ ║ │ - * │ ║ 16 │ 17 ║ │ │ │ 0 │ 1 │║ 2 │ 3 ║ │ - * │ ╟──────┼──────╢ │ │ ┼──────┼──────┼╟──────┼──────╢ │ - * │ ║ │ ║ │ │ │ │ │║ │ ║ │ - * │ ║ 18 │ 19 ║ │ │ │ 4 │ 5 │║ 6 │ 7 ║ │ - * │ ╚══════╧══════╝ │ │ ──────┼────── ║ ─────┼───── ║ │ - * └─────────────────┘ │ ═══════╤═══════╝ ─────┼───── ╚ │ - * │ │ │ ││ │ │ │ - * │ │ 8 │ 9 ││ 10 │ 11 │ │ - * │ ┼──────┼──────┼┼──────┼──────┼ │ - * │ │ │ ││ │ │ │ - * │ │ 12 │ 13 ││ 14 │ 15 │ │ - * │ ═══════╧═══════╗ ─────┼───── ╔ │ - * └────────────────────────────────┘ + * ┌─────────────────┐ ┌────────────────────────────────┐ + * │ texture.png │ │ texture-ctm.png │ + * │ ╔══════╤══════╗ │ │ ──────┼────── ║ ─────┼───── ║ │ + * │ ║ │ ║ │ │ │ │ │║ │ ║ │ + * │ ║ 16 │ 17 ║ │ │ │ 0 │ 1 │║ 2 │ 3 ║ │ + * │ ╟──────┼──────╢ │ │ ┼──────┼──────┼╟──────┼──────╢ │ + * │ ║ │ ║ │ │ │ │ │║ │ ║ │ + * │ ║ 18 │ 19 ║ │ │ │ 4 │ 5 │║ 6 │ 7 ║ │ + * │ ╚══════╧══════╝ │ │ ──────┼────── ║ ─────┼───── ║ │ + * └─────────────────┘ │ ═══════╤═══════╝ ─────┼───── ╚ │ + * │ │ │ ││ │ │ │ + * │ │ 8 │ 9 ││ 10 │ 11 │ │ + * │ ┼──────┼──────┼┼──────┼──────┼ │ + * │ │ │ ││ │ │ │ + * │ │ 12 │ 13 ││ 14 │ 15 │ │ + * │ ═══════╧═══════╗ ─────┼───── ╔ │ + * └────────────────────────────────┘ * * combining { 18, 13, 9, 16 }, we can generate a texture connected to the right! * - * ╔══════╤═══════ - * ║ │ │ - * ║ 16 │ 9 │ - * ╟──────┼──────┼ - * ║ │ │ - * ║ 18 │ 13 │ - * ╚══════╧═══════ + * ╔══════╤═══════ + * ║ │ │ + * ║ 16 │ 9 │ + * ╟──────┼──────┼ + * ║ │ │ + * ║ 18 │ 13 │ + * ╚══════╧═══════ * * * combining { 18, 13, 11, 2 }, we can generate a texture, in the shape of an L (connected to the right, and up * - * ║ ─────┼───── ╚ - * ║ │ │ - * ║ 2 │ 11 │ - * ╟──────┼──────┼ - * ║ │ │ - * ║ 18 │ 13 │ - * ╚══════╧═══════ + * ║ ─────┼───── ╚ + * ║ │ │ + * ║ 2 │ 11 │ + * ╟──────┼──────┼ + * ║ │ │ + * ║ 18 │ 13 │ + * ╚══════╧═══════ * * * HAVE FUN! * -CptRageToaster- - * - * TODO: Everything */ - public class CTM { - - /** - * The quads are ordered the same here, and in the renderer: - * 1. Lower left - * 2. Lower Right - * 3. Top Right - * 4. Top Left - */ - static int submaps[][] = { - { 18, 19, 17, 16 }, // 0 - No connection, with border - - { 18, 19, 3, 2 }, // 1 - Connected from above - { 18, 13, 9, 16 }, // 2 - Connected to the right - { 6, 7, 17, 16 }, // 3 - Connected from below - { 12, 19, 17, 8 }, // 4 - Connected to the left - - { 6, 7, 3, 2 }, // 5 - ║ - { 12, 13, 9, 8 }, // 6 - ═ - { 18, 13, 11, 2 }, // 7 - ╚ with inside corner - { 6, 15, 3, 16 }, // 8 - ╔ with inside corner - { 14, 7, 17, 8 }, // 9 - ╗ with inside corner - { 12, 19, 3, 10 }, // 10 - ╝ with inside corner - - { 18, 13, 1, 2 }, // 11 - ╚ no inside corner - { 6, 5, 3, 16 }, // 12 - ╔ no inside corner - { 4, 7, 17, 8 }, // 13 - ╗ no inside corner - { 12, 19, 3, 0 }, // 14 - ╝ no inside corner - - { 6, 15, 11, 2 }, // 15 - ╠ with inside corners - { 14, 15, 9, 8 }, // 16 - ╦ with inside corners - { 14, 7, 3, 10 }, // 17 - ╣ with inside corners - { 12, 13, 11, 10 }, // 18 - ╩ with inside corners - - { 6, 5, 11, 2 }, // 23 - ╠ with top right inside corner - { 4, 15, 9, 8 }, // 24 - ╦ with bottom right inside corner - { 14, 7, 3, 0 }, // 25 - ╣ with bottom left inside corner - { 12, 13, 1, 10 }, // 26 - ╩ with top left inside corner - - { 6, 15, 1, 2 }, // 19 - ╠ with bottom right inside corner - { 14, 5, 9, 8 }, // 20 - ╦ with bottom left inside corner - { 4, 7, 3, 10 }, // 21 - ╣ with top left inside corner - { 12, 13, 11, 0 }, // 22 - ╩ with top right inside corner - - { 6, 5, 1, 2 }, // 27 - ╠ no inside corners - { 4, 5, 9, 8 }, // 28 - ╦ no inside corners - { 4, 7, 3, 0 }, // 29 - ╣ no inside corners - { 12, 13, 1, 0 }, // 30 - ╩ no inside corners - - { 14, 15, 11, 10 }, // 31 - ╬, with all inside corners - - { 14, 5, 11, 10 }, // 32 - ╬, with all but bottom right inside corner - { 4, 15, 11, 10 }, // 33 - ╬, with all but bottom left inside corner - { 14, 15, 11, 0 }, // 34 - ╬, with all but top left inside corner - { 14, 15, 1, 10 }, // 35 - ╬, with all but top right inside corner - - { 4, 5, 11, 10 }, // 36 - ╬, with top inside corners - { 4, 15, 11, 0 }, // 37 - ╬, with right inside corners - { 14, 15, 1, 0 }, // 38 - ╬, with right inside corners - { 14, 5, 1, 10 }, // 39 - ╬, with left inside corners - { 4, 15, 1, 10 }, // 40 - ╬, with top left and bottom right inside corners - { 14, 5, 11, 0 }, // 41 - ╬, with top right and bottom left inside corners - - { 4, 5, 1, 10 }, // 42 - ╬, with top left inside corner - { 4, 5, 11, 0 }, // 43 - ╬, with top right inside corner - { 4, 15, 1, 0 }, // 44 - ╬, with bottom right inside corner - { 14, 5, 1, 0 }, // 45 - ╬, with bottom left inside corner - - { 4, 5, 1, 0 }, // 46 - ╬, no inside corners - }; - public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side) { - int index = getTexture(world, x, y, z, side); - - return submaps[index]; - } - - public static int getTexture(IBlockAccess world, int x, int y, int z, int side) { if (world == null) - return 0; + return new int[] { 18, 19, 17, 16 }; - int texture = 0; Block block = world.getBlock(x, y, z); int blockMetadata = world.getBlockMetadata(x, y, z); boolean b[] = new boolean[8]; - /** - * b[0] b[1] b[2] - * - * - * - * b[3] FACE b[4] - * - * - * - * b[5] b[6] b[7] - */ - if (side == 0) { - //TODO: - b[0] = isConnected(world, x - 1, y, z, side, block, blockMetadata); - b[1] = isConnected(world, x + 1, y, z, side, block, blockMetadata); - b[2] = isConnected(world, x, y, z + 1, side, block, blockMetadata); - b[3] = isConnected(world, x, y, z - 1, side, block, blockMetadata); - } else if (side == 1) { - //TODO: - b[0] = isConnected(world, x - 1, y, z, side, block, blockMetadata); - b[1] = isConnected(world, x + 1, y, z, side, block, blockMetadata); - b[2] = isConnected(world, x, y, z - 1, side, block, blockMetadata); - b[3] = isConnected(world, x, y, z + 1, side, block, blockMetadata); - } else if (side == 2) { - //TODO: - b[0] = isConnected(world, x + 1, y, z, side, block, blockMetadata); - b[1] = isConnected(world, x - 1, y, z, side, block, blockMetadata); - b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata); - b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata); - } else if (side == 3) { - //TODO: - b[0] = isConnected(world, x - 1, y, z, side, block, blockMetadata); - b[1] = isConnected(world, x + 1, y, z, side, block, blockMetadata); - b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata); - b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata); - } else if (side == 4) { - //TODO: - b[0] = isConnected(world, x, y, z - 1, side, block, blockMetadata); + /** + * b[0] b[1] b[2] + * + * + * + * b[3] FACE b[4] + * + * + * + * b[5] b[6] b[7] + */ + if (side == 0) { + b[0] = isConnected(world, x - 1, y, z + 1, side, block, blockMetadata); b[1] = isConnected(world, x, y, z + 1, side, block, blockMetadata); - b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata); - b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata); - } else if (side == 5) { - //TODO: - b[0] = isConnected(world, x, y, z + 1, side, block, blockMetadata); + b[2] = isConnected(world, x + 1, y, z + 1, side, block, blockMetadata); + b[3] = isConnected(world, x - 1, y, z, side, block, blockMetadata); + b[4] = isConnected(world, x + 1, y, z, side, block, blockMetadata); + b[5] = isConnected(world, x - 1, y, z - 1, side, block, blockMetadata); + b[6] = isConnected(world, x, y, z - 1, side, block, blockMetadata); + b[7] = isConnected(world, x + 1, y, z - 1, side, block, blockMetadata); + } else if (side == 1) { + b[0] = isConnected(world, x - 1, y, z - 1, side, block, blockMetadata); b[1] = isConnected(world, x, y, z - 1, side, block, blockMetadata); - b[2] = isConnected(world, x, y - 1, z, side, block, blockMetadata); - b[3] = isConnected(world, x, y + 1, z, side, block, blockMetadata); + b[2] = isConnected(world, x + 1, y, z - 1, side, block, blockMetadata); + b[3] = isConnected(world, x - 1, y, z, side, block, blockMetadata); + b[4] = isConnected(world, x + 1, y, z, side, block, blockMetadata); + b[5] = isConnected(world, x - 1, y, z + 1, side, block, blockMetadata); + b[6] = isConnected(world, x, y, z + 1, side, block, blockMetadata); + b[7] = isConnected(world, x + 1, y, z + 1, side, block, blockMetadata); + } else if (side == 2) { + b[0] = isConnected(world, x + 1, y + 1, z, side, block, blockMetadata); + b[1] = isConnected(world, x, y + 1, z, side, block, blockMetadata); + b[2] = isConnected(world, x - 1, y + 1, z, side, block, blockMetadata); + b[3] = isConnected(world, x + 1, y, z, side, block, blockMetadata); + b[4] = isConnected(world, x - 1, y, z, side, block, blockMetadata); + b[5] = isConnected(world, x + 1, y - 1, z, side, block, blockMetadata); + b[6] = isConnected(world, x, y - 1, z, side, block, blockMetadata); + b[7] = isConnected(world, x - 1, y - 1, z, side, block, blockMetadata); + } else if (side == 3) { + b[0] = isConnected(world, x - 1, y + 1, z, side, block, blockMetadata); + b[1] = isConnected(world, x, y + 1, z, side, block, blockMetadata); + b[2] = isConnected(world, x + 1, y + 1, z, side, block, blockMetadata); + b[3] = isConnected(world, x - 1, y, z, side, block, blockMetadata); + b[4] = isConnected(world, x + 1, y, z, side, block, blockMetadata); + b[5] = isConnected(world, x - 1, y - 1, z, side, block, blockMetadata); + b[6] = isConnected(world, x, y - 1, z, side, block, blockMetadata); + b[7] = isConnected(world, x + 1, y - 1, z, side, block, blockMetadata); + } else if (side == 4) { + b[0] = isConnected(world, x, y + 1, z - 1, side, block, blockMetadata); + b[1] = isConnected(world, x, y + 1, z, side, block, blockMetadata); + b[2] = isConnected(world, x, y + 1, z + 1, side, block, blockMetadata); + b[3] = isConnected(world, x, y, z - 1, side, block, blockMetadata); + b[4] = isConnected(world, x, y, z + 1, side, block, blockMetadata); + b[5] = isConnected(world, x, y - 1, z - 1, side, block, blockMetadata); + b[6] = isConnected(world, x, y - 1, z, side, block, blockMetadata); + b[7] = isConnected(world, x, y - 1, z + 1, side, block, blockMetadata); + } else if (side == 5) { + b[0] = isConnected(world, x, y + 1, z + 1, side, block, blockMetadata); + b[1] = isConnected(world, x, y + 1, z, side, block, blockMetadata); + b[2] = isConnected(world, x, y + 1, z - 1, side, block, blockMetadata); + b[3] = isConnected(world, x, y, z + 1, side, block, blockMetadata); + b[4] = isConnected(world, x, y, z - 1, side, block, blockMetadata); + b[5] = isConnected(world, x, y - 1, z + 1, side, block, blockMetadata); + b[6] = isConnected(world, x, y - 1, z, side, block, blockMetadata); + b[7] = isConnected(world, x, y - 1, z - 1, side, block, blockMetadata); } - //TODO: return something other than zero + int[] ret = new int[] { 18, 19, 17, 16 }; - return texture; + // Bottom Left + if (b[3] || b[6]) { + ret[0] = 4 + (b[6] ? 2 : 0) + (b[3] ? 8 : 0); + if (b[3] && b[5] && b[6]) ret[0] = 4; + } + + // Bottom Right + if (b[6] || b[4]) { + ret[1] = 5 + (b[6] ? 2 : 0) + (b[4] ? 8 : 0); + if (b[4] && b[6] && b[7]) ret[1] = 5; + } + + // Top Right + if (b[4] || b[1]) { + ret[2] = 1 + (b[1] ? 2 : 0) + (b[4] ? 8 : 0); + if (b[1] && b[2] && b[4]) ret[2] = 1; + } + + // Top Left + if (b[1] || b[3]) { + ret[3] = (b[1] ? 2 : 0) + (b[3] ? 8 : 0); + if (b[0] && b[1] && b[3]) ret[3] = 0; + } + + return ret; } public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) { @@ -205,25 +169,25 @@ public class CTM { int x2 = x + dir.offsetX; int y2 = y + dir.offsetY; int z2 = z + dir.offsetZ; - + Block con = getBlockOrFacade(world, x, y, z, side); Block obscuring = getBlockOrFacade(world, x2, y2, z2, side); - + // no block or a bad API user if (con == null) { return false; } - + boolean ret = con.equals(block) && getBlockOrFacadeMetadata(world, x, y, z, side) == meta; - + // no block obscuring this face if (obscuring == null) { return true; } - + // check that we aren't already connected outwards from this side - ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, side) == meta); - + ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, side) == meta && Configurations.connectInsideCTM); + return ret; } @@ -242,4 +206,4 @@ public class CTM { } return blk; } -} +} \ No newline at end of file diff --git a/src/main/java/com/cricketcraft/chisel/client/render/RenderBlocksCTM.java b/src/main/java/com/cricketcraft/chisel/client/render/RenderBlocksCTM.java index 7c1d223e..28361403 100644 --- a/src/main/java/com/cricketcraft/chisel/client/render/RenderBlocksCTM.java +++ b/src/main/java/com/cricketcraft/chisel/client/render/RenderBlocksCTM.java @@ -20,7 +20,6 @@ public class RenderBlocksCTM extends RenderBlocks { * X, Y, Z, or any combination means that the axes listed in the name are at 1. * X, Y, Z, or any combination followed by HALF means that those axes are at 0.5. * X, Y, Z, or any combination after a HALF means those axes are at 1. - * */ enum Vert { @@ -61,8 +60,7 @@ public class RenderBlocksCTM extends RenderBlocks { void render(RenderBlocksCTM inst, int cacheID) { if (inst.enableAO) { - // TODO: Get this back in - // inst.tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.greenCache[cacheID], inst.blueCache[cacheID]); + inst.tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]); inst.tessellator.setBrightness(inst.lightingCache[cacheID]); } @@ -72,18 +70,18 @@ public class RenderBlocksCTM extends RenderBlocks { /** * Each side is divided into 4 sub-sides. LB(left bottom), RB(right bottom), LT(right top), and RT(right top). - *

+ * * Each sub-side contains 4 {@link Vert} objects representing its position on the block. */ enum SubSide { - XNEG_LB(ZERO, Z_HALF, YZ_HALF, Y_HALF), XNEG_RB(Z_HALF, Z, Y_HALF_Z, YZ_HALF), XNEG_RT(YZ_HALF, Y_HALF_Z, YZ, Z_HALF_Y), XNEG_LT(Y_HALF, YZ_HALF, Z_HALF_Y, Y), - XPOS_LB(XZ, Z_HALF_X, YZ_HALF_X, Y_HALF_XZ), XPOS_RB(Z_HALF_X, X, Y_HALF_X, YZ_HALF_X), XPOS_RT(YZ_HALF_X, Y_HALF_X, XY, Z_HALF_XY), XPOS_LT(Y_HALF_XZ, YZ_HALF_X, Z_HALF_XY, XYZ), + XNEG_LB(ZERO, Z_HALF, YZ_HALF, Y_HALF), XNEG_RB(Z_HALF, Z, Y_HALF_Z, YZ_HALF), XNEG_RT(YZ_HALF, Y_HALF_Z, YZ, Z_HALF_Y), XNEG_LT(Y_HALF, YZ_HALF, Z_HALF_Y, Y), + XPOS_LB(XZ, Z_HALF_X, YZ_HALF_X, Y_HALF_XZ), XPOS_RB(Z_HALF_X, X, Y_HALF_X, YZ_HALF_X), XPOS_RT(YZ_HALF_X, Y_HALF_X, XY, Z_HALF_XY), XPOS_LT(Y_HALF_XZ, YZ_HALF_X, Z_HALF_XY, XYZ), - ZNEG_LB(X, X_HALF, XY_HALF, Y_HALF_X), ZNEG_RB(X_HALF, ZERO, Y_HALF, XY_HALF), ZNEG_RT(XY_HALF, Y_HALF, Y, X_HALF_Y), ZNEG_LT(Y_HALF_X, XY_HALF, X_HALF_Y, XY), - ZPOS_LB(Z, X_HALF_Z, XY_HALF_Z, Y_HALF_Z), ZPOS_RB(X_HALF_Z, XZ, Y_HALF_XZ, XY_HALF_Z), ZPOS_RT(XY_HALF_Z, Y_HALF_XZ, XYZ, X_HALF_YZ), ZPOS_LT(Y_HALF_Z, XY_HALF_Z, X_HALF_YZ, YZ), + ZNEG_LB(X, X_HALF, XY_HALF, Y_HALF_X), ZNEG_RB(X_HALF, ZERO, Y_HALF, XY_HALF), ZNEG_RT(XY_HALF, Y_HALF, Y, X_HALF_Y), ZNEG_LT(Y_HALF_X, XY_HALF, X_HALF_Y, XY), + ZPOS_LB(Z, X_HALF_Z, XY_HALF_Z, Y_HALF_Z), ZPOS_RB(X_HALF_Z, XZ, Y_HALF_XZ, XY_HALF_Z), ZPOS_RT(XY_HALF_Z, Y_HALF_XZ, XYZ, X_HALF_YZ), ZPOS_LT(Y_HALF_Z, XY_HALF_Z, X_HALF_YZ, YZ), - YNEG_LB(ZERO, X_HALF, XZ_HALF, Z_HALF), YNEG_RB(X_HALF, X, Z_HALF_X, XZ_HALF), YNEG_RT(XZ_HALF, Z_HALF_X, XZ, X_HALF_Z), YNEG_LT(Z_HALF, XZ_HALF, X_HALF_Z, Z), - YPOS_LB(YZ, X_HALF_YZ, XZ_HALF_Y, Z_HALF_Y), YPOS_RB(X_HALF_YZ, XYZ, Z_HALF_XY, XZ_HALF_Y), YPOS_RT(XZ_HALF_Y, Z_HALF_XY, XY, X_HALF_Y), YPOS_LT(Z_HALF_Y, XZ_HALF_Y, X_HALF_Y, Y); + YNEG_LB(ZERO, X_HALF, XZ_HALF, Z_HALF), YNEG_RB(X_HALF, X, Z_HALF_X, XZ_HALF), YNEG_RT(XZ_HALF, Z_HALF_X, XZ, X_HALF_Z), YNEG_LT(Z_HALF, XZ_HALF, X_HALF_Z, Z), + YPOS_LB(YZ, X_HALF_YZ, XZ_HALF_Y, Z_HALF_Y), YPOS_RB(X_HALF_YZ, XYZ, Z_HALF_XY, XZ_HALF_Y), YPOS_RT(XZ_HALF_Y, Z_HALF_XY, XY, X_HALF_Y), YPOS_LT(Z_HALF_Y, XZ_HALF_Y, X_HALF_Y, Y); private Vert xmin, xmax, ymin, ymax; SubSide(Vert xmin, Vert ymin, Vert ymax, Vert xmax) { @@ -118,18 +116,20 @@ public class RenderBlocksCTM extends RenderBlocks { double[] vCache = new double[4]; int[] lightingCache = new int[4]; float[] redCache = new float[4]; - float[] greenCache = new float[4]; - float[] blueCache = new float[4]; + float[] grnCache = new float[4]; + float[] bluCache = new float[4]; TextureSubmap submap; TextureSubmap submapSmall; RenderBlocks rendererOld; - int[][] lightmap = new int[3][3]; + int[][] lightmap = new int[3][3]; + float[][] redmap = new float[3][3]; + float[][] grnmap = new float[3][3]; + float[][] blumap = new float[3][3]; int bx, by, bz; - @Override - public boolean renderStandardBlock(Block block, int x, int y, int z) { + @Override public boolean renderStandardBlock(Block block, int x, int y, int z) { bx = x; by = y; bz = z; @@ -146,42 +146,70 @@ public class RenderBlocksCTM extends RenderBlocks { return res; } + /* This method fills a 3x3 grid of light values based on the four corners, by averaging them together. + * + * 2 TL x TR + * + * 1 x x x + * + * 0 BL x BR + * 0 1 2 + * + * Note: Variable names mean nothing... don't touch + * + * ._. + * + * shakes fist in anger + */ + void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) { + lightmap[0][0] = bottomLeft; + lightmap[2][0] = bottomRight; + lightmap[2][2] = topRight; + lightmap[0][2] = topLeft; - /* This method fills a 3x3 grid of light values based on the four corners, by averaging them together. - * - * 2 TL x TR - * - * 1 x x x - * - * 0 BL x BR - * 0 1 2 - * - * Note: Variable names mean nothing... don't touch - * - * ._. - * - * shakes fist in anger - */ - void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) { - lightmap[0][0] = bottomLeft; - lightmap[2][0] = bottomRight; - lightmap[2][2] = topRight; - lightmap[0][2] = topLeft; + lightmap[1][0] = avg(bottomLeft, bottomRight); + lightmap[2][1] = avg(bottomRight, topRight); + lightmap[1][2] = avg(topRight, topLeft); + lightmap[0][1] = avg(topLeft, bottomLeft); - lightmap[1][0] = avg(bottomLeft, bottomRight); - lightmap[2][1] = avg(bottomRight, topRight); - lightmap[1][2] = avg(topRight, topLeft); - lightmap[0][1] = avg(topLeft, bottomLeft); + lightmap[1][1] = avg(bottomLeft, bottomRight, topRight, topLeft); + } - lightmap[1][1] = avg(bottomLeft, bottomRight, topRight, topLeft); - } + void fillColormap(float bottomLeft, float bottomRight, float topRight, float topLeft, float[][] map) { + map[0][0] = bottomLeft; + map[2][0] = bottomRight; + map[2][2] = topRight; + map[0][2] = topLeft; - void getLight(int x, int y) { - lightingCache[0] = lightmap[0+x][0+y]; - lightingCache[1] = lightmap[1+x][0+y]; - lightingCache[2] = lightmap[1+x][1+y]; - lightingCache[3] = lightmap[0+x][1+y]; - } + map[1][0] = (bottomLeft + bottomRight) / 2.0F; + map[2][1] = (bottomRight + topRight) / 2.0F; + map[1][2] = (topRight + topLeft) / 2.0F; + map[0][1] = (topLeft + bottomLeft) / 2.0F; + + map[1][1] = (bottomLeft + bottomRight + topRight + topLeft) / 4.0F; + } + + void getLight(int x, int y) { + lightingCache[0] = lightmap[0 + x][0 + y]; + lightingCache[1] = lightmap[1 + x][0 + y]; + lightingCache[2] = lightmap[1 + x][1 + y]; + lightingCache[3] = lightmap[0 + x][1 + y]; + + redCache[0] = redmap[0 + x][0 + y]; + redCache[1] = redmap[1 + x][0 + y]; + redCache[2] = redmap[1 + x][1 + y]; + redCache[3] = redmap[0 + x][1 + y]; + + grnCache[0] = grnmap[0 + x][0 + y]; + grnCache[1] = grnmap[1 + x][0 + y]; + grnCache[2] = grnmap[1 + x][1 + y]; + grnCache[3] = grnmap[0 + x][1 + y]; + + bluCache[0] = blumap[0 + x][0 + y]; + bluCache[1] = blumap[1 + x][0 + y]; + bluCache[2] = blumap[1 + x][1 + y]; + bluCache[3] = blumap[0 + x][1 + y]; + } /** * This works around a bug in CLC atm @@ -201,8 +229,8 @@ public class RenderBlocksCTM extends RenderBlocks { sunlightBitChannel += (light & 0xF00000); } - return ((blockLightBitChannel / lightVals.length) & 0xFF) | ((redBitChannel / lightVals.length) & 0xF00) | ((greenBitChannel / lightVals.length) & 0xF000) - | ((blueBitChannel / lightVals.length) & 0xF0000) | ((sunlightBitChannel / lightVals.length) & 0xF00000); + return ((blockLightBitChannel / lightVals.length) & 0xFF) | ((redBitChannel / lightVals.length) & 0xF00) | ((greenBitChannel / lightVals.length) & 0xF000) | ( + (blueBitChannel / lightVals.length) & 0xF0000) | ((sunlightBitChannel / lightVals.length) & 0xF00000); } void side(SubSide side, int iconIndex) { @@ -226,8 +254,7 @@ public class RenderBlocksCTM extends RenderBlocks { side.render(this); } - @Override - public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -238,20 +265,23 @@ public class RenderBlocksCTM extends RenderBlocks { } else { int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4); - fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft); - getLight(0, 0); + fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft); + fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap); + fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap); + fillColormap(colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, blumap); + + getLight(0, 0); side(XNEG_LB, tex[0]); - getLight(1, 0); + getLight(1, 0); side(XNEG_RB, tex[1]); - getLight(1, 1); + getLight(1, 1); side(XNEG_RT, tex[2]); - getLight(0, 1); + getLight(0, 1); side(XNEG_LT, tex[3]); } } - @Override - public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -262,20 +292,22 @@ public class RenderBlocksCTM extends RenderBlocks { } else { int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5); - fillLightmap(brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight, brightnessTopRight); - getLight(0, 0); - side(XPOS_LB, tex[0]); - getLight(1, 0); - side(XPOS_RB, tex[1]); - getLight(1, 1); - side(XPOS_RT, tex[2]); - getLight(0, 1); - side(XPOS_LT, tex[3]); + fillLightmap(brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight, brightnessTopRight); + fillColormap(colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, redmap); + fillColormap(colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, grnmap); + fillColormap(colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, blumap); + getLight(0, 0); + side(XPOS_LB, tex[0]); + getLight(1, 0); + side(XPOS_RB, tex[1]); + getLight(1, 1); + side(XPOS_RT, tex[2]); + getLight(0, 1); + side(XPOS_LT, tex[3]); } } - @Override - public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -286,20 +318,22 @@ public class RenderBlocksCTM extends RenderBlocks { } else { int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2); - fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft); - getLight(0, 0); - side(ZNEG_LB, tex[0]); - getLight(1, 0); - side(ZNEG_RB, tex[1]); - getLight(1, 1); - side(ZNEG_RT, tex[2]); - getLight(0, 1); - side(ZNEG_LT, tex[3]); + fillLightmap(brightnessBottomRight, brightnessTopRight, brightnessTopLeft, brightnessBottomLeft); + fillColormap(colorRedBottomRight, colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, redmap); + fillColormap(colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, grnmap); + fillColormap(colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, blumap); + getLight(0, 0); + side(ZNEG_LB, tex[0]); + getLight(1, 0); + side(ZNEG_RB, tex[1]); + getLight(1, 1); + side(ZNEG_RT, tex[2]); + getLight(0, 1); + side(ZNEG_LT, tex[3]); } } - @Override - public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -310,20 +344,22 @@ public class RenderBlocksCTM extends RenderBlocks { } else { int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3); - fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft); - getLight(0, 0); - side(ZPOS_LB, tex[0]); - getLight(1, 0); - side(ZPOS_RB, tex[1]); - getLight(1, 1); - side(ZPOS_RT, tex[2]); - getLight(0, 1); - side(ZPOS_LT, tex[3]); + fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft); + fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap); + fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap); + fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap); + getLight(0, 0); + side(ZPOS_LB, tex[0]); + getLight(1, 0); + side(ZPOS_RB, tex[1]); + getLight(1, 1); + side(ZPOS_RT, tex[2]); + getLight(0, 1); + side(ZPOS_LT, tex[3]); } } - @Override - public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -332,22 +368,24 @@ public class RenderBlocksCTM extends RenderBlocks { tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV()); tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); } else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1); + int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0); - fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft); - getLight(0, 0); - side(YNEG_LB, tex[0]); - getLight(1, 0); - side(YNEG_RB, tex[1]); - getLight(1, 1); - side(YNEG_RT, tex[2]); - getLight(0, 1); - side(YNEG_LT, tex[3]); + fillLightmap(brightnessBottomLeft, brightnessBottomRight, brightnessTopRight, brightnessTopLeft); + fillColormap(colorRedBottomLeft, colorRedBottomRight, colorRedTopRight, colorRedTopLeft, redmap); + fillColormap(colorGreenBottomLeft, colorGreenBottomRight, colorGreenTopRight, colorGreenTopLeft, grnmap); + fillColormap(colorBlueBottomLeft, colorBlueBottomRight, colorBlueTopRight, colorBlueTopLeft, blumap); + getLight(0, 0); + side(YNEG_LB, tex[0]); + getLight(1, 0); + side(YNEG_RB, tex[1]); + getLight(1, 1); + side(YNEG_RT, tex[2]); + getLight(0, 1); + side(YNEG_LT, tex[3]); } } - @Override - public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) { + @Override public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) { if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { IIcon i = rendererOld.overrideBlockTexture; @@ -356,18 +394,20 @@ public class RenderBlocksCTM extends RenderBlocks { tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV()); tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV()); } else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0); + int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1); - fillLightmap(brightnessTopRight, brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight); - getLight(0, 0); - side(YPOS_LB, tex[0]); - getLight(1, 0); - side(YPOS_RB, tex[1]); - getLight(1, 1); - side(YPOS_RT, tex[2]); - getLight(0, 1); - side(YPOS_LT, tex[3]); + fillLightmap(brightnessTopRight, brightnessTopLeft, brightnessBottomLeft, brightnessBottomRight); + fillColormap(colorRedTopRight, colorRedTopLeft, colorRedBottomLeft, colorRedBottomRight, redmap); + fillColormap(colorGreenTopRight, colorGreenTopLeft, colorGreenBottomLeft, colorGreenBottomRight, grnmap); + fillColormap(colorBlueTopRight, colorBlueTopLeft, colorBlueBottomLeft, colorBlueBottomRight, blumap); + getLight(0, 0); + side(YPOS_LB, tex[0]); + getLight(1, 0); + side(YPOS_RB, tex[1]); + getLight(1, 1); + side(YPOS_RT, tex[2]); + getLight(0, 1); + side(YPOS_LT, tex[3]); } } - -} +} \ No newline at end of file diff --git a/src/main/java/com/cricketcraft/chisel/config/Configurations.java b/src/main/java/com/cricketcraft/chisel/config/Configurations.java index 76c812c5..5e5e6c6a 100644 --- a/src/main/java/com/cricketcraft/chisel/config/Configurations.java +++ b/src/main/java/com/cricketcraft/chisel/config/Configurations.java @@ -33,23 +33,26 @@ public class Configurations { public static int particlesTickrate; public static boolean oldPillars; public static boolean disableCTM; + public static boolean connectInsideCTM; public static boolean fancy; public static boolean blockDescriptions; public static boolean allowChiselDamage; public static int ironChiselMaxDamage; public static int diamondChiselMaxDamage; + public static int obsidianChiselMaxDamage; public static boolean ironChiselCanLeftClick; public static boolean ironChiselHasModes; public static int ironChiselAttackDamage; public static int diamondChiselAttackDamage; + public static int obsidianChiselAttackDamage; public static boolean allowChiselCrossColors; public static boolean useRoadLineTool; public static String getRoadLineTool; public static int roadLineToolLevel; - public static int[] configColors = new int[ItemDye.field_150923_a.length]; + public static int[] configColors = new int[ItemDye.field_150923_a.length]; public static boolean refreshConfig() { @@ -82,6 +85,7 @@ public class Configurations { particlesTickrate = config.get(category, "particleTickrate", 1, "Particle tick rate. Greater value = less particles.").getInt(1); oldPillars = config.get(category, "pillarOldGraphics", false, "Use old pillar textures").getBoolean(false); disableCTM = !config.get(category, "connectedTextures", true, "Enable connected textures").getBoolean(true); + connectInsideCTM = !config.get(category, "connectInsideCTM", false, "Choose whether the inside corner is disconnected on a CTM block - http://imgur.com/eUywLZ4").getBoolean(false); fancy = config.get(category, "fancyLeaves", true, "Enable fancy textures").getBoolean(true); blockDescriptions = config.get(category, "tooltipsUseBlockDescriptions", true, "Make variations of blocks have the same name, and use the description in tooltip to distinguish them.") .getBoolean(true); @@ -89,14 +93,18 @@ public class Configurations { /* chisel */ category = "chisel"; allowChiselDamage = config.get(category, "allowChiselDamage", true, "Should the chisel be damageable and take damage when it chisels something.").getBoolean(); - ironChiselMaxDamage = config.get(category, "ironChiselMaxDamage", 500, "The max damage of the standard iron chisel. Default: 500.").getInt(); - diamondChiselMaxDamage = config.get(category, "diamondChiselMaxDamage", 5000, "The max damage of the diamond chisel. Default: 5000").getInt(); + ironChiselMaxDamage = config.getInt("ironChiselMaxDamage", category, 500, 1, Short.MAX_VALUE, "The max damage of the standard iron chisel."); + diamondChiselMaxDamage = config.getInt("diamondChiselMaxDamage", category, 5000, 1, Short.MAX_VALUE, "The max damage of the diamond chisel."); + obsidianChiselMaxDamage = config.getInt("obsidianChiselMaxDamage", category, 2500, 1, Short.MAX_VALUE, "The max damage of the obsidian chisel."); ironChiselCanLeftClick = config.get(category, "ironChiselCanLeftClick", true, "If this is true, the iron chisel can left click chisel blocks. If false, it cannot.").getBoolean(); ironChiselHasModes = config.get(category, "ironChiselHasModes", false, "If this is true, the iron chisel can change its chisel mode just as the diamond chisel can.").getBoolean(); - ironChiselAttackDamage = config.get(category, "ironChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the iron chisel inflicts when it is used to attack an entity.").getInt(); - diamondChiselAttackDamage = config.get(category, "diamondChiselAttackDamage", 2, - "The extra attack damage points (in half hearts) that the diamond chisel inflicts when it is used to attack an entity.").getInt(); allowChiselCrossColors = config.get(category, "allowChiselCrossColors", true, "Should someone be able to chisel something into a different color.").getBoolean(); + ironChiselAttackDamage = config.get(category, "ironChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the iron chisel inflicts when it is used to attack an entity.") + .getInt(); + diamondChiselAttackDamage = config + .get(category, "diamondChiselAttackDamage", 2, "The extra attack damage points (in half hearts) that the diamond chisel inflicts when it is used to attack an entity.").getInt(); + obsidianChiselAttackDamage = config + .get(category, "obsidianChiselAttackDamage", 4, "The extra attack damage points (in half hearts) that the obsidian chisel inflicts when it is used to attack an entity.").getInt(); /* block */ category = "block"; @@ -107,19 +115,19 @@ public class Configurations { .getInt(); /* hexColors */ - category = "hexColors"; + category = "hexColors"; - for(int i = 0; i < ItemDye.field_150923_a.length; i++) { - // tterrag... don't kill me over this formatting. - String temp = config.get(category, "hex" + ItemDye.field_150923_a[i], "#" + Integer.toHexString(ItemDye.field_150922_c[i]), Character.toUpperCase(ItemDye.field_150923_a[i].charAt(0)) + ItemDye.field_150923_a[i].substring(1) + " color for hex block overlay #RRGGBB").getString(); - // Or this - try { - configColors[i] = Integer.decode(temp); - } catch (NumberFormatException e) { - Chisel.logger.warn("Configuration error, " + temp + " was not recognized as a color. Using default: #" + Integer.toHexString(ItemDye.field_150922_c[i])); - configColors[i] = ItemDye.field_150922_c[i]; - } - } + for(int i = 0; i < ItemDye.field_150923_a.length; i++) { + // tterrag... don't kill me over this formatting. + String temp = config.get(category, "hex" + ItemDye.field_150923_a[i], "#" + Integer.toHexString(ItemDye.field_150922_c[i]), Character.toUpperCase(ItemDye.field_150923_a[i].charAt(0)) + ItemDye.field_150923_a[i].substring(1) + " color for hex block overlay #RRGGBB").getString(); + // Or this + try { + configColors[i] = Integer.decode(temp); + } catch (NumberFormatException e) { + Chisel.logger.warn("Configuration error, " + temp + " was not recognized as a color. Using default: #" + Integer.toHexString(ItemDye.field_150922_c[i])); + configColors[i] = ItemDye.field_150922_c[i]; + } + } if (config.hasChanged()) { config.save(); @@ -131,7 +139,9 @@ public class Configurations { return config.get("features", featureName(feature), true).getBoolean(true) && refreshConfig(); } - /** Makes the old camelCase names from the new CONSTANT_CASE names */ + /** + * Makes the old camelCase names from the new CONSTANT_CASE names + */ public static String featureName(Features feature) { String[] words = feature.name().toLowerCase(Locale.ENGLISH).split("_"); if (words.length == 1) { @@ -149,4 +159,4 @@ public class Configurations { public static boolean featureEnabled(String feature) { return false; } -} +} \ No newline at end of file