Compare commits

...

3 Commits

Author SHA1 Message Date
Boblet
24f41d33c9 chat i'm gonna rizz him up 2026-03-03 15:53:58 +01:00
Boblet
fc714dd6c8 conduit rendering helper crap 2026-03-03 11:51:39 +01:00
Boblet
a1008db304 Just remember the bit about bleeding anuses, and you'll be fine. 2026-03-02 11:43:06 +01:00
12 changed files with 435 additions and 86 deletions

View File

@ -24,6 +24,7 @@ import com.hbm.blocks.test.*;
import com.hbm.blocks.turret.*; import com.hbm.blocks.turret.*;
import com.hbm.hrist.BlockConduitBend; import com.hbm.hrist.BlockConduitBend;
import com.hbm.hrist.BlockConduitStraight; import com.hbm.hrist.BlockConduitStraight;
import com.hbm.hrist.BlockConduitSwitch;
import com.hbm.items.block.*; import com.hbm.items.block.*;
import com.hbm.items.bomb.ItemPrototypeBlock; import com.hbm.items.bomb.ItemPrototypeBlock;
import com.hbm.items.special.ItemOreBlock; import com.hbm.items.special.ItemOreBlock;
@ -1240,6 +1241,7 @@ public class ModBlocks {
public static Block conduit_straight; public static Block conduit_straight;
public static Block conduit_bend; public static Block conduit_bend;
public static Block conduit_switch;
private static void initializeBlock() { private static void initializeBlock() {
@ -2392,8 +2394,9 @@ public class ModBlocks {
logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block"); logic_block = new LogicBlock().setBlockName("logic_block").setBlockTextureName(RefStrings.MODID + ":logic_block");
conduit_straight = new BlockConduitStraight().setBlockName("conduit_straight").setBlockTextureName(RefStrings.MODID + ":block_steel"); conduit_straight = new BlockConduitStraight().setBlockName("conduit_straight").setBlockTextureName(RefStrings.MODID + ":rail_standard");
conduit_bend = new BlockConduitBend().setBlockName("conduit_bend").setBlockTextureName(RefStrings.MODID + ":block_steel"); conduit_bend = new BlockConduitBend().setBlockName("conduit_bend").setBlockTextureName(RefStrings.MODID + ":rail_standard");
conduit_switch = new BlockConduitSwitch().setBlockName("conduit_switch").setBlockTextureName(RefStrings.MODID + ":rail_standard");
} }
private static void registerBlock() { private static void registerBlock() {
@ -3550,6 +3553,7 @@ public class ModBlocks {
register(conduit_straight); register(conduit_straight);
register(conduit_bend); register(conduit_bend);
register(conduit_switch);
} }
private static void register(Block b) { private static void register(Block b) {

View File

@ -0,0 +1,57 @@
package com.hbm.hrist;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockDummyable;
import com.hbm.render.block.ISBRHUniversal;
import com.hbm.render.util.RenderBlocksNT;
import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
//you can think of it like a pipeline
public abstract class BlockConduitBase extends BlockDummyable implements ISBRHUniversal {
public BlockConduitBase() {
super(Material.ground);
}
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
@Override public int getRenderType() { return ISBRHUniversal.renderID; }
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 12) {
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
super.breakBlock(world, x, y, z, b, meta);
if(meta >= 12) {
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
}
}
public abstract ConduitPiece getPiece(World world, int x, int y, int z, int meta);
@Override
public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) {
GL11.glPushMatrix();
RenderBlocks renderer = (RenderBlocks) renderBlocks;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
renderer.setRenderBounds(0, 0, 0, 1, 1, 1); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
GL11.glPopMatrix();
}
}

View File

@ -1,47 +1,21 @@
package com.hbm.hrist; package com.hbm.hrist;
import com.hbm.blocks.BlockDummyable;
import com.hbm.hrist.ConduitPiece.ConnectionDefinition; import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.Vec3NT;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
// you can think of it like a pipeline public class BlockConduitBend extends BlockConduitBase {
public class BlockConduitBend extends BlockDummyable {
public BlockConduitBend() {
super(Material.ground);
}
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
@Override public int[] getDimensions() { return new int[] {0, 0, 4, 0, 4, 0}; } @Override public int[] getDimensions() { return new int[] {0, 0, 4, 0, 4, 0}; }
@Override public int getOffset() { return 0; } @Override public int getOffset() { return 0; }
@Override @Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 12) {
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
super.breakBlock(world, x, y, z, b, meta);
if(meta >= 12) {
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
}
}
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) { public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10); ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
@ -53,4 +27,39 @@ public class BlockConduitBend extends BlockDummyable {
z + 0.5 + rot.offsetZ * 4.5 - dir.offsetZ * 3.5, rot); z + 0.5 + rot.offsetZ * 4.5 - dir.offsetZ * 3.5, rot);
return new ConduitPiece(new ConnectionDefinition(d0, d1)); return new ConduitPiece(new ConnectionDefinition(d0, d1));
} }
@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;
}
} }

