Make the rendering of Induction Matrix internals a bit nicer.

This commit is contained in:
Ben Spiers 2015-03-18 01:32:35 +00:00
parent 60a32d44f6
commit 4e3999ea9c
4 changed files with 114 additions and 128 deletions

View file

@ -81,14 +81,14 @@ public class CTM
{},
};
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas)
public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas, boolean convexConnections)
{
int index = getTexture(world, x, y, z, side, blockMetas);
int index = getTexture(world, x, y, z, side, blockMetas, convexConnections);
return submaps[index];
}
public static int getTexture(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas)
public static int getTexture(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas, boolean convexConnections)
{
if(world == null)
{
@ -98,157 +98,135 @@ public class CTM
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)
b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections);
b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections);
b[2] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections);
b[3] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections);
} 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)
b[0] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections);
b[1] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections);
} 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)
b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections);
b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections);
} 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)
b[0] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections);
b[1] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections);
} 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);
b[0] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections);
b[1] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections);
b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections);
b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections);
}
if(b[0] & !b[1] & !b[2] & !b[3])
{
texture = 3;
}
else if(!b[0] & b[1] & !b[2] & !b[3])
} else if(!b[0] & b[1] & !b[2] & !b[3])
{
texture = 1;
}
else if(!b[0] & !b[1] & b[2] & !b[3])
} else if(!b[0] & !b[1] & b[2] & !b[3])
{
texture = 16;
}
else if(!b[0] & !b[1] & !b[2] & b[3])
} else if(!b[0] & !b[1] & !b[2] & b[3])
{
texture = 48;
}
else if(b[0] & b[1] & !b[2] & !b[3])
} else if(b[0] & b[1] & !b[2] & !b[3])
{
texture = 2;
}
else if(!b[0] & !b[1] & b[2] & b[3])
} else if(!b[0] & !b[1] & b[2] & b[3])
{
texture = 32;
}
else if(b[0] & !b[1] & b[2] & !b[3])
} else if(b[0] & !b[1] & b[2] & !b[3])
{
texture = 19;
}
else if(b[0] & !b[1] & !b[2] & b[3])
} else if(b[0] & !b[1] & !b[2] & b[3])
{
texture = 51;
}
else if(!b[0] & b[1] & b[2] & !b[3])
} else if(!b[0] & b[1] & b[2] & !b[3])
{
texture = 17;
}
else if(!b[0] & b[1] & !b[2] & b[3])
} else if(!b[0] & b[1] & !b[2] & b[3])
{
texture = 49;
}
else if(!b[0] & b[1] & b[2] & b[3])
} else if(!b[0] & b[1] & b[2] & b[3])
{
texture = 33;
}
else if(b[0] & !b[1] & b[2] & b[3])
} else if(b[0] & !b[1] & b[2] & b[3])
{
texture = 35;
}
else if(b[0] & b[1] & !b[2] & b[3])
} else if(b[0] & b[1] & !b[2] & b[3])
{
texture = 50;
}
else if(b[0] & b[1] & b[2] & !b[3])
} else if(b[0] & b[1] & b[2] & !b[3])
{
texture = 18;
}
else if(b[0] & b[1] & b[2] & b[3])
} 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)
b2[0] = !isConnected(world, x + 1, y, z + 1, side, blockMetas, convexConnections);
b2[1] = !isConnected(world, x - 1, y, z + 1, side, blockMetas, convexConnections);
b2[2] = !isConnected(world, x + 1, y, z - 1, side, blockMetas, convexConnections);
b2[3] = !isConnected(world, x - 1, y, z - 1, side, blockMetas, convexConnections);
} 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)
b2[0] = !isConnected(world, x - 1, y - 1, z, side, blockMetas, convexConnections);
b2[1] = !isConnected(world, x + 1, y - 1, z, side, blockMetas, convexConnections);
b2[2] = !isConnected(world, x - 1, y + 1, z, side, blockMetas, convexConnections);
b2[3] = !isConnected(world, x + 1, y + 1, z, side, blockMetas, convexConnections);
} 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)
b2[0] = !isConnected(world, x + 1, y - 1, z, side, blockMetas, convexConnections);
b2[1] = !isConnected(world, x - 1, y - 1, z, side, blockMetas, convexConnections);
b2[2] = !isConnected(world, x + 1, y + 1, z, side, blockMetas, convexConnections);
b2[3] = !isConnected(world, x - 1, y + 1, z, side, blockMetas, convexConnections);
} 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)
b2[0] = !isConnected(world, x, y - 1, z + 1, side, blockMetas, convexConnections);
b2[1] = !isConnected(world, x, y - 1, z - 1, side, blockMetas, convexConnections);
b2[2] = !isConnected(world, x, y + 1, z + 1, side, blockMetas, convexConnections);
b2[3] = !isConnected(world, x, y + 1, z - 1, side, blockMetas, convexConnections);
} 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);
b2[2] = !isConnected(world, x, y + 1, z - 1, side, blockMetas);
b2[3] = !isConnected(world, x, y + 1, z + 1, side, blockMetas);
b2[0] = !isConnected(world, x, y - 1, z - 1, side, blockMetas, convexConnections);
b2[1] = !isConnected(world, x, y - 1, z + 1, side, blockMetas, convexConnections);
b2[2] = !isConnected(world, x, y + 1, z - 1, side, blockMetas, convexConnections);
b2[3] = !isConnected(world, x, y + 1, z + 1, side, blockMetas, convexConnections);
}
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;
@ -258,17 +236,17 @@ public class CTM
{
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;
@ -278,17 +256,17 @@ public class CTM
{
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;
@ -298,17 +276,17 @@ public class CTM
{
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;
@ -323,17 +301,17 @@ public class CTM
{
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;
@ -343,17 +321,17 @@ public class CTM
{
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;
@ -372,26 +350,26 @@ public class CTM
{
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, HashMap<Block, List<Integer>> blockMetas)
public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, HashMap<Block, List<Integer>> blockMetas, boolean convexConnections)
{
int x2 = x, y2 = y, z2 = z;
@ -430,7 +408,7 @@ public class CTM
{
validBlockMeta1 |= block1.equals(entry.getKey()) && entry.getValue().contains(meta1);
invalidBlockMeta2 &= !(block2.equals(entry.getKey()) && entry.getValue().contains(meta2));
invalidBlockMeta2 &= convexConnections || !(block2.equals(entry.getKey()) && entry.getValue().contains(meta2));
}
return validBlockMeta1 && invalidBlockMeta2;

View file

@ -149,7 +149,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9);
side(1, 14, 9, 23, tex[0], false, 4);
@ -172,7 +172,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11);
side(11, 21, 3, 15, tex[3], false, 5);
@ -195,7 +195,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8);
side(2, 15, 8, 22, tex[0], false, 2);
@ -219,7 +219,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10);
side(17, 4, 20, 10, tex[2], false, 3);
@ -242,7 +242,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13);
side(13, 21, 7, 20, tex[3], true, 0);
@ -265,7 +265,7 @@ public class RenderBlocksCTM extends RenderBlocks
tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV());
}
else {
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1, dataCTM.acceptableBlockMetas);
int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections);
setupSides(2, 1, 5, 6, 22, 23, 24, 25, 12);
side(12, 24, 6, 25, tex[3], false, 1);

