From 49dfccffc73b5ecd1b744dc98cd5252fc8908a2a Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Wed, 8 Oct 2014 16:34:54 +0800 Subject: [PATCH] Added support for connected textures with facades. --- .../jbcs/minecraft/chisel/api/IFacade.java | 12 ++++++++++++ .../minecraft/chisel/client/render/CTM.java | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/java/info/jbcs/minecraft/chisel/api/IFacade.java diff --git a/src/main/java/info/jbcs/minecraft/chisel/api/IFacade.java b/src/main/java/info/jbcs/minecraft/chisel/api/IFacade.java new file mode 100644 index 00000000..de49cf38 --- /dev/null +++ b/src/main/java/info/jbcs/minecraft/chisel/api/IFacade.java @@ -0,0 +1,12 @@ +package info.jbcs.minecraft.chisel.api; + +import net.minecraft.block.Block; +import net.minecraft.world.IBlockAccess; + +public interface IFacade { + + int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side); + + Block getFacade(IBlockAccess world, int x, int y, int z, int side); + +} diff --git a/src/main/java/info/jbcs/minecraft/chisel/client/render/CTM.java b/src/main/java/info/jbcs/minecraft/chisel/client/render/CTM.java index ccee2b27..aab5ff66 100644 --- a/src/main/java/info/jbcs/minecraft/chisel/client/render/CTM.java +++ b/src/main/java/info/jbcs/minecraft/chisel/client/render/CTM.java @@ -1,5 +1,6 @@ package info.jbcs.minecraft.chisel.client.render; +import info.jbcs.minecraft.chisel.api.IFacade; import net.minecraft.block.Block; import net.minecraft.world.IBlockAccess; @@ -284,9 +285,23 @@ public class CTM break; } - return world.getBlock(x, y, z).equals(block) && world.getBlockMetadata(x, y, z) == meta && (!world.getBlock(x2, y2, z2).equals(block) || world.getBlockMetadata(x2, y2, z2) != meta); - + 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); } + private 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); + } + + private 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; + } }