View File

@ -1,47 +1,20 @@
package com.hbm.hrist; package com.hbm.hrist;
import com.hbm.blocks.BlockDummyable;
import com.hbm.hrist.ConduitPiece.ConnectionDefinition; import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
// you can think of it like a pipeline public class BlockConduitStraight extends BlockConduitBase {
public class BlockConduitStraight extends BlockDummyable {
public BlockConduitStraight() {
super(Material.ground);
}
@Override public TileEntity createNewTileEntity(World world, int meta) { return null; }
@Override public int[] getDimensions() { return new int[] {0, 0, 2, 2, 1, 0}; } @Override public int[] getDimensions() { return new int[] {0, 0, 2, 2, 1, 0}; }
@Override public int getOffset() { return 2; } @Override public int getOffset() { return 2; }
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 12) {
ConduitPiece piece = this.getPiece(world, x, y, z, meta);
ConduitSpace.pushPiece(world, piece, new BlockPos(x, y, z));
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int meta) {
super.breakBlock(world, x, y, z, b, meta);
if(meta >= 12) {
ConduitSpace.popPiece(world, new BlockPos(x, y, z));
}
}
@Override
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) { public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10); ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
@ -52,5 +25,30 @@ public class BlockConduitStraight extends BlockDummyable {
x + 0.5 + rot.offsetX * 0.5 - dir.offsetX * 2.5, y, x + 0.5 + rot.offsetX * 0.5 - dir.offsetX * 2.5, y,
z + 0.5 + rot.offsetZ * 0.5 - dir.offsetZ * 2.5, dir.getOpposite()); z + 0.5 + rot.offsetZ * 0.5 - dir.offsetZ * 2.5, dir.getOpposite());
return new ConduitPiece(new ConnectionDefinition(d0, d1)); return new ConduitPiece(new ConnectionDefinition(d0, d1));
}
@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;
for(int i = -2; i <= 2; i++)
ConduitRenderUtil.renderSupport(Tessellator.instance, blockIcon, x + 0.5 + dir.offsetX * i + rot.offsetX * 0.5, y, z + 0.5 + dir.offsetZ * i + rot.offsetZ * 0.5, angle);
ConduitRenderUtil.renderSteel(Tessellator.instance, blockIcon,
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.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;
} }
} }

View File

