Massively clean up CTM code, much more readable now

This commit is contained in:
tterrag1098 committed 2015-04-22 17:52:03 -04:00
1 parent 03b48c0e94
commit 2c8d88a639
4 files changed
+496 -665

No files matched your search

@@ -1,15 +1,9 @@
package com.cricketcraft.chisel.carving;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.carving.CarvableVariation.CarvableVariationCTM;
import com.cricketcraft.chisel.client.render.CTM;
import com.cricketcraft.chisel.client.render.TextureSubmap;
import com.cricketcraft.chisel.compat.FMPIntegration;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.item.ItemCarvable;
import com.cricketcraft.chisel.utils.GeneralClient;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPane;
import net.minecraft.block.material.Material;
@@ -20,7 +14,14 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.client.render.CTM;
import com.cricketcraft.chisel.client.render.TextureSubmap;
import com.cricketcraft.chisel.compat.FMPIntegration;
import com.cricketcraft.chisel.item.ItemCarvable;
import com.cricketcraft.chisel.utils.GeneralClient;
import cpw.mods.fml.common.registry.GameRegistry;
public class CarvableHelper {
@@ -33,248 +34,19 @@ public class CarvableHelper {
void registerIcons(String modName, Block block, IIconRegister register);
}
public enum TextureType implements ISubmapManager {
public enum TextureType {
TOPSIDE("top", "side") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
TOPBOTSIDE("top", "bottom", "side") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
CTM3("ctm1", "ctm2", "ctm3") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
CTMV("ctmv", "top") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
CTMH("ctmh", "top") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
V9("v9") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
V4("v4") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
CTMX("", "ctm") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
R16("r16") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
R9("r9") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
R4("r4") {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
},
NORMAL {
@Override
public IIcon getIcon(int side, int meta) {
// TODO Auto-generated method stub
return null;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
// TODO Auto-generated method stub
return null;
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
// TODO Auto-generated method stub
}
};
TOPSIDE("top", "side"),
TOPBOTSIDE("top", "bottom", "side"),
CTMV("ctmv", "top"),
CTMH("ctmh", "top"),
V9("v9"),
V4("v4"),
CTMX("", "ctm"),
R16("r16"),
R9("r9"),
R4("r4"),
NORMAL;
private String[] suffixes;
@@ -282,7 +54,7 @@ public class CarvableHelper {
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
}
public static ISubmapManager getManagerFor(String path) {
public static TextureType getTypeFor(String path) {
for (TextureType t : values()) {
boolean matches = true;
for (String s : t.suffixes) {
@@ -297,12 +69,6 @@ public class CarvableHelper {
}
return null;
}
@Override
public abstract IIcon getIcon(int side, int meta);
@Override
public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
}
private static final Random rand = new Random();
@@ -345,7 +111,7 @@ public class CarvableHelper {
if (texture != null) {
variation.texture = texture;
String path = "/assets/" + Chisel.MOD_ID + "/textures/blocks/" + variation.texture;
variation.type = (TextureType) TextureType.getManagerFor(path);
variation.type = (TextureType) TextureType.getTypeFor(path);
} else {
variation.block = block;
variation.type = TextureType.TOPBOTSIDE;
@@ -390,8 +156,6 @@ public class CarvableHelper {
return variation.iconBot;
else
return variation.icon;
case CTM3:
return variation.ctm.seams[0].icons[0];
case CTMV:
if (side < 2)
return variation.iconTop;
@@ -434,13 +198,13 @@ public class CarvableHelper {
case TOPSIDE:
case TOPBOTSIDE:
return getIcon(side, metadata);
case CTM3:
int tex = CTM.getTexture(world, x, y, z, side);
int row = tex / 16;
int col = tex % 16;
return variation.ctm.seams[col / 4].icons[col % 4 + row * 4];
// case CTM3:
// int tex = CTM.getTexture(world, x, y, z, side);
//
// int row = tex / 16;
// int col = tex % 16;
//
// return variation.ctm.seams[col / 4].icons[col % 4 + row * 4];
case CTMV: {
if (side < 2)
return variation.iconTop;
@@ -614,13 +378,13 @@ public class CarvableHelper {
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
variation.iconBot = register.registerIcon(modName + ":" + variation.texture + "-bottom");
break;
case CTM3:
CarvableVariationCTM ctm = new CarvableVariationCTM();
ctm.seams[0] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm1"), 4, 4);
ctm.seams[1] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm2"), 4, 4);
ctm.seams[2] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm3"), 4, 4);
variation.ctm = ctm;
break;
// case CTM3:
// CarvableVariationCTM ctm = new CarvableVariationCTM();
// ctm.seams[0] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm1"), 4, 4);
// ctm.seams[1] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm2"), 4, 4);
// ctm.seams[2] = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm3"), 4, 4);
// variation.ctm = ctm;
// break;
case CTMV:
variation.seamsCtmVert = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctmv"), 2, 2);
variation.iconTop = register.registerIcon(modName + ":" + variation.texture + "-top");
@@ -1,13 +1,23 @@
package com.cricketcraft.chisel.client.render;
import com.cricketcraft.chisel.config.Configurations;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import java.util.EnumMap;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.IFacade;
import com.cricketcraft.chisel.config.Configurations;
import com.google.common.collect.Maps;
import static com.cricketcraft.chisel.client.render.CTM.Dir.*;
import static net.minecraftforge.common.util.ForgeDirection.*;
/**
* @formatter:off
* 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
@@ -56,129 +66,167 @@ import com.cricketcraft.chisel.api.IFacade;
* HAVE FUN!
* -CptRageToaster-
*/
public class CTM {
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side) {
if (world == null)
return new int[] { 18, 19, 17, 16 };
Block block = world.getBlock(x, y, z);
int blockMetadata = world.getBlockMetadata(x, y, z);
enum Dir {
TOP(UP),
TOP_RIGHT(UP, EAST),
RIGHT(EAST),
BOTTOM_RIGHT(DOWN, EAST),
BOTTOM(DOWN),
BOTTOM_LEFT(DOWN, WEST),
LEFT(WEST),
TOP_LEFT(UP, WEST);
// @formatter:on
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) {
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 + 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 + 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);
private static final ForgeDirection NORMAL = SOUTH;
private static final Dir[] VALUES = values();
private ForgeDirection[] dirs;
private Dir(ForgeDirection... dirs) {
this.dirs = dirs;
}
private boolean isConnected(IBlockAccess world, int x, int y, int z, int sideIdx, Block block, int meta) {
ForgeDirection side = getOrientation(sideIdx);
ForgeDirection[] dirs = getNormalizedDirs(side);
for (ForgeDirection dir : dirs) {
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
}
return CTM.isConnected(world, x, y, z, side, block, meta);
}
private ForgeDirection[] getNormalizedDirs(ForgeDirection normal) {
if (normal == NORMAL) {
return dirs;
} else if (normal == NORMAL.getOpposite()) {
// If this is the opposite direction of the default normal, we need to mirror the dirs
// A mirror version does not affect y+ and y- so we ignore those
ForgeDirection[] ret = new ForgeDirection[dirs.length];
for (int i = 0; i < ret.length; i++) {
ret[i] = dirs[i].offsetY != 0 ? dirs[i] : dirs[i].getOpposite();
}
return ret;
} else {
ForgeDirection axis = null;
// Next, we need different a different rotation axis depending
// on if this is up/down or not
if (normal.offsetY == 0) {
// If it is not up/down, pick either the left or right-hand rotation
axis = normal == NORMAL.getRotation(UP) ? UP : DOWN;
} else {
// If it is up/down, pick either the up or down rotation.
axis = normal == UP ? NORMAL.getRotation(DOWN) : NORMAL.getRotation(UP);
}
ForgeDirection[] ret = new ForgeDirection[dirs.length];
// Finally apply all the rotations
for (int i = 0; i < ret.length; i++) {
ret[i] = dirs[i].getRotation(axis);
}
return ret;
}
}
}
/** Some hardcoded offset values for the different corner indeces */
private static int[] submapOffsets = { 4, 5, 1, 0 };
private static TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
private static EnumMap<Dir, Boolean> connectionMap = Maps.newEnumMap(Dir.class);
static {
for (Dir dir : Dir.VALUES) {
connectionMap.put(dir, false);
}
// Mapping the different corner indeces to their respective dirs
submapMap.put(0, new Dir[] { BOTTOM, LEFT, BOTTOM_LEFT });
submapMap.put(1, new Dir[] { BOTTOM, RIGHT, BOTTOM_RIGHT });
submapMap.put(2, new Dir[] { TOP, RIGHT, TOP_RIGHT });
submapMap.put(3, new Dir[] { TOP, LEFT, TOP_LEFT });
}
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side) {
int[] ret = new int[] { 18, 19, 17, 16 };
// 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;
if (world == null) {
return ret;
}
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// 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;
// Build connections
for (Dir dir : Dir.VALUES) {
connectionMap.put(dir, dir.isConnected(world, x, y, z, side, block, meta));
}
// 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;
// Map connections to submap indeces
for (int i = 0; i < 4; i++) {
fillSubmaps(ret, i);
}
// 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;
}
private static void fillSubmaps(int[] ret, int idx) {
Dir[] dirs = submapMap.get(idx);
if (connectedOr(dirs[0], dirs[1])) {
if (connectedAnd(dirs)) {
// If all dirs are connected, we use the fully connected face,
// the base offset value.
ret[idx] = submapOffsets[idx];
} else {
// This is a bit magic-y, but basically the array is ordered so
// the first dir requires an offset of 2, and the second dir
// requires an offset of 8, plus the initial offset for the
// corner.
ret[idx] = submapOffsets[idx] + (connected(dirs[0]) ? 2 : 0) + (connected(dirs[1]) ? 8 : 0);
}
}
}
private static boolean connected(Dir dir) {
return connectionMap.get(dir);
}
private static boolean connectedAnd(Dir... dirs) {
for (Dir dir : dirs) {
if (!connected(dir)) {
return false;
}
}
return true;
}
private static boolean connectedOr(Dir... dirs) {
for (Dir dir : dirs) {
if (connected(dir)) {
return true;
}
}
return false;
}
public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
return isConnected(world, x, y, z, dir, block, meta);
}
public static boolean isConnected(IBlockAccess world, int x, int y, int z, ForgeDirection dir, Block block, int meta) {
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);
Block con = getBlockOrFacade(world, x, y, z, dir.ordinal());
Block obscuring = getBlockOrFacade(world, x2, y2, z2, dir.ordinal());
// no block or a bad API user
if (con == null) {
return false;
}
boolean ret = con.equals(block) && getBlockOrFacadeMetadata(world, x, y, z, side) == meta;
boolean ret = con.equals(block) && getBlockOrFacadeMetadata(world, x, y, z, dir.ordinal()) == meta;
// no block obscuring this face
if (obscuring == null) {
@@ -186,7 +234,7 @@ public class CTM {
}
// check that we aren't already connected outwards from this side
ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, side) == meta && Configurations.connectInsideCTM);
ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, dir.ordinal()) == meta && Configurations.connectInsideCTM);
return ret;
}
@@ -16,13 +16,14 @@ public class RenderBlocksCTM extends RenderBlocks {
*
* The naming scheme is as follows:
*
* ZERO and ONE are special cases, they are the absolute min and absolute max of the block.
* 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.
* ZERO and ONE are special cases, they are the absolute min and absolute
* max of the block. 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 {
// @formatter:off
ZERO(0, 0, 0),
XYZ(1, 1, 1),
X(1, 0, 0),
@@ -49,6 +50,7 @@ public class RenderBlocksCTM extends RenderBlocks {
XY_HALF_Z(0.5, 0.5, 1),
YZ_HALF_X(1, 0.5, 0.5),
XZ_HALF_Y(0.5, 1, 0.5);
// @formatter:on
private double x, y, z;
@@ -69,11 +71,14 @@ 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 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.
* Each sub-side contains 4 {@link Vert} objects representing its position
* on the block.
*/
enum SubSide {
// @formatter:off
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),
@@ -82,6 +87,7 @@ public class RenderBlocksCTM extends RenderBlocks {
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);
// @formatter:on
private Vert xmin, xmax, ymin, ymax;
SubSide(Vert xmin, Vert ymin, Vert ymax, Vert xmax) {
@@ -129,7 +135,8 @@ public class RenderBlocksCTM extends RenderBlocks {
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,7 +153,8 @@ 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.
/* @formatter:off
* This method fills a 3x3 grid of light values based on the four corners, by averaging them together.
*
* 2 TL x TR
*
@@ -161,6 +169,7 @@ public class RenderBlocksCTM extends RenderBlocks {
*
* shakes fist in anger
*/
// @formatter:on
void fillLightmap(int bottomLeft, int bottomRight, int topRight, int topLeft) {
lightmap[0][0] = bottomLeft;
lightmap[2][0] = bottomRight;
@@ -229,8 +238,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) {
@@ -254,7 +263,8 @@ 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;
@@ -281,7 +291,8 @@ public class RenderBlocksCTM extends RenderBlocks {
}
}
@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;
@@ -307,7 +318,8 @@ public class RenderBlocksCTM extends RenderBlocks {
}
}
@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;
@@ -333,7 +345,8 @@ public class RenderBlocksCTM extends RenderBlocks {
}
}
@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;
@@ -359,7 +372,8 @@ public class RenderBlocksCTM extends RenderBlocks {
}
}
@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;
@@ -385,7 +399,8 @@ public class RenderBlocksCTM extends RenderBlocks {
}
}
@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;