View file

@ -27,6 +27,8 @@ public class CTMData
public int facing;
public boolean renderConvexConnections = false;
public CTMData(String textureName, Block block, List<Integer> connectableMeta)
{
mainTextureData = new CTMTextureData(textureName);
@ -113,6 +115,12 @@ public class CTMData
return this;
}
public CTMData setRenderConvexConnections()
{
renderConvexConnections = true;
return this;
}
@SideOnly(Side.CLIENT)
public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side)
{

View file

@ -181,14 +181,14 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon
ctms[1][0] = new CTMData("ctm/InductionCasing", this, Arrays.asList(1, 2)).registerIcons(register);
ctms[2][0] = new CTMData("ctm/InductionPortInput", this, Arrays.asList(1, 2)).registerIcons(register);
ctms[2][1] = new CTMData("ctm/InductionPortOutput", this, Arrays.asList(1, 2)).registerIcons(register);
ctms[3][0] = new CTMData("ctm/InductionCellBasic", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[3][1] = new CTMData("ctm/InductionCellAdvanced", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[3][2] = new CTMData("ctm/InductionCellElite", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[3][3] = new CTMData("ctm/InductionCellUltimate", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[4][0] = new CTMData("ctm/InductionProviderBasic", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[4][1] = new CTMData("ctm/InductionProviderAdvanced", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[4][2] = new CTMData("ctm/InductionProviderElite", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[4][3] = new CTMData("ctm/InductionProviderUltimate", this, Arrays.asList(3, 4)).registerIcons(register);
ctms[3][0] = new CTMData("ctm/InductionCellBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[3][1] = new CTMData("ctm/InductionCellAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[3][2] = new CTMData("ctm/InductionCellElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[3][3] = new CTMData("ctm/InductionCellUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[4][0] = new CTMData("ctm/InductionProviderBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[4][1] = new CTMData("ctm/InductionProviderAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[4][2] = new CTMData("ctm/InductionProviderElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
ctms[4][3] = new CTMData("ctm/InductionProviderUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections();
//TODO @unpairedbracket, mind fixing this?
icons[0][0] = ctms[0][0].mainTextureData.icon;