@ -0,0 +1,86 @@
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;
public class BlockConduitSwitch extends BlockConduitBase {
@Override public int[] getDimensions() { return new int[] {0, 0, 4, 0, 4, 3}; }
@Override public int getOffset() { return 0; }
@Override
public ConduitPiece getPiece(World world, int x, int y, int z, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
DirPos d0 = new DirPos(
x + 0.5 + rot.offsetX * 0.5 + dir.offsetX * 0.5, y,
z + 0.5 + rot.offsetZ * 0.5 + dir.offsetZ * 0.5, dir);
DirPos d1 = new DirPos(
x + 0.5 + rot.offsetX * 4.5 - dir.offsetX * 3.5, y,
z + 0.5 + rot.offsetZ * 4.5 - dir.offsetZ * 3.5, rot);
DirPos d2 = new DirPos(
x + 0.5 + rot.offsetX * 0.5 + dir.offsetX * 0.5, y,
z + 0.5 + rot.offsetZ * 0.5 + dir.offsetZ * 0.5, dir);
DirPos d3 = new DirPos(
x + 0.5 - rot.offsetX * 3.5 - dir.offsetX * 3.5, y,
z + 0.5 - rot.offsetZ * 3.5 - dir.offsetZ * 3.5, rot.getOpposite());
return new ConduitPiece(new ConnectionDefinition(d0, d1), new ConnectionDefinition(d2, d3));
}
@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;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Map.Entry;
import com.hbm.hrist.ConduitPiece.ConnectionDefinition; import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
import com.hbm.hrist.ConduitSpace.ConduitWorld; import com.hbm.hrist.ConduitSpace.ConduitWorld;
import com.hbm.util.BobMathUtil;
import com.hbm.util.ParticleUtil; import com.hbm.util.ParticleUtil;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
@ -35,7 +36,7 @@ public class ConDbg {
int color = line.hashCode() & 0xFFFFFF; int color = line.hashCode() & 0xFFFFFF;
ParticleUtil.spawnDroneLine(world, x, y, z, dx, dy, dz, !line.valid ? 0xff0000 : color, true); ParticleUtil.spawnDroneLine(world, x, y, z, dx, dy, dz, !line.valid ? (BobMathUtil.getBlink() ? 0xff0000 : 0x000000) : color, true);
} }
} }
} }

View File

@ -14,7 +14,7 @@ public class ConduitLine {
public World world; public World world;
protected boolean valid = true; protected boolean valid = true;
public LineEndpoint[] connectedTo = new LineEndpoint[2]; // a sausage always has two ends public LineEndpoint[] connectedTo = new LineEndpoint[2]; // a sausage always has two ends
public Set<ConnectionDefinition> constructedFrom = new HashSet(); private Set<ConnectionDefinition> constructedFrom = new HashSet();
public ConnectionStatus state = ConnectionStatus.ONLINE; public ConnectionStatus state = ConnectionStatus.ONLINE;
public double cachedDistance = 0; public double cachedDistance = 0;
@ -24,6 +24,23 @@ public class ConduitLine {
this.world = world; this.world = world;
} }
public int getDefCount() {
return this.constructedFrom.size();
}
public void join(ConnectionDefinition def) {
this.constructedFrom.add(def);
this.setChanged();
}
public void absorb(ConduitLine smallerLine) {
for(ConnectionDefinition smallerDef : smallerLine.constructedFrom) {
smallerDef.setLine(this);
}
smallerLine.constructedFrom.clear();
smallerLine.invalidate();
}
public void setChanged() { this.hasChanged = true; } public void setChanged() { this.hasChanged = true; }
public double getDistance() { public double getDistance() {

View File

@ -63,6 +63,7 @@ public class ConduitPiece {
public void setLine(ConduitLine line) { public void setLine(ConduitLine line) {
this.liveConnection = line; this.liveConnection = line;
if(line != null) line.join(this);
} }
} }
} }

View File

