mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Do you know what this means? It means that
this damn thing doesn't work at all!
This commit is contained in:
parent
7b6467fb37
commit
7ab30aa136
@ -1,12 +1,23 @@
|
|||||||
package api.hbm.energymk2;
|
package api.hbm.energymk2;
|
||||||
|
|
||||||
|
import com.hbm.lib.Library;
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
|
|
||||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
|
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
|
||||||
|
|
||||||
public default PowerNode getNode() {
|
public default PowerNode createNode() {
|
||||||
TileEntity tile = (TileEntity) this;
|
TileEntity tile = (TileEntity) this;
|
||||||
return Nodespace.getNode(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord);
|
return new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
|
||||||
|
new DirPos(tile.xCoord + 1, tile.yCoord, tile.zCoord, Library.POS_X),
|
||||||
|
new DirPos(tile.xCoord - 1, tile.yCoord, tile.zCoord, Library.NEG_X),
|
||||||
|
new DirPos(tile.xCoord, tile.yCoord + 1, tile.zCoord, Library.POS_Y),
|
||||||
|
new DirPos(tile.xCoord, tile.yCoord - 1, tile.zCoord, Library.NEG_Y),
|
||||||
|
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord + 1, Library.POS_Z),
|
||||||
|
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord - 1, Library.NEG_Z)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,13 +25,13 @@ public interface IEnergyConnectorMK2 extends ILoadedTile {
|
|||||||
|
|
||||||
public static final boolean particleDebug = false;
|
public static final boolean particleDebug = false;
|
||||||
|
|
||||||
public default Vec3 getDebugParticlePos() {
|
public default Vec3 getDebugParticlePosMK2() {
|
||||||
TileEntity te = (TileEntity) this;
|
TileEntity te = (TileEntity) this;
|
||||||
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
|
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
|
||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public default void provideInfoForEC(NBTTagCompound data) {
|
public default void provideInfoForECMK2(NBTTagCompound data) {
|
||||||
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
|
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
|
||||||
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
|
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public interface IEnergyProviderMK2 extends IEnergyConnector {
|
|||||||
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
||||||
if(!con.canConnect(dir.getOpposite())) return;
|
if(!con.canConnect(dir.getOpposite())) return;
|
||||||
|
|
||||||
PowerNode node = con.getNode();
|
PowerNode node = con.createNode();
|
||||||
|
|
||||||
if(node != null && node.net != null) {
|
if(node != null && node.net != null) {
|
||||||
node.net.addProvider(this);
|
node.net.addProvider(this);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
|||||||
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
||||||
if(!con.canConnect(dir.getOpposite())) return;
|
if(!con.canConnect(dir.getOpposite())) return;
|
||||||
|
|
||||||
PowerNode node = con.getNode();
|
PowerNode node = con.createNode();
|
||||||
|
|
||||||
if(node != null && node.net != null) {
|
if(node != null && node.net != null) {
|
||||||
node.net.addReceiver(this);
|
node.net.addReceiver(this);
|
||||||
@ -51,7 +51,7 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
|||||||
|
|
||||||
if(te instanceof IEnergyConductorMK2) {
|
if(te instanceof IEnergyConductorMK2) {
|
||||||
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
||||||
PowerNode node = con.getNode();
|
PowerNode node = con.createNode();
|
||||||
|
|
||||||
if(node != null && node.net != null) {
|
if(node != null && node.net != null) {
|
||||||
node.net.removeReceiver(this);
|
node.net.removeReceiver(this);
|
||||||
|
|||||||
@ -1,11 +1,17 @@
|
|||||||
package api.hbm.energymk2;
|
package api.hbm.energymk2;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.hbm.packet.AuxParticlePacketNT;
|
||||||
|
import com.hbm.packet.PacketDispatcher;
|
||||||
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 cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -18,6 +24,7 @@ public class Nodespace {
|
|||||||
|
|
||||||
/** Contains all "NodeWorld" instances, i.e. lists of nodes existing per world */
|
/** Contains all "NodeWorld" instances, i.e. lists of nodes existing per world */
|
||||||
public static HashMap<World, NodeWorld> worlds = new HashMap();
|
public static HashMap<World, NodeWorld> worlds = new HashMap();
|
||||||
|
public static Set<PowerNetMK2> activePowerNets = new HashSet();
|
||||||
|
|
||||||
public static PowerNode getNode(World world, int x, int y, int z) {
|
public static PowerNode getNode(World world, int x, int y, int z) {
|
||||||
NodeWorld nodeWorld = worlds.get(world);
|
NodeWorld nodeWorld = worlds.get(world);
|
||||||
@ -36,7 +43,19 @@ public class Nodespace {
|
|||||||
|
|
||||||
public static void destroyNode(World world, int x, int y, int z) {
|
public static void destroyNode(World world, int x, int y, int z) {
|
||||||
PowerNode node = getNode(world, x, y, z);
|
PowerNode node = getNode(world, x, y, z);
|
||||||
if(node != null) worlds.get(world).popNode(node);
|
if(node != null) {
|
||||||
|
worlds.get(world).popNode(node);
|
||||||
|
markNeigbors(world, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Grabs all neighbor nodes from the given node's connection points and removes them from the network entirely, forcing a hard reconnect */
|
||||||
|
private static void markNeigbors(World world, PowerNode node) {
|
||||||
|
|
||||||
|
for(DirPos con : node.connections) {
|
||||||
|
PowerNode conNode = getNode(world, con.getX(), con.getY(), con.getZ());
|
||||||
|
if(conNode != null && conNode.hasValidNet()) conNode.net.leaveLink(conNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Goes over each node and manages connections */
|
/** Goes over each node and manages connections */
|
||||||
@ -47,7 +66,22 @@ public class Nodespace {
|
|||||||
|
|
||||||
for(Entry<BlockPos, PowerNode> entry : nodes.nodes.entrySet()) {
|
for(Entry<BlockPos, PowerNode> entry : nodes.nodes.entrySet()) {
|
||||||
PowerNode node = entry.getValue();
|
PowerNode node = entry.getValue();
|
||||||
checkNodeConnection(world, node);
|
if(!node.hasValidNet()) {
|
||||||
|
checkNodeConnection(world, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(node.hasValidNet()) {
|
||||||
|
|
||||||
|
for(BlockPos pos : node.positions) {
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
data.setString("type", "marker");
|
||||||
|
data.setInteger("color", 0x00ff00);
|
||||||
|
data.setInteger("expires", 250);
|
||||||
|
data.setDouble("dist", 15D);
|
||||||
|
data.setString("label", "" + node.net.hashCode());
|
||||||
|
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.getX(), pos.getY(), pos.getZ()), new TargetPoint(world.provider.dimensionId, pos.getX(), pos.getY(), pos.getZ(), 50));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +91,7 @@ public class Nodespace {
|
|||||||
|
|
||||||
for(DirPos con : node.connections) {
|
for(DirPos con : node.connections) {
|
||||||
|
|
||||||
PowerNode conNode = getNode(world, con.getX() + con.getDir().offsetX, con.getY() + con.getDir().offsetY, con.getZ() + con.getDir().offsetZ); // get whatever neighbor node intersects with that connection
|
PowerNode conNode = getNode(world, con.getX(), con.getY(), con.getZ()); // get whatever neighbor node intersects with that connection
|
||||||
|
|
||||||
if(conNode != null) { // if there is a node at that place
|
if(conNode != null) { // if there is a node at that place
|
||||||
|
|
||||||
@ -107,6 +141,7 @@ public class Nodespace {
|
|||||||
if(node.net != null) node.net.destroy();
|
if(node.net != null) node.net.destroy();
|
||||||
for(BlockPos pos : node.positions) {
|
for(BlockPos pos : node.positions) {
|
||||||
nodes.remove(pos);
|
nodes.remove(pos);
|
||||||
|
node.expired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +157,7 @@ public class Nodespace {
|
|||||||
public BlockPos[] positions;
|
public BlockPos[] positions;
|
||||||
public DirPos[] connections;
|
public DirPos[] connections;
|
||||||
public PowerNetMK2 net;
|
public PowerNetMK2 net;
|
||||||
|
public boolean expired = false;
|
||||||
|
|
||||||
public PowerNode(BlockPos... positions) {
|
public PowerNode(BlockPos... positions) {
|
||||||
this.positions = positions;
|
this.positions = positions;
|
||||||
|
|||||||
@ -15,6 +15,10 @@ public class PowerNetMK2 {
|
|||||||
private HashMap<IEnergyReceiverMK2, Long> receiverEntries = new HashMap();
|
private HashMap<IEnergyReceiverMK2, Long> receiverEntries = new HashMap();
|
||||||
private HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap();
|
private HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap();
|
||||||
|
|
||||||
|
public PowerNetMK2() {
|
||||||
|
Nodespace.activePowerNets.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
/// SUBSCRIBER HANDLING ///
|
/// SUBSCRIBER HANDLING ///
|
||||||
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
|
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
|
||||||
return this.receiverEntries.containsKey(receiver);
|
return this.receiverEntries.containsKey(receiver);
|
||||||
@ -72,6 +76,7 @@ public class PowerNetMK2 {
|
|||||||
/// GENERAL POWER NET CONTROL ///
|
/// GENERAL POWER NET CONTROL ///
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
this.valid = false;
|
this.valid = false;
|
||||||
|
Nodespace.activePowerNets.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
|
|||||||
@ -80,6 +80,7 @@ import com.hbm.util.InventoryUtil;
|
|||||||
import com.hbm.util.ArmorRegistry.HazardClass;
|
import com.hbm.util.ArmorRegistry.HazardClass;
|
||||||
import com.hbm.world.generator.TimedGenerator;
|
import com.hbm.world.generator.TimedGenerator;
|
||||||
|
|
||||||
|
import api.hbm.energymk2.Nodespace;
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
@ -1103,6 +1104,7 @@ public class ModEventHandler {
|
|||||||
RTTYSystem.updateBroadcastQueue();
|
RTTYSystem.updateBroadcastQueue();
|
||||||
RequestNetwork.updateEntries();
|
RequestNetwork.updateEntries();
|
||||||
TileEntityMachineRadarNT.updateSystem();
|
TileEntityMachineRadarNT.updateSystem();
|
||||||
|
Nodespace.updateNodespace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,16 @@ package com.hbm.tileentity.network;
|
|||||||
import api.hbm.energy.IEnergyConductor;
|
import api.hbm.energy.IEnergyConductor;
|
||||||
import api.hbm.energy.IPowerNet;
|
import api.hbm.energy.IPowerNet;
|
||||||
import api.hbm.energy.PowerNet;
|
import api.hbm.energy.PowerNet;
|
||||||
|
import api.hbm.energymk2.IEnergyConductorMK2;
|
||||||
|
import api.hbm.energymk2.Nodespace;
|
||||||
|
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityCableBaseNT extends TileEntity implements IEnergyConductor {
|
public class TileEntityCableBaseNT extends TileEntity implements IEnergyConductor, IEnergyConductorMK2 {
|
||||||
|
|
||||||
protected IPowerNet network;
|
protected IPowerNet network;
|
||||||
|
protected PowerNode node;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
@ -24,6 +28,22 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
|||||||
this.setPowerNet(new PowerNet().joinLink(this));
|
this.setPowerNet(new PowerNet().joinLink(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
|
if(this.node == null || this.node.expired) {
|
||||||
|
this.node = Nodespace.getNode(worldObj, xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
|
if(this.node == null || this.node.expired) {
|
||||||
|
this.node = this.createNode();
|
||||||
|
Nodespace.createNode(worldObj, this.node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNodeDestroyedCallback() {
|
||||||
|
this.node = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void connect() {
|
protected void connect() {
|
||||||
@ -59,6 +79,10 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
|||||||
this.network.reevaluate();
|
this.network.reevaluate();
|
||||||
this.network = null;
|
this.network = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.node != null) {
|
||||||
|
Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user