diff --git a/src/main/java/com/hbm/hrist/BlockConduitBend.java b/src/main/java/com/hbm/hrist/BlockConduitBend.java index 678b91e88..abe1dc9e7 100644 --- a/src/main/java/com/hbm/hrist/BlockConduitBend.java +++ b/src/main/java/com/hbm/hrist/BlockConduitBend.java @@ -1,9 +1,11 @@ package com.hbm.hrist; import com.hbm.hrist.ConduitPiece.ConnectionDefinition; +import com.hbm.util.Vec3NT; import com.hbm.util.fauxpointtwelve.DirPos; import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -28,6 +30,36 @@ public class BlockConduitBend extends BlockConduitBase { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) { + int meta = world.getBlockMetadata(x, y, z); + if(meta >= 12) { + double angle = 0; + ForgeDirection dir = ForgeDirection.getOrientation(meta - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + if(dir == ForgeDirection.NORTH) angle += 0; + if(dir == ForgeDirection.WEST) angle += 90; + if(dir == ForgeDirection.SOUTH) angle += 180; + if(dir == ForgeDirection.EAST) angle += 270; + + double diff = 90D / 5D; + + Vec3NT sv0 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(90); + Vec3NT sv1 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(90 + diff); + Vec3NT supVec = new Vec3NT(3.9375 * dir.offsetX, 0, 3.9375 * dir.offsetZ).rotateAroundYDeg(90 + diff / 2); + double outer = 4.75D + 0.03125D; + double inner = 3.25D - 0.03125D; + double dx = x + 0.5 + dir.offsetX * 0.5 + rot.offsetX * 4.5; + double dz = z + 0.5 + dir.offsetZ * 0.5 + rot.offsetZ * 4.5; + + for(int i = 0; i < 5; i++) { + ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, dx + supVec.xCoord, y, dz + supVec.zCoord, angle + diff / 2); + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx + sv1.xCoord * outer, y, dz + sv1.zCoord * outer, angle + diff, dx + sv0.xCoord * outer, y, dz + sv0.zCoord * outer, angle); + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx + sv1.xCoord * inner, y, dz + sv1.zCoord * inner, angle + diff, dx + sv0.xCoord * inner, y, dz + sv0.zCoord * inner, angle); + supVec.rotateAroundYDeg(diff); + sv0.rotateAroundYDeg(diff); + sv1.rotateAroundYDeg(diff); + angle += diff; + } + } return false; } } diff --git a/src/main/java/com/hbm/hrist/BlockConduitStraight.java b/src/main/java/com/hbm/hrist/BlockConduitStraight.java index e521fbaf0..4528218e9 100644 --- a/src/main/java/com/hbm/hrist/BlockConduitStraight.java +++ b/src/main/java/com/hbm/hrist/BlockConduitStraight.java @@ -46,8 +46,8 @@ public class BlockConduitStraight extends BlockConduitBase { x + 0.5 - dir.offsetX * 2.5 - rot.offsetX * 0.28125, y, z + 0.5 - dir.offsetZ * 2.5 - rot.offsetZ * 0.28125, angle, x + 0.5 + dir.offsetX * 2.5 - rot.offsetX * 0.28125, y, z + 0.5 + dir.offsetZ * 2.5 - rot.offsetZ * 0.28125, angle); ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, - x + 0.5 - dir.offsetX * 2.5 - rot.offsetX * -1.21875, y, z + 0.5 - dir.offsetZ * 2.5 - rot.offsetZ * -1.21875, angle, - x + 0.5 + dir.offsetX * 2.5 - rot.offsetX * -1.21875, y, z + 0.5 + dir.offsetZ * 2.5 - rot.offsetZ * -1.21875, angle); + x + 0.5 - dir.offsetX * 2.5 - rot.offsetX * -1.28125, y, z + 0.5 - dir.offsetZ * 2.5 - rot.offsetZ * -1.28125, angle, + x + 0.5 + dir.offsetX * 2.5 - rot.offsetX * -1.28125, y, z + 0.5 + dir.offsetZ * 2.5 - rot.offsetZ * -1.28125, angle); } return false; } diff --git a/src/main/java/com/hbm/hrist/BlockConduitSwitch.java b/src/main/java/com/hbm/hrist/BlockConduitSwitch.java index cfc47cdf8..2e7ff9c7c 100644 --- a/src/main/java/com/hbm/hrist/BlockConduitSwitch.java +++ b/src/main/java/com/hbm/hrist/BlockConduitSwitch.java @@ -1,9 +1,11 @@ package com.hbm.hrist; import com.hbm.hrist.ConduitPiece.ConnectionDefinition; +import com.hbm.util.Vec3NT; import com.hbm.util.fauxpointtwelve.DirPos; import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -34,6 +36,51 @@ public class BlockConduitSwitch extends BlockConduitBase { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) { + int meta = world.getBlockMetadata(x, y, z); + if(meta >= 12) { + double angle = 0; + ForgeDirection dir = ForgeDirection.getOrientation(meta - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + if(dir == ForgeDirection.NORTH) angle += 0; + if(dir == ForgeDirection.WEST) angle += 90; + if(dir == ForgeDirection.SOUTH) angle += 180; + if(dir == ForgeDirection.EAST) angle += 270; + + double diff = 90D / 5D; + + Vec3NT sv0 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(90); + Vec3NT sv1 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(90 + diff); + Vec3NT sv2 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(-90); + Vec3NT sv3 = new Vec3NT(dir.offsetX, 0, dir.offsetZ).rotateAroundYDeg(-90 - diff); + Vec3NT supVec0 = new Vec3NT(3.9375 * dir.offsetX, 0, 3.9375 * dir.offsetZ).rotateAroundYDeg(90 + diff / 2); + Vec3NT supVec1 = new Vec3NT(3.9375 * dir.offsetX, 0, 3.9375 * dir.offsetZ).rotateAroundYDeg(-90 - diff / 2); + double outer = 4.75D + 0.03125D; + double inner = 3.25D - 0.03125D; + double dx0 = x + 0.5 + dir.offsetX * 0.5 + rot.offsetX * 4.5; + double dz0 = z + 0.5 + dir.offsetZ * 0.5 + rot.offsetZ * 4.5; + double dx1 = x + 0.5 + dir.offsetX * 0.5 - rot.offsetX * 3.5; + double dz1 = z + 0.5 + dir.offsetZ * 0.5 - rot.offsetZ * 3.5; + + ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, dx0 + supVec0.xCoord, y, dz0 + supVec0.zCoord, angle); + + for(int i = 0; i < 5; i++) { + if(i > 1) { + ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, dx0 + supVec0.xCoord, y, dz0 + supVec0.zCoord, angle + diff / 2); + ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, dx1 + supVec1.xCoord, y, dz1 + supVec1.zCoord, -angle - diff / 2); + } + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx0 + sv1.xCoord * outer, y, dz0 + sv1.zCoord * outer, angle + diff, dx0 + sv0.xCoord * outer, y, dz0 + sv0.zCoord * outer, angle); + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx0 + sv1.xCoord * inner, y, dz0 + sv1.zCoord * inner, angle + diff, dx0 + sv0.xCoord * inner, y, dz0 + sv0.zCoord * inner, angle); + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx1 + sv3.xCoord * outer, y, dz1 + sv3.zCoord * outer, -angle - diff, dx1 + sv2.xCoord * outer, y, dz1 + sv2.zCoord * outer, -angle); + ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon, dx1 + sv3.xCoord * inner, y, dz1 + sv3.zCoord * inner, -angle - diff, dx1 + sv2.xCoord * inner, y, dz1 + sv2.zCoord * inner, -angle); + supVec0.rotateAroundYDeg(diff); + supVec1.rotateAroundYDeg(-diff); + sv0.rotateAroundYDeg(diff); + sv1.rotateAroundYDeg(diff); + sv2.rotateAroundYDeg(-diff); + sv3.rotateAroundYDeg(-diff); + angle += diff; + } + } return false; } } diff --git a/src/main/java/com/hbm/hrist/ConDbg.java b/src/main/java/com/hbm/hrist/ConDbg.java index 0871a6609..c5b78c870 100644 --- a/src/main/java/com/hbm/hrist/ConDbg.java +++ b/src/main/java/com/hbm/hrist/ConDbg.java @@ -36,7 +36,7 @@ public class ConDbg { int color = line.hashCode() & 0xFFFFFF; - ParticleUtil.spawnDroneLine(world, x, y, z, dx, dy, dz, !line.valid ? (BobMathUtil.getBlink() ? 0xff0000 : 0xff8000) : color, true); + ParticleUtil.spawnDroneLine(world, x, y, z, dx, dy, dz, !line.valid ? (BobMathUtil.getBlink() ? 0xff0000 : 0x000000) : color, true); } } } diff --git a/src/main/java/com/hbm/hrist/ConduitSpace.java b/src/main/java/com/hbm/hrist/ConduitSpace.java index 7ead9b59e..abad5920c 100644 --- a/src/main/java/com/hbm/hrist/ConduitSpace.java +++ b/src/main/java/com/hbm/hrist/ConduitSpace.java @@ -105,13 +105,13 @@ public class ConduitSpace { line = orphan.getLine(); // if the current line is null - if(line == null || !line.valid) { + if(line == null || !line.isValid()) { if(connectedDef.connectors[0].equals(connection) || connectedDef.connectors[1].equals(connection)) { orphan.setLine(connectedLine); break; } // if not, merge - } else { + } else if(line.isValid()) { // larger one eats the smaller one for performance ConduitLine larger = line.getDefCount() > connectedLine.getDefCount() ? line : connectedLine; ConduitLine smaller = larger == connectedLine ? line : connectedLine; @@ -120,7 +120,7 @@ public class ConduitSpace { } } - if(orphan.getLine() == null) { + if(orphan.getLine() == null || !orphan.getLine().isValid()) { orphan.setLine(new ConduitLine(world)); } }