@ -0,0 +1,172 @@
package com.hbm.hrist;
import com.hbm.interfaces.NotableComments;
import com.hbm.util.Vec3NT;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
@NotableComments
public class ConduitRenderUtil {
// public cum rags
private static Vec3NT vec = new Vec3NT(0, 0, 0);
private static double[][] v = new double[4][3];
public static void renderSupport(Tessellator tess, IIcon icon, double x, double y, double z, double rotation) {
double minU = icon.getMinU();
double minV = icon.getMinV();
double pu = (icon.getMaxU() - icon.getMinU()) / 32D;
double pv = (icon.getMaxV() - icon.getMinV()) / 32D;
// work smort, not hort
vec.setTurn(01, 0, 00.1875, rotation).add(x, y, z).copyToArray(v[0]);
vec.setTurn(01, 0, -0.1875, rotation).add(x, y, z).copyToArray(v[1]);
vec.setTurn(-1, 0, -0.1875, rotation).add(x, y, z).copyToArray(v[2]);
vec.setTurn(-1, 0, 00.1875, rotation).add(x, y, z).copyToArray(v[3]);
setBrightnessFromNormals(tess, 0F, 1F, 0F);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 0, minV + pv * 32);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 6, minV + pv * 32);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 00);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 0, minV + pv * 00);
setBrightnessFromNormals(tess, 0F, -1F, 0F);
tess.addVertexWithUV(v[1][0], v[1][1], v[1][2], minU + pu * 0, minV + pv * 32);
tess.addVertexWithUV(v[0][0], v[0][1], v[0][2], minU + pu * 6, minV + pv * 32);
tess.addVertexWithUV(v[3][0], v[3][1], v[3][2], minU + pu * 6, minV + pv * 00);
tess.addVertexWithUV(v[2][0], v[2][1], v[2][2], minU + pu * 0, minV + pv * 00);
vec.setTurn(1, 0, 0, rotation).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 0, minV + pv * 0);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 6, minV + pv * 0);
tess.addVertexWithUV(v[0][0], v[0][1] + 000000, v[0][2], minU + pu * 6, minV + pv * 1);
tess.addVertexWithUV(v[1][0], v[1][1] + 000000, v[1][2], minU + pu * 0, minV + pv * 1);
vec.setTurn(1, 0, 0, rotation + 180).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 0, minV + pv * 0);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 0);
tess.addVertexWithUV(v[2][0], v[2][1] + 000000, v[2][2], minU + pu * 6, minV + pv * 1);
tess.addVertexWithUV(v[3][0], v[3][1] + 000000, v[3][2], minU + pu * 0, minV + pv * 1);
vec.setTurn(1, 0, 0, rotation + 90).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 6, minV + pv * 00);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 6, minV + pv * 32);
tess.addVertexWithUV(v[1][0], v[1][1] + 000000, v[1][2], minU + pu * 7, minV + pv * 32);
tess.addVertexWithUV(v[2][0], v[2][1] + 000000, v[2][2], minU + pu * 7, minV + pv * 00);
vec.setTurn(1, 0, 0, rotation + 270).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 6, minV + pv * 00);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 6, minV + pv * 32);
tess.addVertexWithUV(v[3][0], v[3][1] + 000000, v[3][2], minU + pu * 7, minV + pv * 32);
tess.addVertexWithUV(v[0][0], v[0][1] + 000000, v[0][2], minU + pu * 7, minV + pv * 00);
for(int i = 0; i < 2; i++) {
vec.setTurn(0.9375 - i * 1.5625, 0, 00.0625, rotation).add(x, y, z).copyToArray(v[0]);
vec.setTurn(0.9375 - i * 1.5625, 0, -0.0625, rotation).add(x, y, z).copyToArray(v[1]);
vec.setTurn(0.6250 - i * 1.5625, 0, -0.0625, rotation).add(x, y, z).copyToArray(v[2]);
vec.setTurn(0.6250 - i * 1.5625, 0, 00.0625, rotation).add(x, y, z).copyToArray(v[3]);
setBrightnessFromNormals(tess, 0F, 1F, 0F);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.125, v[0][2], minU + pu * 19, minV + pv * 31);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.125, v[1][2], minU + pu * 19, minV + pv * 29);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.125, v[2][2], minU + pu * 14, minV + pv * 29);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.125, v[3][2], minU + pu * 14, minV + pv * 31);
vec.setTurn(1, 0, 0, rotation).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1250, v[1][2], minU + pu * 14, minV + pv * 29);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1250, v[0][2], minU + pu * 14, minV + pv * 31);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 13, minV + pv * 31);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 13, minV + pv * 29);
vec.setTurn(1, 0, 0, rotation + 180).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1250, v[3][2], minU + pu * 14, minV + pv * 29);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1250, v[2][2], minU + pu * 14, minV + pv * 31);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 13, minV + pv * 31);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 13, minV + pv * 29);
vec.setTurn(1, 0, 0, rotation + 90).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1250, v[2][2], minU + pu * 14, minV + pv * 31);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1250, v[1][2], minU + pu * 19, minV + pv * 31);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 19, minV + pv * 32);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 14, minV + pv * 32);
vec.setTurn(1, 0, 0, rotation + 270).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1250, v[0][2], minU + pu * 14, minV + pv * 31);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1250, v[3][2], minU + pu * 19, minV + pv * 31);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 19, minV + pv * 32);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 14, minV + pv * 32);
}
}
public static void renderSteel(Tessellator tess, IIcon icon, double x0, double y0, double z0, double r0, double x1, double y1, double z1, double r1) {
double minU = icon.getMinU();
double minV = icon.getMinV();
double pu = (icon.getMaxU() - icon.getMinU()) / 32D;
double pv = (icon.getMaxV() - icon.getMinV()) / 32D;
double avg = (r0 + r1) / 2;
vec.setTurn(-0.03125, 0, 0, r0).add(x0, y0, z0).copyToArray(v[0]);
vec.setTurn(00.03125, 0, 0, r0).add(x0, y0, z0).copyToArray(v[1]);
vec.setTurn(00.03125, 0, 0, r1).add(x1, y1, z1).copyToArray(v[2]);
vec.setTurn(-0.03125, 0, 0, r1).add(x1, y1, z1).copyToArray(v[3]);
setBrightnessFromNormals(tess, 0F, 1F, 0F);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 10, minV + pv * 32);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 11, minV + pv * 32);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 11, minV + pv * 16);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 10, minV + pv * 16);
setBrightnessFromNormals(tess, 0F, -1F, 0F);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 7, minV + pv * 32);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 8, minV + pv * 32);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 8, minV + pv * 16);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 7, minV + pv * 16);
vec.setTurn(1, 0, 0, avg).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 10, minV + pv * 16);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 11, minV + pv * 16);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 11, minV + pv * 14);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 10, minV + pv * 14);
vec.setTurn(1, 0, 0, avg + 180).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 10, minV + pv * 16);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 11, minV + pv * 16);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 11, minV + pv * 14);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 10, minV + pv * 14);
vec.setTurn(1, 0, 0, avg + 90).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.1875, v[2][2], minU + pu * 10, minV + pv * 16);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.1875, v[1][2], minU + pu * 10, minV + pv * 32);
tess.addVertexWithUV(v[1][0], v[1][1] + 0.0625, v[1][2], minU + pu * 8, minV + pv * 32);
tess.addVertexWithUV(v[2][0], v[2][1] + 0.0625, v[2][2], minU + pu * 8, minV + pv * 16);
vec.setTurn(1, 0, 0, avg + 270).normalizeSelf();
setBrightnessFromNormals(tess, vec.xCoord, vec.yCoord, vec.zCoord);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.1875, v[0][2], minU + pu * 11, minV + pv * 16);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.1875, v[3][2], minU + pu * 11, minV + pv * 32);
tess.addVertexWithUV(v[3][0], v[3][1] + 0.0625, v[3][2], minU + pu * 13, minV + pv * 32);
tess.addVertexWithUV(v[0][0], v[0][1] + 0.0625, v[0][2], minU + pu * 13, minV + pv * 16);
}
public static void setBrightnessFromNormals(Tessellator tess, double x, double y, double z) {
float brightness = ((float) y + 0.7F) * 0.9F - (float) Math.abs(x) * 0.1F + (float) Math.abs(z) * 0.1F;
if(brightness < 0.45F) brightness = 0.45F;
tess.setNormal((float) x, (float) y, (float) z);
tess.setColorOpaque_F(brightness, brightness, brightness);
}
}

