mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
a botched nosejob
This commit is contained in:
parent
a814e581b9
commit
27bd64eafc
39
src/main/java/com/hbm/uninos/GenNode.java
Normal file
39
src/main/java/com/hbm/uninos/GenNode.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
|
|
||||||
|
public class GenNode<T> {
|
||||||
|
|
||||||
|
public BlockPos[] positions;
|
||||||
|
public DirPos[] connections;
|
||||||
|
public INodeNet<T> net;
|
||||||
|
public boolean expired = false;
|
||||||
|
public boolean recentlyChanged = true;
|
||||||
|
|
||||||
|
public GenNode(BlockPos... positions) {
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenNode<T> setConnections(DirPos... connections) {
|
||||||
|
this.connections = connections;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenNode<T> addConnection(DirPos connection) {
|
||||||
|
DirPos[] newCons = new DirPos[this.connections.length + 1];
|
||||||
|
for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i];
|
||||||
|
newCons[newCons.length - 1] = connection;
|
||||||
|
this.connections = newCons;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasValidNet() {
|
||||||
|
return this.net != null && this.net.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNet(INodeNet<T> net) {
|
||||||
|
this.net = net;
|
||||||
|
this.recentlyChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/main/java/com/hbm/uninos/GenNodeWorld.java
Normal file
29
src/main/java/com/hbm/uninos/GenNodeWorld.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
|
||||||
|
public class GenNodeWorld<T> {
|
||||||
|
|
||||||
|
public HashMap<BlockPos, GenNode<T>> nodes = new HashMap();
|
||||||
|
|
||||||
|
public void pushNode(GenNode<T> node) {
|
||||||
|
for(BlockPos pos : node.positions) {
|
||||||
|
nodes.put(pos, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void popNode(GenNode<T> node) {
|
||||||
|
if(node.net != null) node.net.destroy();
|
||||||
|
for(BlockPos pos : node.positions) {
|
||||||
|
nodes.remove(pos);
|
||||||
|
node.expired = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void popNode(BlockPos pos) {
|
||||||
|
GenNode<T> node = nodes.get(pos);
|
||||||
|
if(node != null) popNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/main/java/com/hbm/uninos/GenNodespace.java
Normal file
34
src/main/java/com/hbm/uninos/GenNodespace.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class GenNodespace<T> {
|
||||||
|
|
||||||
|
public HashMap<World, GenNodeWorld<T>> worlds = new HashMap<>();
|
||||||
|
|
||||||
|
public GenNode<T> getNode(World world, int x, int y, int z) {
|
||||||
|
GenNodeWorld nodeWorld = worlds.get(world);
|
||||||
|
if(nodeWorld != null) return (GenNode<T>) nodeWorld.nodes.get(new BlockPos(x, y, z));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNode(World world, GenNode<T> node) {
|
||||||
|
GenNodeWorld nodeWorld = worlds.get(world);
|
||||||
|
if(nodeWorld == null) {
|
||||||
|
nodeWorld = new GenNodeWorld();
|
||||||
|
worlds.put(world, nodeWorld);
|
||||||
|
}
|
||||||
|
nodeWorld.pushNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroyNode(World world, int x, int y, int z) {
|
||||||
|
GenNode<T> node = getNode(world, x, y, z);
|
||||||
|
if(node != null) {
|
||||||
|
worlds.get(world).popNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/main/java/com/hbm/uninos/INetworkProvider.java
Normal file
5
src/main/java/com/hbm/uninos/INetworkProvider.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
public interface INetworkProvider {
|
||||||
|
|
||||||
|
}
|
||||||
7
src/main/java/com/hbm/uninos/INodeNet.java
Normal file
7
src/main/java/com/hbm/uninos/INodeNet.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
public interface INodeNet<T> {
|
||||||
|
|
||||||
|
public boolean isValid();
|
||||||
|
public void destroy();
|
||||||
|
}
|
||||||
8
src/main/java/com/hbm/uninos/UniNodespace.java
Normal file
8
src/main/java/com/hbm/uninos/UniNodespace.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.hbm.uninos;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class UniNodespace {
|
||||||
|
|
||||||
|
public static HashMap<INetworkProvider, GenNodespace> nodespaces = new HashMap();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user