From 99a5702de95e59ebb87c05128dd5571eb7b2ca1a Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Tue, 2 Sep 2014 08:08:03 -0400 Subject: [PATCH] Cleanup - this renderer is so pretty --- src/main/java/mekanism/client/render/CTM.java | 144 ++++++++++++++++-- .../client/render/block/TextureSubmap.java | 4 +- src/main/java/mekanism/common/CTMData.java | 2 + 3 files changed, 139 insertions(+), 11 deletions(-) diff --git a/src/main/java/mekanism/client/render/CTM.java b/src/main/java/mekanism/client/render/CTM.java index 2af53ba90..426b0f587 100644 --- a/src/main/java/mekanism/client/render/CTM.java +++ b/src/main/java/mekanism/client/render/CTM.java @@ -93,99 +93,142 @@ public class CTM public static int getTexture(IBlockAccess world, int x, int y, int z, int side, HashMap> blockMetas) { if(world == null) + { return 0; + } int texture = 0; boolean b[] = new boolean[6]; + if(side <= 1) { b[0] = isConnected(world, x - 1, y, z, side, blockMetas); b[1] = isConnected(world, x + 1, y, z, side, blockMetas); b[2] = isConnected(world, x, y, z + 1, side, blockMetas); b[3] = isConnected(world, x, y, z - 1, side, blockMetas); - } else if(side == 2) + } + else if(side == 2) { b[0] = isConnected(world, x + 1, y, z, side, blockMetas); b[1] = isConnected(world, x - 1, y, z, side, blockMetas); b[2] = isConnected(world, x, y - 1, z, side, blockMetas); b[3] = isConnected(world, x, y + 1, z, side, blockMetas); - } else if(side == 3) + } + else if(side == 3) { b[0] = isConnected(world, x - 1, y, z, side, blockMetas); b[1] = isConnected(world, x + 1, y, z, side, blockMetas); b[2] = isConnected(world, x, y - 1, z, side, blockMetas); b[3] = isConnected(world, x, y + 1, z, side, blockMetas); - } else if(side == 4) + } + else if(side == 4) { b[0] = isConnected(world, x, y, z - 1, side, blockMetas); b[1] = isConnected(world, x, y, z + 1, side, blockMetas); b[2] = isConnected(world, x, y - 1, z, side, blockMetas); b[3] = isConnected(world, x, y + 1, z, side, blockMetas); - } else if(side == 5) + } + else if(side == 5) { b[0] = isConnected(world, x, y, z + 1, side, blockMetas); b[1] = isConnected(world, x, y, z - 1, side, blockMetas); b[2] = isConnected(world, x, y - 1, z, side, blockMetas); b[3] = isConnected(world, x, y + 1, z, side, blockMetas); } + 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, blockMetas); b2[1] = !isConnected(world, x - 1, y, z + 1, side, blockMetas); b2[2] = !isConnected(world, x + 1, y, z - 1, side, blockMetas); b2[3] = !isConnected(world, x - 1, y, z - 1, side, blockMetas); - } else if(side == 2) + } + else if(side == 2) { b2[0] = !isConnected(world, x - 1, y - 1, z, side, blockMetas); b2[1] = !isConnected(world, x + 1, y - 1, z, side, blockMetas); b2[2] = !isConnected(world, x - 1, y + 1, z, side, blockMetas); b2[3] = !isConnected(world, x + 1, y + 1, z, side, blockMetas); - } else if(side == 3) + } + else if(side == 3) { b2[0] = !isConnected(world, x + 1, y - 1, z, side, blockMetas); b2[1] = !isConnected(world, x - 1, y - 1, z, side, blockMetas); b2[2] = !isConnected(world, x + 1, y + 1, z, side, blockMetas); b2[3] = !isConnected(world, x - 1, y + 1, z, side, blockMetas); - } else if(side == 4) + } + else if(side == 4) { b2[0] = !isConnected(world, x, y - 1, z + 1, side, blockMetas); b2[1] = !isConnected(world, x, y - 1, z - 1, side, blockMetas); b2[2] = !isConnected(world, x, y + 1, z + 1, side, blockMetas); b2[3] = !isConnected(world, x, y + 1, z - 1, side, blockMetas); - } else if(side == 5) + } + else if(side == 5) { b2[0] = !isConnected(world, x, y - 1, z - 1, side, blockMetas); b2[1] = !isConnected(world, x, y - 1, z + 1, side, blockMetas); @@ -194,76 +237,159 @@ public class CTM } 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; } diff --git a/src/main/java/mekanism/client/render/block/TextureSubmap.java b/src/main/java/mekanism/client/render/block/TextureSubmap.java index 2ac629774..f71c24470 100644 --- a/src/main/java/mekanism/client/render/block/TextureSubmap.java +++ b/src/main/java/mekanism/client/render/block/TextureSubmap.java @@ -13,7 +13,9 @@ import net.minecraftforge.common.MinecraftForge; public class TextureSubmap { public int width, height; + public IIcon icon; + public IIcon icons[]; public TextureSubmap(IIcon i, int w, int h) @@ -29,7 +31,6 @@ public class TextureSubmap @SubscribeEvent public void TexturesStitched(TextureStitchEvent.Post event) { - for(int x = 0; x < width; x++) { for(int y = 0; y < height; y++) @@ -38,5 +39,4 @@ public class TextureSubmap } } } - } diff --git a/src/main/java/mekanism/common/CTMData.java b/src/main/java/mekanism/common/CTMData.java index 239626b1e..d3df03750 100644 --- a/src/main/java/mekanism/common/CTMData.java +++ b/src/main/java/mekanism/common/CTMData.java @@ -87,6 +87,7 @@ public class CTMData { return sideOverrides[side]; } + return mainTextureData; } @@ -123,6 +124,7 @@ public class CTMData { valid |= entry.getKey().equals(coordBlock) && entry.getValue().contains(coordMeta); } + return !valid; }