View File

@ -7,12 +7,14 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import com.hbm.hrist.ConduitPiece.ConnectionDefinition; import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
import com.hbm.interfaces.NotableComments;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.world.World; import net.minecraft.world.World;
/// ROBUR PER UNITATEM /// /// ROBUR PER UNITATEM ///
@NotableComments
public class ConduitSpace { public class ConduitSpace {
public static Map<World, ConduitWorld> worlds = new HashMap(); public static Map<World, ConduitWorld> worlds = new HashMap();
@ -64,8 +66,6 @@ public class ConduitSpace {
connections.put(def.connectors[1], piece); connections.put(def.connectors[1], piece);
orphans.add(def); orphans.add(def);
} }
for(ConnectionDefinition con : piece.definitions) orphans.add(con);
} }
public void pop(ConduitPiece piece, BlockPos core) { public void pop(ConduitPiece piece, BlockPos core) {
@ -96,40 +96,32 @@ public class ConduitSpace {
if(connectedPiece == null) continue; // if no piece is actually connected, skip if(connectedPiece == null) continue; // if no piece is actually connected, skip
if(connectedPiece == orphan.parent) continue; // no self-fellating if(connectedPiece == orphan.parent) continue; // no self-fellating
if(connectedPiece.hasMultipleConnections(connection)) continue; // if this connection leads to a switch, skip if(connectedPiece.hasMultipleConnections(connection)) continue; // if this connection leads to a switch, skip
if(orphan.parent.hasMultipleConnections(pos)) continue; // if this connection leads to a switch, skip
for(ConnectionDefinition connectedDef : connectedPiece.definitions) { for(ConnectionDefinition connectedDef : connectedPiece.definitions) {
ConduitLine connectedLine = connectedDef.getLine(); ConduitLine connectedLine = connectedDef.getLine();
if(connectedLine == null) continue; if(connectedLine == null) continue;
if(connectedDef == orphan) continue;
line = orphan.getLine(); line = orphan.getLine();
// if the current line is null // 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)) { if(connectedDef.connectors[0].equals(connection) || connectedDef.connectors[1].equals(connection)) {
orphan.setLine(connectedLine); orphan.setLine(connectedLine);
connectedLine.constructedFrom.add(orphan); break;
} }
// if not, merge // if not, merge
} else { } else if(line.isValid()) {
// larger one eats the smaller one for performance // larger one eats the smaller one for performance
ConduitLine larger = line.constructedFrom.size() > connectedLine.constructedFrom.size() ? line : connectedLine; ConduitLine larger = line.getDefCount() > connectedLine.getDefCount() ? line : connectedLine;
ConduitLine smaller = line.constructedFrom.size() > connectedLine.constructedFrom.size() ? connectedLine : line; ConduitLine smaller = larger == connectedLine ? line : connectedLine;
larger.absorb(smaller);
larger.constructedFrom.addAll(smaller.constructedFrom);
for(ConnectionDefinition smallerDef : smaller.constructedFrom) {
smallerDef.setLine(larger);
}
smaller.constructedFrom.clear();
larger.setChanged();
smaller.invalidate();
} }
} }
} }
if(orphan.getLine() == null) { if(orphan.getLine() == null || !orphan.getLine().isValid()) {
ConduitLine newLine = new ConduitLine(world); orphan.setLine(new ConduitLine(world));
orphan.setLine(newLine);
newLine.constructedFrom.add(orphan);
newLine.setChanged();
} }
} }

View File

@ -64,6 +64,18 @@ public class Vec3NT extends Vec3 {
this.zCoord = z; this.zCoord = z;
return this; return this;
} }
/** Sets components, then rotates around the Y axis (in degrees) */
public Vec3NT setTurn(double x, double y, double z, double rot) {
return this.setComponents(x, y, z).rotateAroundYDeg(rot);
}
/** Does what it says, i.e. requires a double array with a length of at least 3 and copies the components into the first three fields */
public void copyToArray(double[] array) {
array[0] = this.xCoord;
array[1] = this.yCoord;
array[2] = this.zCoord;
}
public Vec3NT rotateAroundXRad(double alpha) { public Vec3NT rotateAroundXRad(double alpha) {
double cos = Math.cos(alpha); double cos = Math.cos(alpha);

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B