mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 08:17:48 +00:00
Merge branch 'ctm_refactor2' into dev
This commit is contained in:
commit
59dcf10846
31 files changed
+1219
-994
No files matched your search
@@ -6,6 +6,7 @@ import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.carving.Carving;
|
||||
import com.cricketcraft.chisel.carving.CarvingGroup;
|
||||
import com.cricketcraft.chisel.client.render.SubmapManagerFakeController;
|
||||
import com.cricketcraft.chisel.compat.fmp.ItemBlockChiselTorchPart;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.entity.EntityBallOMoss;
|
||||
@@ -773,7 +774,7 @@ public enum Features {
|
||||
*/).setCreativeTab(ChiselTabs.tabMetalChiselBlocks).setHardness(2.0F).setResistance(10F);
|
||||
futura.carverHelper.addVariation("tile.futura.0.desc", 0, "futura/WIP/screenMetallicWIP");
|
||||
futura.carverHelper.addVariation("tile.futura.1.desc", 1, "futura/WIP/screenCyanWIP");
|
||||
futura.carverHelper.addVariation("tile.futura.2.desc", 2, "futura/WIP/controllerWIP");
|
||||
futura.carverHelper.addVariation("tile.futura.2.desc", 2, "futura/WIP/controllerWIP", new SubmapManagerFakeController());
|
||||
futura.carverHelper.addVariation("tile.futura.3.desc", 3, "futura/WIP/wavyWIP");
|
||||
futura.carverHelper.registerAll(futura, "futura");
|
||||
|
||||
|
||||
@@ -31,16 +31,20 @@ public class CarvingUtils {
|
||||
}
|
||||
|
||||
private static Field _chisel;
|
||||
private static boolean errored = false;
|
||||
private static boolean registryErrored = false;
|
||||
private static final String CARVING_CLASS = "com.cricketcraft.chisel.carving.Carving";
|
||||
|
||||
private static Class<ICarvableHelper> _carvableHelper;
|
||||
private static boolean helperErrored = false;
|
||||
private static final String CARVABLE_HELPER_CLASS = "com.cricketcraft.carving.CarvableHelper";
|
||||
|
||||
/**
|
||||
* @return The instance of the chisel carving registry from the chisel mod.
|
||||
* <p>
|
||||
* If chisel is not installed or some other error occurs this will return null.
|
||||
*/
|
||||
public static ICarvingRegistry getChiselRegistry() {
|
||||
if (errored) {
|
||||
if (registryErrored) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,8 +55,31 @@ public class CarvingUtils {
|
||||
return (ICarvingRegistry) _chisel.get(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errored = true;
|
||||
registryErrored = true;
|
||||
return getChiselRegistry();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An instance of an {@link ICarvableHelper}.
|
||||
* <p>
|
||||
* If chisel is not installed or some other error occurs this will return null.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ICarvableHelper getCarvableHelperInstance() {
|
||||
if (helperErrored) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (_carvableHelper == null) {
|
||||
_carvableHelper = (Class<ICarvableHelper>) Class.forName(CARVABLE_HELPER_CLASS);
|
||||
}
|
||||
return _carvableHelper.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
helperErrored = true;
|
||||
return getCarvableHelperInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.cricketcraft.chisel.api.carving;
|
||||
|
||||
|
||||
public interface ICarvableHelper {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
|
||||
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.google.common.collect.Maps;
|
||||
|
||||
import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
|
||||
// @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
|
||||
* rest of the quadrants.
|
||||
* <pre><blockquote>
|
||||
* ┌─────────────────┐ ┌────────────────────────────────┐
|
||||
* │ 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 │ │
|
||||
* │ ═══════╧═══════╗ ─────┼───── ╔ │
|
||||
* └────────────────────────────────┘
|
||||
* </blockquote></pre>
|
||||
* combining { 18, 13, 9, 16 }, we can generate a texture connected to the right!
|
||||
* <pre><blockquote>
|
||||
* ╔══════╤═══════
|
||||
* ║ │ │
|
||||
* ║ 16 │ 9 │
|
||||
* ╟──────┼──────┼
|
||||
* ║ │ │
|
||||
* ║ 18 │ 13 │
|
||||
* ╚══════╧═══════
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* combining { 18, 13, 11, 2 }, we can generate a texture, in the shape of an L (connected to the right, and up
|
||||
* <pre><blockquote>
|
||||
* ║ ─────┼───── ╚
|
||||
* ║ │ │
|
||||
* ║ 2 │ 11 │
|
||||
* ╟──────┼──────┼
|
||||
* ║ │ │
|
||||
* ║ 18 │ 13 │
|
||||
* ╚══════╧═══════
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* HAVE FUN!
|
||||
* -CptRageToaster-
|
||||
*/
|
||||
// @formatter:on
|
||||
public class CTM {
|
||||
|
||||
/** Some hardcoded offset values for the different corner indeces */
|
||||
private int[] submapOffsets = { 4, 5, 1, 0 };
|
||||
private TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
|
||||
private static EnumMap<Dir, Boolean> connectionMap = Maps.newEnumMap(Dir.class);
|
||||
/** For use via the Chisel 2 config only, altering this could cause unintended behavior */
|
||||
public static boolean disableObscuredFaceCheckConfig = false;
|
||||
|
||||
public Boolean disableObscuredFaceCheck = null;
|
||||
|
||||
private CTM() {
|
||||
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 CTM getInstance() {
|
||||
return new CTM();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The indeces of the typical 4x4 submap to use for the given face at the given location.
|
||||
*
|
||||
* Indeces are in counter-clockwise order starting at bottom left.
|
||||
*/
|
||||
public int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int[] ret = new int[] { 18, 19, 17, 16 };
|
||||
|
||||
if (world == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
buildConnectionMap(world, x, y, z, side, block, meta);
|
||||
|
||||
// Map connections to submap indeces
|
||||
for (int i = 0; i < 4; i++) {
|
||||
fillSubmaps(ret, i);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the connection map and stores it in this CTM instance. The {@link #connected(Dir)}, {@link #connectedAnd(Dir...)}, and {@link #connectedOr(Dir...)} methods can be used to access it.
|
||||
*/
|
||||
public void buildConnectionMap(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
|
||||
for (Dir dir : Dir.VALUES) {
|
||||
connectionMap.put(dir, dir.isConnected(this, world, x, y, z, side, block, meta));
|
||||
}
|
||||
}
|
||||
|
||||
private 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dir
|
||||
* The direction to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in this {@link Dir direction}.
|
||||
*/
|
||||
public boolean connected(Dir dir) {
|
||||
return connectionMap.get(dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dirs
|
||||
* The directions to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in <i><b>all</b></i> the given {@link Dir directions}.
|
||||
*/
|
||||
public boolean connectedAnd(Dir... dirs) {
|
||||
for (Dir dir : dirs) {
|
||||
if (!connected(dir)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dirs
|
||||
* The directions to check connection in.
|
||||
* @return True if the cached connectionMap holds a connection in <i><b>one of</b></i> the given {@link Dir directions}.
|
||||
*/
|
||||
private boolean connectedOr(Dir... dirs) {
|
||||
for (Dir dir : dirs) {
|
||||
if (connected(dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple check for if the given block can connect to the given direction on the given side.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* The x coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param y
|
||||
* The y coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param z
|
||||
* The z coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param side
|
||||
* The side of the block to check for connection status. This is <i>not</i> the direction to check in.
|
||||
* @param block
|
||||
* The block to check against for connection.
|
||||
* @param meta
|
||||
* The metadata to check against for connection.
|
||||
* @return True if the given block can connect to the given location on the given side.
|
||||
*/
|
||||
public 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple check for if the given block can connect to the given direction on the given side.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* The x coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param y
|
||||
* The y coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param z
|
||||
* The z coordinate of the block to check <i>against</i>. This is not the position of your block.
|
||||
* @param dir
|
||||
* The {@link ForgeDirection side} of the block to check for connection status. This is <i>not</i> the direction to check in.
|
||||
* @param block
|
||||
* The block to check against for connection.
|
||||
* @param meta
|
||||
* The metadata to check against for connection.
|
||||
* @return True if the given block can connect to the given location on the given side.
|
||||
*/
|
||||
public 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;
|
||||
|
||||
boolean disableObscured = disableObscuredFaceCheck == null ? disableObscuredFaceCheckConfig : disableObscuredFaceCheck;
|
||||
|
||||
Block con = getBlockOrFacade(world, x, y, z, dir.ordinal());
|
||||
Block obscuring = disableObscured ? null : 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, dir.ordinal()) == meta;
|
||||
|
||||
// no block obscuring this face
|
||||
if (obscuring == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// check that we aren't already connected outwards from this side
|
||||
ret &= !(obscuring.equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, dir.ordinal()) == meta);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to access metadata from both the world and {@link IFacade} blocks in the world.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param side
|
||||
* The side to check for. -1 for unknown.
|
||||
* @return The metadata at this position in the world, or inside an {@link IFacade} block.
|
||||
*/
|
||||
public int getBlockOrFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block blk = world.getBlock(x, y, z);
|
||||
if (blk instanceof IFacade) {
|
||||
return ((IFacade) blk).getFacadeMetadata(world, x, y, z, side);
|
||||
}
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to access a block from both the world and {@link IFacade} blocks in the world.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param side
|
||||
* The side to check for. -1 for unknown.
|
||||
* @return The block at this position in the world, or inside an {@link IFacade} block.
|
||||
*/
|
||||
public Block getBlockOrFacade(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block blk = world.getBlock(x, y, z);
|
||||
if (blk instanceof IFacade) {
|
||||
blk = ((IFacade) blk).getFacade(world, x, y, z, side);
|
||||
}
|
||||
return blk;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.cricketcraft.chisel.api.client;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
|
||||
public 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
|
||||
|
||||
private static final ForgeDirection NORMAL = SOUTH;
|
||||
public static final Dir[] VALUES = values();
|
||||
|
||||
private ForgeDirection[] dirs;
|
||||
|
||||
private Dir(ForgeDirection... dirs) {
|
||||
this.dirs = dirs;
|
||||
}
|
||||
|
||||
public boolean isConnected(CTM inst, 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 inst.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
@@ -18,12 +15,12 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation.CarvableVariationCTM;
|
||||
import com.cricketcraft.chisel.client.render.CTM;
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.client.render.TextureSubmap;
|
||||
import com.cricketcraft.chisel.compat.fmp.FMPIMC;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.item.ItemCarvable;
|
||||
import com.cricketcraft.chisel.utils.GeneralClient;
|
||||
|
||||
@@ -32,20 +29,57 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CarvableHelper {
|
||||
|
||||
public static final int NORMAL = 0;
|
||||
public static final int TOPSIDE = 1;
|
||||
public static final int TOPBOTSIDE = 2;
|
||||
public static final int CTM3 = 3;
|
||||
public static final int CTMV = 4;
|
||||
public static final int CTMH = 5;
|
||||
public static final int V9 = 6;
|
||||
public static final int V4 = 7;
|
||||
public static final int CTMX = 8;
|
||||
public static final int R16 = 9;
|
||||
public static final int R9 = 10;
|
||||
public static final int R4 = 11;
|
||||
public interface ISubmapManager {
|
||||
|
||||
private static final Random rand = new Random();
|
||||
IIcon getIcon(int side, int meta);
|
||||
|
||||
IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
|
||||
|
||||
void registerIcons(String modName, Block block, IIconRegister register);
|
||||
}
|
||||
|
||||
public enum TextureType {
|
||||
|
||||
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,
|
||||
CUSTOM;
|
||||
|
||||
private static final TextureType[] VALUES;
|
||||
private String[] suffixes;
|
||||
static {
|
||||
VALUES = ArrayUtils.subarray(values(), 0, values().length - 1);
|
||||
}
|
||||
|
||||
private TextureType(String... suffixes) {
|
||||
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
|
||||
}
|
||||
|
||||
public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) {
|
||||
for (TextureType t : VALUES) {
|
||||
boolean matches = true;
|
||||
for (String s : t.suffixes) {
|
||||
if (!inst.exists(modid, path, s.isEmpty() ? s : "-" + s)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
if (matches) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return CUSTOM;
|
||||
}
|
||||
}
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
public ArrayList<CarvableVariation> variations = new ArrayList<CarvableVariation>();
|
||||
CarvableVariation[] map = new CarvableVariation[16];
|
||||
@@ -65,7 +99,11 @@ public class CarvableHelper {
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture) {
|
||||
addVariation(description, metadata, texture, null, 0, Chisel.MOD_ID);
|
||||
addVariation(description, metadata, texture, (ISubmapManager) null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
|
||||
addVariation(description, metadata, texture, null, 0, Chisel.MOD_ID, manager);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, Block bb, String modid) {
|
||||
@@ -85,6 +123,11 @@ public class CarvableHelper {
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid) {
|
||||
addVariation(description, metadata, texture, block, blockMeta, modid, null);
|
||||
}
|
||||
|
||||
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager customManager) {
|
||||
|
||||
if (variations.size() >= 16)
|
||||
return;
|
||||
|
||||
@@ -100,53 +143,14 @@ public class CarvableHelper {
|
||||
|
||||
if (texture != null && FMLCommonHandler.instance().getSide().isClient()) {
|
||||
variation.texture = texture;
|
||||
|
||||
String path = variation.texture;
|
||||
|
||||
boolean any = exists(modid, path, "");
|
||||
boolean ctm3 = exists(modid, path, "-ctm1") && exists(modid, path, "-ctm2") && exists(modid, path, "-ctm3");
|
||||
boolean ctmv = exists(modid, path, "-ctmv");
|
||||
boolean ctmh = exists(modid, path, "-ctmh");
|
||||
boolean side = exists(modid, path, "-side");
|
||||
boolean top = exists(modid, path, "-top");
|
||||
boolean bot = exists(modid, path, "-bottom");
|
||||
boolean v9 = exists(modid, path, "-v9");
|
||||
boolean v4 = exists(modid, path, "-v4");
|
||||
boolean ctmx = exists(modid, path, "-ctm");
|
||||
boolean r16 = exists(modid, path, "-r16");
|
||||
boolean r9 = exists(modid, path, "-r9");
|
||||
boolean r4 = exists(modid, path, "-r4");
|
||||
|
||||
if (ctm3) {
|
||||
variation.kind = 3;
|
||||
} else if (ctmh && top) {
|
||||
variation.kind = 5;
|
||||
} else if (ctmv && top) {
|
||||
variation.kind = CTMV;
|
||||
} else if (bot && top && side) {
|
||||
variation.kind = 2;
|
||||
} else if (top && side) {
|
||||
variation.kind = 1;
|
||||
} else if (v9) {
|
||||
variation.kind = V9;
|
||||
} else if (v4) {
|
||||
variation.kind = V4;
|
||||
} else if (any && ctmx && !Configurations.disableCTM) {
|
||||
variation.kind = CTMX;
|
||||
} else if (r16) {
|
||||
variation.kind = R16;
|
||||
} else if (r9) {
|
||||
variation.kind = R9;
|
||||
} else if (r4) {
|
||||
variation.kind = R4;
|
||||
} else if (any) {
|
||||
variation.kind = 0;
|
||||
} else {
|
||||
throw new RuntimeException("No valid textures found for chisel block variation '" + description + "' (" + variation.texture + ")");
|
||||
variation.type = (TextureType) TextureType.getTypeFor(this, modid, variation.texture);
|
||||
if (variation.type == TextureType.CUSTOM && customManager == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not find texture %s, and no custom texture manager was provided.", texture));
|
||||
}
|
||||
variation.manager = customManager;
|
||||
} else {
|
||||
variation.block = block;
|
||||
variation.kind = 2;
|
||||
variation.type = TextureType.TOPBOTSIDE;
|
||||
variation.blockMeta = blockMeta;
|
||||
}
|
||||
|
||||
@@ -184,45 +188,45 @@ public class CarvableHelper {
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.kind) {
|
||||
case NORMAL:
|
||||
return variation.icon;
|
||||
case TOPSIDE:
|
||||
if (side == 0 || side == 1)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.icon;
|
||||
case TOPBOTSIDE:
|
||||
if (side == 1)
|
||||
return variation.iconTop;
|
||||
else if (side == 0)
|
||||
return variation.iconBot;
|
||||
else
|
||||
return variation.icon;
|
||||
case CTM3:
|
||||
return variation.ctm.seams[0].icons[0];
|
||||
case CTMV:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case CTMH:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case V9:
|
||||
return variation.variations9.icons[4];
|
||||
case V4:
|
||||
return variation.variations9.icons[0];
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
case R16:
|
||||
return variation.variations9.icons[5];
|
||||
case R9:
|
||||
return variation.variations9.icons[4];
|
||||
case R4:
|
||||
return variation.variations9.icons[0];
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
return variation.icon;
|
||||
case TOPSIDE:
|
||||
if (side == 0 || side == 1)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.icon;
|
||||
case TOPBOTSIDE:
|
||||
if (side == 1)
|
||||
return variation.iconTop;
|
||||
else if (side == 0)
|
||||
return variation.iconBot;
|
||||
else
|
||||
return variation.icon;
|
||||
case CTMV:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case CTMH:
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
else
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case V9:
|
||||
return variation.variations9.icons[4];
|
||||
case V4:
|
||||
return variation.variations9.icons[0];
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
case R16:
|
||||
return variation.variations9.icons[5];
|
||||
case R9:
|
||||
return variation.variations9.icons[4];
|
||||
case R4:
|
||||
return variation.variations9.icons[0];
|
||||
case CUSTOM:
|
||||
return variation.manager.getIcon(side, metadata);
|
||||
}
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
@@ -238,25 +242,25 @@ public class CarvableHelper {
|
||||
if (variation == null)
|
||||
return GeneralClient.getMissingIcon();
|
||||
|
||||
switch (variation.kind) {
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
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;
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
boolean topConnected = CTM.isConnected(world, x, y + 1, z, side, block, metadata);
|
||||
boolean botConnected = CTM.isConnected(world, x, y - 1, z, side, block, metadata);
|
||||
boolean topConnected = ctm.isConnected(world, x, y + 1, z, side, block, metadata);
|
||||
boolean botConnected = ctm.isConnected(world, x, y - 1, z, side, block, metadata);
|
||||
|
||||
if (topConnected && botConnected)
|
||||
return variation.seamsCtmVert.icons[2];
|
||||
@@ -270,18 +274,18 @@ public class CarvableHelper {
|
||||
if (side < 2)
|
||||
return variation.iconTop;
|
||||
|
||||
Block block = CTM.getBlockOrFacade(world, x, y, z, side);
|
||||
Block block = ctm.getBlockOrFacade(world, x, y, z, side);
|
||||
|
||||
boolean p;
|
||||
boolean n;
|
||||
boolean reverse = side == 2 || side == 5;
|
||||
|
||||
if (side < 4) {
|
||||
p = CTM.isConnected(world, x - 1, y, z, side, block, metadata);
|
||||
n = CTM.isConnected(world, x + 1, y, z, side, block, metadata);
|
||||
p = ctm.isConnected(world, x - 1, y, z, side, block, metadata);
|
||||
n = ctm.isConnected(world, x + 1, y, z, side, block, metadata);
|
||||
} else {
|
||||
p = CTM.isConnected(world, x, y, z - 1, side, block, metadata);
|
||||
n = CTM.isConnected(world, x, y, z + 1, side, block, metadata);
|
||||
p = ctm.isConnected(world, x, y, z - 1, side, block, metadata);
|
||||
n = ctm.isConnected(world, x, y, z + 1, side, block, metadata);
|
||||
}
|
||||
|
||||
if (p && n)
|
||||
@@ -293,7 +297,7 @@ public class CarvableHelper {
|
||||
return variation.seamsCtmVert.icons[0];
|
||||
case V9:
|
||||
case V4:
|
||||
int variationSize = (variation.kind == V9) ? 3 : 2;
|
||||
int variationSize = (variation.type == TextureType.V9) ? 3 : 2;
|
||||
|
||||
int xModulus = x % variationSize;
|
||||
int zModulus = z % variationSize;
|
||||
@@ -327,25 +331,25 @@ public class CarvableHelper {
|
||||
return variation.variations9.icons[index];
|
||||
case CTMX:
|
||||
return variation.icon;
|
||||
case R16:
|
||||
case R9:
|
||||
case R4:
|
||||
case R16:
|
||||
case R9:
|
||||
case R4:
|
||||
|
||||
int indexRan = x + y + z;
|
||||
if ((side==2)||(side==5)) {
|
||||
indexRan = -indexRan;
|
||||
}
|
||||
while (indexRan < 0) {
|
||||
indexRan = indexRan+10000;
|
||||
}
|
||||
int indexRan = x + y + z;
|
||||
if ((side == 2) || (side == 5)) {
|
||||
indexRan = -indexRan;
|
||||
}
|
||||
while (indexRan < 0) {
|
||||
indexRan = indexRan + 10000;
|
||||
}
|
||||
|
||||
//rand.setSeed(indexRan); // Broken
|
||||
// rand.setSeed(indexRan); // Broken
|
||||
|
||||
return variation.variations9.icons[ /*rand*/ indexRan % ((variation.kind == R9) ? 9 : 4)];
|
||||
return variation.variations9.icons[ /* rand */indexRan % ((variation.type == TextureType.R9) ? 9 : 4)];
|
||||
case CUSTOM:
|
||||
return variation.manager.getIcon(world, x, y, z, side);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return GeneralClient.getMissingIcon();
|
||||
}
|
||||
|
||||
@@ -396,7 +400,7 @@ public class CarvableHelper {
|
||||
variation.iconBot = ((BlockPane) variation.block).getBlockTextureFromSide(0);
|
||||
|
||||
} else {
|
||||
switch (variation.kind) {
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
variation.icon = variation.block.getIcon(2, variation.blockMeta);
|
||||
break;
|
||||
@@ -412,7 +416,7 @@ public class CarvableHelper {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (variation.kind) {
|
||||
switch (variation.type) {
|
||||
case NORMAL:
|
||||
variation.icon = register.registerIcon(modName + ":" + variation.texture);
|
||||
break;
|
||||
@@ -425,13 +429,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");
|
||||
@@ -451,15 +455,17 @@ public class CarvableHelper {
|
||||
variation.submap = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-ctm"), 4, 4);
|
||||
variation.submapSmall = new TextureSubmap(variation.icon, 2, 2);
|
||||
break;
|
||||
case R16:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r16"), 4, 4);
|
||||
break;
|
||||
case R9:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r9"), 3, 3);
|
||||
break;
|
||||
case R4:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r4"), 2, 2);
|
||||
break;
|
||||
case R16:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r16"), 4, 4);
|
||||
break;
|
||||
case R9:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r9"), 3, 3);
|
||||
break;
|
||||
case R4:
|
||||
variation.variations9 = new TextureSubmap(register.registerIcon(modName + ":" + variation.texture + "-r4"), 2, 2);
|
||||
break;
|
||||
case CUSTOM:
|
||||
variation.manager.registerIcons(modName, block, register);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,12 +478,7 @@ public class CarvableHelper {
|
||||
}
|
||||
|
||||
public void setChiselBlockName(String name) {
|
||||
blockName = name;
|
||||
}
|
||||
|
||||
public static Set<Block> getChiselBlockSet() {
|
||||
HashSet<Block> tools = new HashSet<Block>();
|
||||
return tools;
|
||||
blockName = name;
|
||||
}
|
||||
|
||||
public void registerOre(String ore) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.ISubmapManager;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.client.render.TextureSubmap;
|
||||
|
||||
public class CarvableVariation {
|
||||
@@ -11,7 +13,7 @@ public class CarvableVariation {
|
||||
public String blockName;
|
||||
public String descriptionUnloc;
|
||||
public int metadata;
|
||||
public int kind;
|
||||
public TextureType type = TextureType.NORMAL;
|
||||
|
||||
public Block block;
|
||||
public int blockMeta;
|
||||
@@ -19,8 +21,8 @@ public class CarvableVariation {
|
||||
public String texture;
|
||||
|
||||
public IIcon icon;
|
||||
public IIcon iconTop;
|
||||
public IIcon iconBot;
|
||||
public IIcon iconTop;
|
||||
|
||||
public CarvableVariationCTM ctm;
|
||||
public TextureSubmap seamsCtmVert;
|
||||
@@ -28,6 +30,8 @@ public class CarvableVariation {
|
||||
|
||||
public TextureSubmap submap;
|
||||
public TextureSubmap submapSmall;
|
||||
|
||||
public ISubmapManager manager;
|
||||
|
||||
public String getDescription() {
|
||||
return I18n.format(descriptionUnloc);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.cricketcraft.chisel.carving;
|
||||
|
||||
|
||||
public interface ITextureVariation {
|
||||
|
||||
}
|
||||
+4
-3
@@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
@@ -45,8 +46,8 @@ public class BlockAdvancedMarbleRenderer implements ISimpleBlockRenderingHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (var == null ? 0 : var.kind) {
|
||||
case CarvableHelper.CTMX:
|
||||
switch (var == null ? TextureType.NORMAL : var.type) {
|
||||
case CTMX:
|
||||
rendererCTM.blockAccess = world;
|
||||
rendererCTM.renderMaxX = 1.0;
|
||||
rendererCTM.renderMaxY = 1.0;
|
||||
@@ -58,7 +59,7 @@ public class BlockAdvancedMarbleRenderer implements ISimpleBlockRenderingHandler
|
||||
rendererCTM.rendererOld = rendererOld;
|
||||
|
||||
return rendererCTM.renderStandardBlock(block, x, y, z);
|
||||
case CarvableHelper.CTMV:
|
||||
case CTMV:
|
||||
rendererColumn.blockAccess = world;
|
||||
rendererColumn.renderMaxX = 1.0;
|
||||
rendererColumn.renderMaxY = 1.0;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
@@ -40,8 +41,7 @@ public class BlockCTMNoLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
CarvableVariation var = ((ICarvable) block).getVariation(world, x, y, z, meta);
|
||||
|
||||
switch (var == null ? 0 : var.kind) {
|
||||
case CarvableHelper.CTMX:
|
||||
if (var != null && var.type == TextureType.CTMX) {
|
||||
rendererCTMNoLight.blockAccess = world;
|
||||
rendererCTMNoLight.renderMaxX = 1.0;
|
||||
rendererCTMNoLight.renderMaxY = 1.0;
|
||||
@@ -53,7 +53,7 @@ public class BlockCTMNoLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
rendererCTMNoLight.rendererOld = rendererOld;
|
||||
|
||||
return rendererCTMNoLight.renderStandardBlock(block, x, y, z);
|
||||
default:
|
||||
} else {
|
||||
return rendererOld.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.block.BlockCarvablePillar;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
@@ -54,7 +55,7 @@ public class BlockMarblePillarRenderer implements ISimpleBlockRenderingHandler {
|
||||
metadata = block.carverHelper.variations.size() - 1;
|
||||
}
|
||||
else {
|
||||
if (block.carverHelper.variations.get(metadata).kind != CarvableHelper.CTMV) {
|
||||
if (block.carverHelper.variations.get(metadata).type != TextureType.CTMV) {
|
||||
block.sides[0] = block.carverHelper.getIcon(0, metadata);
|
||||
block.sides[1] = block.carverHelper.getIcon(1, metadata);
|
||||
block.sides[2] = block.carverHelper.getIcon(2, metadata);
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.cricketcraft.chisel.api.IFacade;
|
||||
|
||||
public class CTM {
|
||||
|
||||
static int submaps[][] = { { 16, 17, 18, 19 }, { 16, 9, 18, 13 }, { 8, 9, 12, 13 }, { 8, 17, 12, 19 }, { 16, 9, 6, 15 }, { 8, 17, 14, 7 }, { 2, 11, 6, 15 }, { 8, 9, 14, 15 }, { 10, 1, 14, 15 },
|
||||
{ 10, 11, 14, 5 }, { 0, 11, 4, 15 }, { 0, 1, 14, 15 }, {}, {}, {}, {}, { 16, 17, 6, 7 }, { 16, 9, 6, 5 }, { 8, 9, 4, 5 }, { 8, 17, 4, 7 }, { 2, 11, 18, 13 }, { 10, 3, 12, 19 },
|
||||
{ 10, 11, 12, 13 }, { 10, 3, 14, 7 }, { 0, 11, 14, 15 }, { 10, 11, 4, 15 }, { 10, 11, 4, 5 }, { 10, 1, 14, 5 }, {}, {}, {}, {}, { 2, 3, 6, 7 }, { 2, 1, 6, 5 }, { 0, 1, 4, 5 },
|
||||
{ 0, 3, 4, 7 }, { 2, 11, 6, 5 }, { 8, 9, 4, 15 }, { 2, 1, 6, 15 }, { 8, 9, 14, 5 }, { 0, 1, 4, 15 }, { 0, 1, 14, 5 }, { 10, 1, 4, 15 }, { 0, 11, 14, 5 }, {}, {}, {}, {}, { 2, 3, 18, 19 },
|
||||
{ 2, 1, 18, 13 }, { 0, 1, 12, 13 }, { 0, 3, 12, 19 }, { 10, 1, 12, 13 }, { 0, 3, 14, 7 }, { 0, 11, 12, 13 }, { 10, 3, 4, 7 }, { 0, 11, 4, 5 }, { 10, 1, 4, 5 }, { 10, 11, 14, 15 },
|
||||
{ 0, 1, 4, 5 }, {}, {}, {}, {}, };
|
||||
|
||||
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;
|
||||
|
||||
int texture = 0;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int blockMetadata = world.getBlockMetadata(x, y, z);
|
||||
|
||||
boolean b[] = new boolean[6];
|
||||
if (side <= 1) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
b[0] = isConnected(world, x, 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) {
|
||||
b[0] = isConnected(world, x, 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);
|
||||
}
|
||||
if (b[0] & !b[1] & !b[2] & !b[3])
|
||||
texture = 3;
|
||||
else if (!b[0] & b[1] & !b[2] & !b[3])
|
||||
texture = 1;
|
||||
else if (!b[0] & !b[1] & b[2] & !b[3])
|
||||
texture = 16;
|
||||
else if (!b[0] & !b[1] & !b[2] & b[3])
|
||||
texture = 48;
|
||||
else if (b[0] & b[1] & !b[2] & !b[3])
|
||||
texture = 2;
|
||||
else if (!b[0] & !b[1] & b[2] & b[3])
|
||||
texture = 32;
|
||||
else if (b[0] & !b[1] & b[2] & !b[3])
|
||||
texture = 19;
|
||||
else if (b[0] & !b[1] & !b[2] & b[3])
|
||||
texture = 51;
|
||||
else if (!b[0] & b[1] & b[2] & !b[3])
|
||||
texture = 17;
|
||||
else if (!b[0] & b[1] & !b[2] & b[3])
|
||||
texture = 49;
|
||||
else if (!b[0] & b[1] & b[2] & b[3])
|
||||
texture = 33;
|
||||
else if (b[0] & !b[1] & b[2] & b[3])
|
||||
texture = 35;
|
||||
else if (b[0] & b[1] & !b[2] & b[3])
|
||||
texture = 50;
|
||||
else if (b[0] & b[1] & b[2] & !b[3])
|
||||
texture = 18;
|
||||
else if (b[0] & b[1] & b[2] & b[3])
|
||||
texture = 34;
|
||||
|
||||
boolean b2[] = new boolean[6];
|
||||
if (side <= 1) {
|
||||
b2[0] = !isConnected(world, x + 1, y, z + 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x - 1, y, z + 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x + 1, y, z - 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x - 1, y, z - 1, side, block, blockMetadata);
|
||||
} else if (side == 2) {
|
||||
b2[0] = !isConnected(world, x - 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x + 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x - 1, y + 1, z, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x + 1, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 3) {
|
||||
b2[0] = !isConnected(world, x + 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x - 1, y - 1, z, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x + 1, y + 1, z, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x - 1, y + 1, z, side, block, blockMetadata);
|
||||
} else if (side == 4) {
|
||||
b2[0] = !isConnected(world, x, y - 1, z + 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x, y - 1, z - 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x, y + 1, z + 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x, y + 1, z - 1, side, block, blockMetadata);
|
||||
} else if (side == 5) {
|
||||
b2[0] = !isConnected(world, x, y - 1, z - 1, side, block, blockMetadata);
|
||||
b2[1] = !isConnected(world, x, y - 1, z + 1, side, block, blockMetadata);
|
||||
b2[2] = !isConnected(world, x, y + 1, z - 1, side, block, blockMetadata);
|
||||
b2[3] = !isConnected(world, x, y + 1, z + 1, side, block, blockMetadata);
|
||||
}
|
||||
|
||||
if (texture == 17 && b2[0])
|
||||
texture = 4;
|
||||
if (texture == 19 && b2[1])
|
||||
texture = 5;
|
||||
if (texture == 49 && b2[2])
|
||||
texture = 20;
|
||||
if (texture == 51 && b2[3])
|
||||
texture = 21;
|
||||
|
||||
if (texture == 18 && b2[0] && b2[1])
|
||||
texture = 7;
|
||||
if (texture == 33 && b2[0] && b2[2])
|
||||
texture = 6;
|
||||
if (texture == 35 && b2[3] && b2[1])
|
||||
texture = 23;
|
||||
if (texture == 50 && b2[3] && b2[2])
|
||||
texture = 22;
|
||||
|
||||
if (texture == 18 && !b2[0] && b2[1])
|
||||
texture = 39;
|
||||
if (texture == 33 && b2[0] && !b2[2])
|
||||
texture = 38;
|
||||
if (texture == 35 && !b2[3] && b2[1])
|
||||
texture = 53;
|
||||
if (texture == 50 && b2[3] && !b2[2])
|
||||
texture = 52;
|
||||
|
||||
if (texture == 18 && b2[0] && !b2[1])
|
||||
texture = 37;
|
||||
if (texture == 33 && !b2[0] && b2[2])
|
||||
texture = 36;
|
||||
if (texture == 35 && b2[3] && !b2[1])
|
||||
texture = 55;
|
||||
if (texture == 50 && !b2[3] && b2[2])
|
||||
texture = 54;
|
||||
|
||||
if (texture == 34 && b2[0] && b2[1] && b2[2] && b2[3])
|
||||
texture = 58;
|
||||
|
||||
if (texture == 34 && !b2[0] && b2[1] && b2[2] && b2[3])
|
||||
texture = 9;
|
||||
if (texture == 34 && b2[0] && !b2[1] && b2[2] && b2[3])
|
||||
texture = 25;
|
||||
if (texture == 34 && b2[0] && b2[1] && !b2[2] && b2[3])
|
||||
texture = 8;
|
||||
if (texture == 34 && b2[0] && b2[1] && b2[2] && !b2[3])
|
||||
texture = 24;
|
||||
|
||||
if (texture == 34 && b2[0] && b2[1] && !b2[2] && !b2[3])
|
||||
texture = 11;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && b2[2] && b2[3])
|
||||
texture = 26;
|
||||
if (texture == 34 && !b2[0] && b2[1] && !b2[2] && b2[3])
|
||||
texture = 27;
|
||||
if (texture == 34 && b2[0] && !b2[1] && b2[2] && !b2[3])
|
||||
texture = 10;
|
||||
|
||||
if (texture == 34 && b2[0] && !b2[1] && !b2[2] && b2[3])
|
||||
texture = 42;
|
||||
if (texture == 34 && !b2[0] && b2[1] && b2[2] && !b2[3])
|
||||
texture = 43;
|
||||
|
||||
if (texture == 34 && b2[0] && !b2[1] && !b2[2] && !b2[3])
|
||||
texture = 40;
|
||||
if (texture == 34 && !b2[0] && b2[1] && !b2[2] && !b2[3])
|
||||
texture = 41;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && b2[2] && !b2[3])
|
||||
texture = 56;
|
||||
if (texture == 34 && !b2[0] && !b2[1] && !b2[2] && b2[3])
|
||||
texture = 57;
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
|
||||
|
||||
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);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int getBlockOrFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block blk = world.getBlock(x, y, z);
|
||||
if (blk instanceof IFacade) {
|
||||
return ((IFacade) blk).getFacadeMetadata(world, x, y, z, side);
|
||||
}
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
public static Block getBlockOrFacade(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block blk = world.getBlock(x, y, z);
|
||||
if (blk instanceof IFacade) {
|
||||
blk = ((IFacade) blk).getFacade(world, x, y, z, side);
|
||||
}
|
||||
return blk;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,113 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.Vert.*;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.SubSide.*;
|
||||
import static com.cricketcraft.chisel.client.render.RenderBlocksCTM.Vert.Y_HALF_X;
|
||||
|
||||
public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
/**
|
||||
* An enum for all possible 26 sub-side vertices.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
enum Vert {
|
||||
// @formatter:off
|
||||
ZERO(0, 0, 0),
|
||||
XYZ(1, 1, 1),
|
||||
X(1, 0, 0),
|
||||
Y(0, 1, 0),
|
||||
Z(0, 0, 1),
|
||||
XY(1, 1, 0),
|
||||
YZ(0, 1, 1),
|
||||
XZ(1, 0, 1),
|
||||
X_HALF(0.5, 0, 0),
|
||||
Y_HALF(0, 0.5, 0),
|
||||
Z_HALF(0, 0, 0.5),
|
||||
XY_HALF(0.5, 0.5, 0),
|
||||
YZ_HALF(0, 0.5, 0.5),
|
||||
XZ_HALF(0.5, 0, 0.5),
|
||||
X_HALF_Y(0.5, 1, 0),
|
||||
X_HALF_Z(0.5, 0, 1),
|
||||
Y_HALF_X(1, 0.5, 0),
|
||||
Y_HALF_Z(0, 0.5, 1),
|
||||
Z_HALF_X(1, 0, 0.5),
|
||||
Z_HALF_Y(0, 1, 0.5),
|
||||
X_HALF_YZ(0.5, 1, 1),
|
||||
Y_HALF_XZ(1, 0.5, 1),
|
||||
Z_HALF_XY(1, 1, 0.5),
|
||||
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;
|
||||
|
||||
private Vert(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
void render(RenderBlocksCTM inst, int cacheID) {
|
||||
if (inst.enableAO) {
|
||||
inst.tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]);
|
||||
inst.tessellator.setBrightness(inst.lightingCache[cacheID]);
|
||||
}
|
||||
|
||||
inst.tessellator.addVertexWithUV(x, y, z, inst.uCache[cacheID], inst.vCache[cacheID]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
// @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),
|
||||
|
||||
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);
|
||||
// @formatter:on
|
||||
private Vert xmin, xmax, ymin, ymax;
|
||||
|
||||
SubSide(Vert xmin, Vert ymin, Vert ymax, Vert xmax) {
|
||||
this.xmin = xmin;
|
||||
this.ymin = ymin;
|
||||
this.ymax = ymax;
|
||||
this.xmax = xmax;
|
||||
}
|
||||
|
||||
void render(RenderBlocksCTM inst) {
|
||||
xmin.render(inst, 0);
|
||||
ymin.render(inst, 1);
|
||||
ymax.render(inst, 2);
|
||||
xmax.render(inst, 3);
|
||||
}
|
||||
}
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
// globals added to save the JVM some trouble. No need to constantly create
|
||||
// and destroy ints if we don't have to
|
||||
int blockLightBitChannel = 0;
|
||||
@@ -17,24 +118,24 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
|
||||
RenderBlocksCTM() {
|
||||
super();
|
||||
|
||||
resetVertices();
|
||||
}
|
||||
|
||||
Tessellator tessellator;
|
||||
double[] X = new double[26];
|
||||
double[] Y = new double[26];
|
||||
double[] Z = new double[26];
|
||||
double[] U = new double[26];
|
||||
double[] V = new double[26];
|
||||
int[] L = new int[26];
|
||||
float[] R = new float[26];
|
||||
float[] G = new float[26];
|
||||
float[] B = new float[26];
|
||||
double[] uCache = new double[4];
|
||||
double[] vCache = new double[4];
|
||||
int[] lightingCache = new int[4];
|
||||
float[] redCache = 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];
|
||||
float[][] redmap = new float[3][3];
|
||||
float[][] grnmap = new float[3][3];
|
||||
float[][] blumap = new float[3][3];
|
||||
|
||||
int bx, by, bz;
|
||||
|
||||
@Override
|
||||
@@ -55,70 +156,77 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
return res;
|
||||
}
|
||||
|
||||
void setupSides(int a, int b, int c, int d, int xa, int xb, int xc, int xd, int e) {
|
||||
L[a] = brightnessBottomLeft;
|
||||
L[b] = brightnessBottomRight;
|
||||
L[c] = brightnessTopRight;
|
||||
L[d] = brightnessTopLeft;
|
||||
/* @formatter:off
|
||||
* 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
|
||||
*/
|
||||
// @formatter:on
|
||||
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;
|
||||
|
||||
// Updated to safely average light and color channels
|
||||
L[e] = averageBrightnessChannels(brightnessBottomLeft, brightnessTopLeft, brightnessTopRight, brightnessBottomRight);
|
||||
L[xa] = averageBrightnessChannels(L[a], L[b]);
|
||||
L[xb] = averageBrightnessChannels(L[b], L[c]);
|
||||
L[xc] = averageBrightnessChannels(L[c], L[d]);
|
||||
L[xd] = averageBrightnessChannels(L[d], L[a]);
|
||||
lightmap[1][0] = avg(bottomLeft, bottomRight);
|
||||
lightmap[2][1] = avg(bottomRight, topRight);
|
||||
lightmap[1][2] = avg(topRight, topLeft);
|
||||
lightmap[0][1] = avg(topLeft, bottomLeft);
|
||||
|
||||
R[a] = colorRedBottomLeft;
|
||||
R[b] = colorRedBottomRight;
|
||||
R[c] = colorRedTopRight;
|
||||
R[d] = colorRedTopLeft;
|
||||
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
|
||||
R[xa] = (R[a] + R[b]) / 2;
|
||||
R[xb] = (R[b] + R[c]) / 2;
|
||||
R[xc] = (R[c] + R[d]) / 2;
|
||||
R[xd] = (R[d] + R[a]) / 2;
|
||||
|
||||
G[a] = colorGreenBottomLeft;
|
||||
G[b] = colorGreenBottomRight;
|
||||
G[c] = colorGreenTopRight;
|
||||
G[d] = colorGreenTopLeft;
|
||||
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
|
||||
G[xa] = (G[a] + G[b]) / 2;
|
||||
G[xb] = (G[b] + G[c]) / 2;
|
||||
G[xc] = (G[c] + G[d]) / 2;
|
||||
G[xd] = (G[d] + G[a]) / 2;
|
||||
|
||||
B[a] = colorBlueBottomLeft;
|
||||
B[b] = colorBlueBottomRight;
|
||||
B[c] = colorBlueTopRight;
|
||||
B[d] = colorBlueTopLeft;
|
||||
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
|
||||
B[xa] = (B[a] + B[b]) / 2;
|
||||
B[xb] = (B[b] + B[c]) / 2;
|
||||
B[xc] = (B[c] + B[d]) / 2;
|
||||
B[xd] = (B[d] + B[a]) / 2;
|
||||
lightmap[1][1] = avg(bottomLeft, bottomRight, topRight, topLeft);
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes in a variable number of packed light-integers, and computes the
|
||||
* average value of each 4 bit channel
|
||||
*
|
||||
* For vanilla, these look like: (S = skylight and L = block light) 0000
|
||||
* 0000 SSSS 0000 0000 0000 LLLL 0000 With the Colored Light Core installed,
|
||||
* these look like: (B = Blue, G = Green, R = Red) 0000 0000 SSSS BBBB GGGG
|
||||
* RRRR LLLL 0000
|
||||
*
|
||||
* This method will average all of the values appropriately for the more
|
||||
* complex case, by separating each color channel into a running total, then
|
||||
* it will combine the final results together using integer division and a
|
||||
* lot of bit-cramming.
|
||||
*
|
||||
* While slightly more complex, the runtime should not be drastically
|
||||
* effected, and the averaging routine remains compatible with vanilla.
|
||||
*
|
||||
* Authored: CptSpaceToaster - 12/19/2014
|
||||
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;
|
||||
|
||||
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
|
||||
*/
|
||||
int averageBrightnessChannels(int... lightVals) {
|
||||
int avg(int... lightVals) {
|
||||
blockLightBitChannel = 0;
|
||||
redBitChannel = 0;
|
||||
greenBitChannel = 0;
|
||||
@@ -137,37 +245,25 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
| ((blueBitChannel / lightVals.length) & 0xF0000) | ((sunlightBitChannel / lightVals.length) & 0xF00000);
|
||||
}
|
||||
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip) {
|
||||
void side(SubSide side, int iconIndex) {
|
||||
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
double v1 = icon.getMinV();
|
||||
double umax = icon.getMaxU();
|
||||
double umin = icon.getMinU();
|
||||
double vmax = icon.getMaxV();
|
||||
double vmin = icon.getMinV();
|
||||
|
||||
U[a] = flip ? u1 : u1;
|
||||
U[b] = flip ? u0 : u1;
|
||||
U[c] = flip ? u0 : u0;
|
||||
U[d] = flip ? u1 : u0;
|
||||
uCache[0] = umin;
|
||||
uCache[1] = umax;
|
||||
uCache[2] = umax;
|
||||
uCache[3] = umin;
|
||||
|
||||
V[a] = flip ? v1 : v1;
|
||||
V[b] = flip ? v1 : v0;
|
||||
V[c] = flip ? v0 : v0;
|
||||
V[d] = flip ? v0 : v1;
|
||||
vCache[0] = vmax;
|
||||
vCache[1] = vmax;
|
||||
vCache[2] = vmin;
|
||||
vCache[3] = vmin;
|
||||
|
||||
vert(a);
|
||||
vert(b);
|
||||
vert(c);
|
||||
vert(d);
|
||||
}
|
||||
|
||||
void vert(int index) {
|
||||
if (enableAO) {
|
||||
tessellator.setColorOpaque_F(R[index], G[index], B[index]);
|
||||
tessellator.setBrightness(L[index]);
|
||||
}
|
||||
|
||||
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
|
||||
side.render(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,13 +276,21 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9);
|
||||
side(1, 14, 9, 23, tex[0], false);
|
||||
side(23, 9, 17, 5, tex[1], false);
|
||||
side(9, 19, 4, 17, tex[3], false);
|
||||
side(14, 0, 19, 9, tex[2], false);
|
||||
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);
|
||||
side(XNEG_RB, tex[1]);
|
||||
getLight(1, 1);
|
||||
side(XNEG_RT, tex[2]);
|
||||
getLight(0, 1);
|
||||
side(XNEG_LT, tex[3]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,13 +304,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11);
|
||||
side(11, 21, 3, 15, tex[3], false);
|
||||
side(16, 7, 21, 11, tex[2], false);
|
||||
side(25, 11, 15, 2, tex[1], false);
|
||||
side(6, 16, 11, 25, tex[0], false);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,13 +331,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8);
|
||||
side(2, 15, 8, 22, tex[0], false);
|
||||
side(15, 3, 18, 8, tex[2], false);
|
||||
side(8, 18, 0, 14, tex[3], false);
|
||||
side(22, 8, 14, 1, tex[1], false);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,13 +358,20 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10);
|
||||
side(17, 4, 20, 10, tex[2], false);
|
||||
side(5, 17, 10, 24, tex[0], false);
|
||||
side(24, 10, 16, 6, tex[1], false);
|
||||
side(10, 20, 7, 16, tex[3], false);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,13 +385,20 @@ 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, 0);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13);
|
||||
side(13, 21, 7, 20, tex[3], true);
|
||||
side(19, 13, 20, 4, tex[2], true);
|
||||
side(0, 18, 13, 19, tex[0], true);
|
||||
side(18, 3, 21, 13, tex[1], true);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,119 +412,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, 1);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
setupSides(2, 1, 5, 6, 22, 23, 24, 25, 12);
|
||||
side(12, 24, 6, 25, tex[3], false);
|
||||
side(22, 12, 25, 2, tex[1], false);
|
||||
side(1, 23, 12, 22, tex[0], false);
|
||||
side(23, 5, 24, 12, tex[2], false);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
void resetVertices() {
|
||||
X[0] = 0;
|
||||
Z[0] = 0;
|
||||
Y[0] = 0;
|
||||
|
||||
X[1] = 0;
|
||||
Z[1] = 0;
|
||||
Y[1] = 1;
|
||||
|
||||
X[2] = 1;
|
||||
Z[2] = 0;
|
||||
Y[2] = 1;
|
||||
|
||||
X[3] = 1;
|
||||
Z[3] = 0;
|
||||
Y[3] = 0;
|
||||
|
||||
X[4] = 0;
|
||||
Z[4] = 1;
|
||||
Y[4] = 0;
|
||||
|
||||
X[5] = 0;
|
||||
Z[5] = 1;
|
||||
Y[5] = 1;
|
||||
|
||||
X[6] = 1;
|
||||
Z[6] = 1;
|
||||
Y[6] = 1;
|
||||
|
||||
X[7] = 1;
|
||||
Z[7] = 1;
|
||||
Y[7] = 0;
|
||||
|
||||
X[8] = 0.5;
|
||||
Z[8] = 0;
|
||||
Y[8] = 0.5;
|
||||
|
||||
X[9] = 0;
|
||||
Z[9] = 0.5;
|
||||
Y[9] = 0.5;
|
||||
|
||||
X[10] = 0.5;
|
||||
Z[10] = 1;
|
||||
Y[10] = 0.5;
|
||||
|
||||
X[11] = 1;
|
||||
Z[11] = 0.5;
|
||||
Y[11] = 0.5;
|
||||
|
||||
X[12] = 0.5;
|
||||
Z[12] = 0.5;
|
||||
Y[12] = 1;
|
||||
|
||||
X[13] = 0.5;
|
||||
Z[13] = 0.5;
|
||||
Y[13] = 0;
|
||||
|
||||
X[14] = 0;
|
||||
Z[14] = 0;
|
||||
Y[14] = 0.5;
|
||||
|
||||
X[15] = 1;
|
||||
Z[15] = 0;
|
||||
Y[15] = 0.5;
|
||||
|
||||
X[16] = 1;
|
||||
Z[16] = 1;
|
||||
Y[16] = 0.5;
|
||||
|
||||
X[17] = 0;
|
||||
Z[17] = 1;
|
||||
Y[17] = 0.5;
|
||||
|
||||
X[18] = 0.5;
|
||||
Z[18] = 0;
|
||||
Y[18] = 0;
|
||||
|
||||
X[19] = 0;
|
||||
Z[19] = 0.5;
|
||||
Y[19] = 0;
|
||||
|
||||
X[20] = 0.5;
|
||||
Z[20] = 1;
|
||||
Y[20] = 0;
|
||||
|
||||
X[21] = 1;
|
||||
Z[21] = 0.5;
|
||||
Y[21] = 0;
|
||||
|
||||
X[22] = 0.5;
|
||||
Z[22] = 0;
|
||||
Y[22] = 1;
|
||||
|
||||
X[23] = 0;
|
||||
Z[23] = 0.5;
|
||||
Y[23] = 1;
|
||||
|
||||
X[24] = 0.5;
|
||||
Z[24] = 1;
|
||||
Y[24] = 1;
|
||||
|
||||
X[25] = 1;
|
||||
Z[25] = 0.5;
|
||||
Y[25] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,6 @@ public class RenderBlocksCTMCarpet extends RenderBlocksCTM {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetVertices() {
|
||||
super.resetVertices();
|
||||
|
||||
for (int i = 0; i < Y.length; i++) {
|
||||
Y[i] /= 16;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceXNeg(block, 0, 0, 0, submapSmall.icon);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -7,6 +9,8 @@ import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksCTMNoLight() {
|
||||
super();
|
||||
resetVertices();
|
||||
@@ -82,7 +86,7 @@ public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 4);
|
||||
|
||||
side(1, 14, 9, 23, tex[0], false);
|
||||
side(23, 9, 17, 5, tex[1], false);
|
||||
@@ -101,7 +105,7 @@ public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 5);
|
||||
|
||||
side(11, 21, 3, 15, tex[3], false);
|
||||
side(16, 7, 21, 11, tex[2], false);
|
||||
@@ -120,7 +124,7 @@ public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 2);
|
||||
|
||||
side(2, 15, 8, 22, tex[0], false);
|
||||
side(15, 3, 18, 8, tex[2], false);
|
||||
@@ -139,7 +143,7 @@ public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
|
||||
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
|
||||
} else {
|
||||
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 3);
|
||||
|
||||
side(17, 4, 20, 10, tex[2], false);
|
||||
side(5, 17, 10, 24, tex[0], false);
|
||||
@@ -158,7 +162,7 @@ public class RenderBlocksCTMNoLight 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, 0);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 0);
|
||||
|
||||
side(13, 21, 7, 20, tex[3], true);
|
||||
side(19, 13, 20, 4, tex[2], true);
|
||||
@@ -177,7 +181,7 @@ public class RenderBlocksCTMNoLight 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, 1);
|
||||
int tex[] = ctm.getSubmapIndices(blockAccess, bx, by, bz, 1);
|
||||
|
||||
side(12, 24, 6, 25, tex[3], false);
|
||||
side(22, 12, 25, 2, tex[1], false);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -10,14 +12,15 @@ public class RenderBlocksColumn extends RenderBlocks {
|
||||
TextureSubmap submap;
|
||||
IIcon iconTop;
|
||||
IIcon sides[] = new IIcon[6];
|
||||
CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksColumn() {
|
||||
super();
|
||||
}
|
||||
|
||||
boolean connected(IBlockAccess world, int x, int y, int z, Block block, int meta) {
|
||||
Block inWorld = CTM.getBlockOrFacade(world, x, y, z, -1);
|
||||
return inWorld != null && inWorld.equals(block) && CTM.getBlockOrFacadeMetadata(world, x, y, z, -1) == meta;
|
||||
Block inWorld = ctm.getBlockOrFacade(world, x, y, z, -1);
|
||||
return inWorld != null && inWorld.equals(block) && ctm.getBlockOrFacadeMetadata(world, x, y, z, -1) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.ISubmapManager;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
|
||||
public class SubmapManagerFakeController implements ISubmapManager {
|
||||
|
||||
private TextureSubmap map;
|
||||
private CTM ctm = CTM.getInstance();
|
||||
|
||||
public SubmapManagerFakeController() {
|
||||
ctm.disableObscuredFaceCheck = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return map.icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
ctm.buildConnectionMap(world, x, y, z, side, ChiselBlocks.futura, 2);
|
||||
if (ctm.connectedAnd(TOP, BOTTOM, LEFT, RIGHT)) {
|
||||
return map.icons[3];
|
||||
} else if (ctm.connectedAnd(TOP, BOTTOM)) {
|
||||
return map.icons[2];
|
||||
} else if (ctm.connectedAnd(LEFT, RIGHT)) {
|
||||
return map.icons[1];
|
||||
} else {
|
||||
return map.icons[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(String modName, Block block, IIconRegister register) {
|
||||
map = new TextureSubmap(register.registerIcon(modName + ":futura/WIP/controllerWIP-ctm"), 2, 2);
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,4 @@ public class TextureSubmap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,59 +6,59 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TextureVirtual implements IIcon {
|
||||
|
||||
int ox, oy;
|
||||
float u0, u1, v0, v1;
|
||||
String name;
|
||||
IIcon icon;
|
||||
private int width, height;
|
||||
private float umin, umax, vmin, vmax;
|
||||
private String name;
|
||||
private IIcon parentIcon;
|
||||
|
||||
TextureVirtual(IIcon parent, int w, int h, int x, int y) {
|
||||
icon = parent;
|
||||
parentIcon = parent;
|
||||
|
||||
u0 = icon.getInterpolatedU(16.0 * (x) / w);
|
||||
u1 = icon.getInterpolatedU(16.0 * (x + 1) / w);
|
||||
v0 = icon.getInterpolatedV(16.0 * (y) / h);
|
||||
v1 = icon.getInterpolatedV(16.0 * (y + 1) / h);
|
||||
umin = parentIcon.getInterpolatedU(16.0 * (x) / w);
|
||||
umax = parentIcon.getInterpolatedU(16.0 * (x + 1) / w);
|
||||
vmin = parentIcon.getInterpolatedV(16.0 * (y) / h);
|
||||
vmax = parentIcon.getInterpolatedV(16.0 * (y + 1) / h);
|
||||
|
||||
name = icon.getIconName() + "|" + x + "." + y;
|
||||
name = parentIcon.getIconName() + "|" + x + "." + y;
|
||||
|
||||
ox = icon.getIconWidth();
|
||||
oy = icon.getIconHeight();
|
||||
width = parentIcon.getIconWidth();
|
||||
height = parentIcon.getIconHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinU() {
|
||||
return u0;
|
||||
return umin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxU() {
|
||||
return u1;
|
||||
return umax;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedU(double d0) {
|
||||
return (float) (u0 + (u1 - u0) * d0 / 16.0);
|
||||
return (float) (umin + (umax - umin) * d0 / 16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinV() {
|
||||
return v0;
|
||||
return vmin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxV() {
|
||||
return v1;
|
||||
return vmax;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedV(double d0) {
|
||||
return (float) (v0 + (v1 - v0) * d0 / 16.0);
|
||||
return (float) (vmin + (vmax - vmin) * d0 / 16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,13 +70,12 @@ public class TextureVirtual implements IIcon {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconWidth() {
|
||||
return ox;
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconHeight() {
|
||||
return oy;
|
||||
return height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,8 +2,11 @@ package com.cricketcraft.chisel.config;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.Features;
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -33,6 +36,7 @@ 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;
|
||||
|
||||
@@ -87,6 +91,8 @@ 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);
|
||||
CTM.disableObscuredFaceCheckConfig = 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);
|
||||
@@ -100,6 +106,7 @@ public class Configurations {
|
||||
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();
|
||||
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,
|
||||
|
||||
Reference in new issue
Block a user