mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-16 06:35:35 +00:00
Compare commits
3 Commits
f957a0fedf
...
24f41d33c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24f41d33c9 | ||
|
|
fc714dd6c8 | ||
|
|
a1008db304 |
@ -24,6 +24,7 @@ import com.hbm.blocks.test.*;
|
||||
import com.hbm.blocks.turret.*;
|
||||
import com.hbm.hrist.BlockConduitBend;
|
||||
import com.hbm.hrist.BlockConduitStraight;
|
||||
import com.hbm.hrist.BlockConduitSwitch;
|
||||
import com.hbm.items.block.*;
|
||||
import com.hbm.items.bomb.ItemPrototypeBlock;
|
||||
import com.hbm.items.special.ItemOreBlock;
|
||||
@ -1240,6 +1241,7 @@ public class ModBlocks {
|
||||
|
||||
public static Block conduit_straight;
|
||||
public static Block conduit_bend;
|
||||
public static Block conduit_switch;
|
||||
|
||||
private static void initializeBlock() {
|
||||
|
||||
@ -2392,8 +2394,9 @@ public class ModBlocks {
|
||||
|
||||
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_bend = new BlockConduitBend().setBlockName("conduit_bend").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 + ":rail_standard");
|
||||
conduit_switch = new BlockConduitSwitch().setBlockName("conduit_switch").setBlockTextureName(RefStrings.MODID + ":rail_standard");
|
||||
}
|
||||
|
||||
private static void registerBlock() {
|
||||
@ -3550,6 +3553,7 @@ public class ModBlocks {
|
||||
|
||||
register(conduit_straight);
|
||||
register(conduit_bend);
|
||||
register(conduit_switch);
|
||||
}
|
||||
|
||||
private static void register(Block b) {
|
||||
|
||||
57
src/main/java/com/hbm/hrist/BlockConduitBase.java
Normal file
57
src/main/java/com/hbm/hrist/BlockConduitBase.java
Normal 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();
|
||||
}
|
||||
}
|
||||
@ -1,47 +1,21 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.Vec3NT;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
// you can think of it like a pipeline
|
||||
public class BlockConduitBend extends BlockDummyable {
|
||||
public class BlockConduitBend extends BlockConduitBase {
|
||||
|
||||
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 getOffset() { return 0; }
|
||||
|
||||
@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) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta - 10);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,47 +1,20 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
// you can think of it like a pipeline
|
||||
public class BlockConduitStraight extends BlockDummyable {
|
||||
public class BlockConduitStraight extends BlockConduitBase {
|
||||
|
||||
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 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));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -53,4 +26,29 @@ public class BlockConduitStraight extends BlockDummyable {
|
||||
z + 0.5 + rot.offsetZ * 0.5 - dir.offsetZ * 2.5, dir.getOpposite());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
86
src/main/java/com/hbm/hrist/BlockConduitSwitch.java
Normal file
86
src/main/java/com/hbm/hrist/BlockConduitSwitch.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.hrist.ConduitSpace.ConduitWorld;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.ParticleUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
@ -35,7 +36,7 @@ public class ConDbg {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public class ConduitLine {
|
||||
public World world;
|
||||
protected boolean valid = true;
|
||||
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 double cachedDistance = 0;
|
||||
@ -24,6 +24,23 @@ public class ConduitLine {
|
||||
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 double getDistance() {
|
||||
|
||||
@ -63,6 +63,7 @@ public class ConduitPiece {
|
||||
|
||||
public void setLine(ConduitLine line) {
|
||||
this.liveConnection = line;
|
||||
if(line != null) line.join(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
172
src/main/java/com/hbm/hrist/ConduitRenderUtil.java
Normal file
172
src/main/java/com/hbm/hrist/ConduitRenderUtil.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -7,12 +7,14 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.interfaces.NotableComments;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/// ROBUR PER UNITATEM ///
|
||||
@NotableComments
|
||||
public class ConduitSpace {
|
||||
|
||||
public static Map<World, ConduitWorld> worlds = new HashMap();
|
||||
@ -64,8 +66,6 @@ public class ConduitSpace {
|
||||
connections.put(def.connectors[1], piece);
|
||||
orphans.add(def);
|
||||
}
|
||||
|
||||
for(ConnectionDefinition con : piece.definitions) orphans.add(con);
|
||||
}
|
||||
|
||||
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 == orphan.parent) continue; // no self-fellating
|
||||
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) {
|
||||
ConduitLine connectedLine = connectedDef.getLine();
|
||||
if(connectedLine == null) continue;
|
||||
if(connectedDef == orphan) continue;
|
||||
|
||||
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);
|
||||
connectedLine.constructedFrom.add(orphan);
|
||||
break;
|
||||
}
|
||||
// if not, merge
|
||||
} else {
|
||||
} else if(line.isValid()) {
|
||||
// larger one eats the smaller one for performance
|
||||
ConduitLine larger = line.constructedFrom.size() > connectedLine.constructedFrom.size() ? line : connectedLine;
|
||||
ConduitLine smaller = line.constructedFrom.size() > connectedLine.constructedFrom.size() ? connectedLine : line;
|
||||
|
||||
larger.constructedFrom.addAll(smaller.constructedFrom);
|
||||
for(ConnectionDefinition smallerDef : smaller.constructedFrom) {
|
||||
smallerDef.setLine(larger);
|
||||
}
|
||||
smaller.constructedFrom.clear();
|
||||
larger.setChanged();
|
||||
smaller.invalidate();
|
||||
ConduitLine larger = line.getDefCount() > connectedLine.getDefCount() ? line : connectedLine;
|
||||
ConduitLine smaller = larger == connectedLine ? line : connectedLine;
|
||||
larger.absorb(smaller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(orphan.getLine() == null) {
|
||||
ConduitLine newLine = new ConduitLine(world);
|
||||
orphan.setLine(newLine);
|
||||
newLine.constructedFrom.add(orphan);
|
||||
newLine.setChanged();
|
||||
if(orphan.getLine() == null || !orphan.getLine().isValid()) {
|
||||
orphan.setLine(new ConduitLine(world));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,6 +65,18 @@ public class Vec3NT extends Vec3 {
|
||||
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) {
|
||||
double cos = Math.cos(alpha);
|
||||
double sin = Math.sin(alpha);
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/rail_standard.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/rail_standard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
Loading…
x
Reference in New Issue
Block a user