mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-16 06:35:35 +00:00
Just remember the bit about bleeding anuses, and you'll be fine.
This commit is contained in:
parent
f957a0fedf
commit
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() {
|
||||
|
||||
@ -2394,6 +2396,7 @@ public class ModBlocks {
|
||||
|
||||
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_switch = new BlockConduitSwitch().setBlockName("conduit_switch").setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -53,4 +57,10 @@ 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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -53,4 +57,10 @@ 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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
71
src/main/java/com/hbm/hrist/BlockConduitSwitch.java
Normal file
71
src/main/java/com/hbm/hrist/BlockConduitSwitch.java
Normal file
@ -0,0 +1,71 @@
|
||||
package com.hbm.hrist;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.hrist.ConduitPiece.ConnectionDefinition;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockConduitSwitch extends BlockDummyable {
|
||||
|
||||
public BlockConduitSwitch() {
|
||||
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, 3}; }
|
||||
@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);
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
world.spawnParticle("smoke", x + rand.nextFloat(), y + 1, z + rand.nextFloat(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
@ -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 : 0xff8000) : 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(connectedDef.connectors[0].equals(connection) || connectedDef.connectors[1].equals(connection)) {
|
||||
orphan.setLine(connectedLine);
|
||||
connectedLine.constructedFrom.add(orphan);
|
||||
break;
|
||||
}
|
||||
// if not, merge
|
||||
} else {
|
||||
// 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();
|
||||
orphan.setLine(new ConduitLine(world));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user