Actually fix #9. Some other cleanup in CTM.

This commit is contained in:
tterrag1098 committed 2015-01-07 21:47:45 -05:00
1 parent fdb8cb7903
commit fa2f71c287
4 files changed
+48 -42

No files matched your search

@@ -3,10 +3,37 @@ package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.world.IBlockAccess;
public interface IFacade {
/**
* To be implemented on blocks that "hide" another block inside, so connected textuers can still be
* accomplished.
*/
public interface IFacade
{
/**
* Gets the block this facade is acting as.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @return The block inside of your facade block.
*/
Block getFacade(IBlockAccess world, int x, int y, int z, int side);
int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
Block getFacade(IBlockAccess world, int x, int y, int z, int side);
}
/**
* Gets the metadata of the block that this facade is acting as.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @return The metadata of your facade block.
*/
int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
}
@@ -208,8 +208,8 @@ public class CarvableHelper {
return variation.iconTop;
Block block = world.getBlock(x, y, z);
boolean topConnected = block.equals(CTM.getBlockOrFacade(world, x, y + 1, z, side)) && metadata == CTM.getBlockOrFacadeMetadata(world, x, y + 1, z, side);
boolean botConnected = block.equals(CTM.getBlockOrFacade(world, x, y - 1, z, side)) && metadata == CTM.getBlockOrFacadeMetadata(world, x, y - 1, z, side);
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];
@@ -230,11 +230,11 @@ public class CarvableHelper {
boolean reverse = side == 2 || side == 4;
if (side < 4) {
p = isSame(world, x - 1, y, z, block, metadata, side);
n = isSame(world, x + 1, y, z, block, metadata, side);
p = CTM.isConnected(world, x - 1, y, z, side, block, metadata);
n = CTM.isConnected(world, x + 1, y, z, side, block, metadata);
} else {
p = isSame(world, x, y, z + 1, block, metadata, side);
n = isSame(world, x, y, z - 1, block, metadata, side);
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)
@@ -381,10 +381,6 @@ public class CarvableHelper {
}
}
private boolean isSame(IBlockAccess world, int x, int y, int z, Block block, int meta, int side) {
return CTM.getBlockOrFacade(world, x, y, z, side).equals(block) && CTM.getBlockOrFacadeMetadata(world, x, y, z, side) == meta;
}
public void setChiselBlockName(String name) {
blockName = name;
}
@@ -2,6 +2,7 @@ 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;
@@ -187,34 +188,16 @@ public class CTM {
return texture;
}
protected static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
int x2 = x, y2 = y, z2 = z;
public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, Block block, int meta) {
switch (side) {
case 0:
y2--;
break;
case 1:
y2++;
break;
case 2:
z2--;
break;
case 3:
z2++;
break;
case 4:
x2--;
break;
case 5:
x2++;
break;
}
if (getBlockOrFacade(world, x2, y2, z2, side) == null || getBlockOrFacade(world, x, y, z, side) == null || block == null)
return false;
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
int x2 = x + dir.offsetX;
int y2 = y + dir.offsetY;
int z2 = z + dir.offsetZ;
return getBlockOrFacade(world, x, y, z, side).equals(block) && getBlockOrFacadeMetadata(world, x, y, z, side) == meta
&& (!getBlockOrFacade(world, x2, y2, z2, side).equals(block) || getBlockOrFacadeMetadata(world, x2, y2, z2, side) != meta);
&& !(getBlockOrFacade(world, x2, y2, z2, side).equals(block) && getBlockOrFacadeMetadata(world, x2, y2, z2, side) == meta);
}
public static int getBlockOrFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) {
@@ -16,7 +16,7 @@ public class RenderBlocksColumn extends RenderBlocks {
}
boolean connected(IBlockAccess world, int x, int y, int z, Block block, int meta) {
return world.getBlock(x, y, z).equals(block) && world.getBlockMetadata(x, y, z) == meta;
return CTM.getBlockOrFacade(world, x, y, z, -1).equals(block) && CTM.getBlockOrFacadeMetadata(world, x, y, z, -1) == meta;
}
@Override