mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
my eyes are burning
This commit is contained in:
parent
b65abb526f
commit
4869dbb1c8
@ -2,6 +2,7 @@ package api.hbm.energymk2;
|
|||||||
|
|
||||||
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
|
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
|
||||||
|
|
||||||
|
// ??? could be redundant because of nodespace, we'll see how that works out
|
||||||
public PowerNetMK2 getPowerNet();
|
public PowerNetMK2 getPowerNet();
|
||||||
|
|
||||||
public void setPowerNet(PowerNetMK2 network);
|
public void setPowerNet(PowerNetMK2 network);
|
||||||
|
|||||||
7
src/main/java/api/hbm/energymk2/IEnergyProviderMK2.java
Normal file
7
src/main/java/api/hbm/energymk2/IEnergyProviderMK2.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package api.hbm.energymk2;
|
||||||
|
|
||||||
|
import api.hbm.energy.IEnergyConnector;
|
||||||
|
|
||||||
|
public interface IEnergyProviderMK2 extends IEnergyConnector {
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,7 +3,6 @@ package api.hbm.energymk2;
|
|||||||
import com.hbm.packet.AuxParticlePacketNT;
|
import com.hbm.packet.AuxParticlePacketNT;
|
||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
|
|
||||||
import api.hbm.energy.IEnergyConductor;
|
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@ -20,8 +19,8 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
|||||||
TileEntity te = world.getTileEntity(x, y, z);
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
boolean red = false;
|
boolean red = false;
|
||||||
|
|
||||||
/*if(te instanceof IEnergyConductor) {
|
if(te instanceof IEnergyConductorMK2) {
|
||||||
IEnergyConductor con = (IEnergyConductor) te;
|
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
||||||
|
|
||||||
if(!con.canConnect(dir.getOpposite()))
|
if(!con.canConnect(dir.getOpposite()))
|
||||||
return;
|
return;
|
||||||
@ -31,7 +30,7 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
|||||||
|
|
||||||
if(con.getPowerNet() != null)
|
if(con.getPowerNet() != null)
|
||||||
red = true;
|
red = true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if(particleDebug) {
|
if(particleDebug) {
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
@ -51,11 +50,11 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
|||||||
|
|
||||||
TileEntity te = world.getTileEntity(x, y, z);
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if(te instanceof IEnergyConductor) {
|
if(te instanceof IEnergyConductorMK2) {
|
||||||
IEnergyConductor con = (IEnergyConductor) te;
|
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
|
||||||
|
|
||||||
/*if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this))
|
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this))
|
||||||
con.getPowerNet().unsubscribe(this);*/
|
con.getPowerNet().unsubscribe(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,61 @@
|
|||||||
package api.hbm.energymk2;
|
package api.hbm.energymk2;
|
||||||
|
|
||||||
public class Nodespace {
|
import java.util.HashMap;
|
||||||
|
|
||||||
//we're gonna figure this shit out as we go along
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "Nodespace" is an intermediate, "ethereal" layer of abstraction that tracks nodes (i.e. cables) even when they are no longer loaded, allowing continued operation even when unloaded
|
||||||
|
* @author hbm
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Nodespace {
|
||||||
|
|
||||||
|
/** Contains all "NodeWorld" instances, i.e. lists of nodes existing per world */
|
||||||
|
public static HashMap<World, NodeWorld> worlds = new HashMap();
|
||||||
|
|
||||||
|
public static class NodeWorld {
|
||||||
|
|
||||||
|
/** Contains a map showing where each node is, a node is every spot that a cable exists at.
|
||||||
|
* Instead of the old proxy system, things like substation now create multiple nodes at their connection points */
|
||||||
|
public static HashMap<BlockPos, PowerNode> nodes = new HashMap();
|
||||||
|
|
||||||
|
/** Adds a node at all its positions to the nodespace */
|
||||||
|
public void pushNode(PowerNode node) {
|
||||||
|
for(BlockPos pos : node.positions) {
|
||||||
|
nodes.put(pos, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Removes the specified node from all positions from nodespace */
|
||||||
|
public void popNode(PowerNode node) {
|
||||||
|
for(BlockPos pos : node.positions) {
|
||||||
|
nodes.remove(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Grabs the node at one position, then removes it from all positions it occupies */
|
||||||
|
public void popNode(BlockPos pos) {
|
||||||
|
PowerNode node = nodes.get(pos);
|
||||||
|
if(node != null) popNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PowerNode {
|
||||||
|
|
||||||
|
public BlockPos[] positions;
|
||||||
|
public DirPos[] connections;
|
||||||
|
|
||||||
|
public PowerNode(BlockPos... positions) {
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PowerNode setConnections(DirPos... connections) {
|
||||||
|
this.connections = connections;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,56 @@
|
|||||||
package api.hbm.energymk2;
|
package api.hbm.energymk2;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||||
|
|
||||||
public class PowerNetMK2 {
|
public class PowerNetMK2 {
|
||||||
|
|
||||||
private boolean valid = true;
|
private boolean valid = true;
|
||||||
private HashMap<Integer, IEnergyConductorMK2> links = new HashMap();
|
private Set<PowerNode> links = new HashSet();
|
||||||
private HashMap<Integer, Integer> proxies = new HashMap();
|
|
||||||
private List<IEnergyConnectorMK2> subscribers = new ArrayList();
|
|
||||||
|
|
||||||
|
/** Maps all active subscribers to a timestamp, handy for handling timeouts. In a good system this shouldn't be necessary, but the previous system taught me to be cautious anyway */
|
||||||
|
private HashMap<IEnergyReceiverMK2, Long> subscriberEntries = new HashMap();
|
||||||
|
/** A simple set containing all subscribers, might be redundant because of the hashmap, we'll see if we keep this around */
|
||||||
|
private Set<IEnergyReceiverMK2> subscriberSet = new HashSet();
|
||||||
|
|
||||||
|
private HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap();
|
||||||
|
private Set<IEnergyProviderMK2> providerSet = new HashSet();
|
||||||
|
|
||||||
|
/// SUBSCRIBER HANDLING ///
|
||||||
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
|
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
|
||||||
return false; //TBI
|
return this.subscriberSet.contains(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subscribe(IEnergyReceiverMK2 receiver) {
|
public void subscribe(IEnergyReceiverMK2 receiver) {
|
||||||
//TBI
|
this.subscriberSet.add(receiver);
|
||||||
|
this.subscriberEntries.put(receiver, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsubscribe(IEnergyReceiverMK2 receiver) {
|
||||||
|
this.subscriberSet.remove(receiver);
|
||||||
|
this.subscriberEntries.remove(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// PROVIDER HANDLING ///
|
||||||
|
public boolean isProvider(IEnergyProviderMK2 provider) {
|
||||||
|
return this.providerSet.contains(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProvider(IEnergyProviderMK2 provider) {
|
||||||
|
this.providerSet.add(provider);
|
||||||
|
this.providerEntries.put(provider, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeProvider(IEnergyProviderMK2 provider) {
|
||||||
|
this.providerSet.remove(provider);
|
||||||
|
this.providerEntries.remove(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// GENERAL POWER NET CONTROL ///
|
||||||
|
public void invalidate() {
|
||||||
|
this.valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user