mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
my head hurts
This commit is contained in:
parent
43d3d03df5
commit
7b6467fb37
@ -39,6 +39,7 @@ public class Nodespace {
|
||||
if(node != null) worlds.get(world).popNode(node);
|
||||
}
|
||||
|
||||
/** Goes over each node and manages connections */
|
||||
public static void updateNodespace() {
|
||||
|
||||
for(World world : MinecraftServer.getServer().worldServers) {
|
||||
@ -46,15 +47,46 @@ public class Nodespace {
|
||||
|
||||
for(Entry<BlockPos, PowerNode> entry : nodes.nodes.entrySet()) {
|
||||
PowerNode node = entry.getValue();
|
||||
if(node.net == null || !node.net.isValid()) {
|
||||
tryConnectNode(world, node);
|
||||
checkNodeConnection(world, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Goes over each connection point of the given node, tries to find neighbor nodes and to join networks with them */
|
||||
private static void checkNodeConnection(World world, PowerNode node) {
|
||||
|
||||
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
|
||||
|
||||
if(conNode != null) { // if there is a node at that place
|
||||
|
||||
if(conNode.hasValidNet() && conNode.net == node.net) continue; // if the net is valid and both nodes have the same net, skip
|
||||
|
||||
for(DirPos revCon : conNode.connections) { // check if neighbor node also has a valid reverse connection
|
||||
|
||||
// god i hope i didn't fuck this up my brain is hurting already
|
||||
if(revCon.getX() - revCon.getDir().offsetX == con.getX() && revCon.getY() - revCon.getDir().offsetY == con.getY() && revCon.getZ() - revCon.getDir().offsetZ == con.getZ() && revCon.getDir() == con.getDir().getOpposite()) {
|
||||
connectToNode(node, conNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryConnectNode(World world, PowerNode node) {
|
||||
if(node.net == null || !node.net.isValid()) new PowerNetMK2().joinLink(node);
|
||||
}
|
||||
|
||||
/** Links two nodes with different or potentially no networks */
|
||||
private static void connectToNode(PowerNode origin, PowerNode connection) {
|
||||
|
||||
if(origin.hasValidNet() && connection.hasValidNet()) { // both nodes have nets, but the nets are different (previous assumption), join networks
|
||||
origin.net.joinNetworks(connection.net);
|
||||
} else if(!origin.hasValidNet() && connection.hasValidNet()) { // origin has no net, connection does, have origin join connection's net
|
||||
connection.net.joinLink(origin);
|
||||
} else if(origin.hasValidNet() && !connection.hasValidNet()) { // ...and vice versa
|
||||
origin.net.joinLink(connection);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NodeWorld {
|
||||
@ -99,5 +131,9 @@ public class Nodespace {
|
||||
this.connections = connections;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasValidNet() {
|
||||
return this.net != null && this.net.isValid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class WavefrontObjDisplayList implements IModelCustom {
|
||||
@Override
|
||||
public void renderAll() {
|
||||
for(Pair<String, Integer> p : nameToCallList)
|
||||
callList(p.getRight());
|
||||
GL11.glCallList(p.getRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +64,7 @@ public class WavefrontObjDisplayList implements IModelCustom {
|
||||
for(Pair<String, Integer> p : nameToCallList){
|
||||
for(String name : groupNames){
|
||||
if(p.getLeft().equalsIgnoreCase(name)){
|
||||
callList(p.getRight());
|
||||
GL11.glCallList(p.getRight());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class WavefrontObjDisplayList implements IModelCustom {
|
||||
public void renderPart(String partName) {
|
||||
for(Pair<String, Integer> p : nameToCallList){
|
||||
if(p.getLeft().equalsIgnoreCase(partName)){
|
||||
callList(p.getRight());
|
||||
GL11.glCallList(p.getRight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,16 +91,8 @@ public class WavefrontObjDisplayList implements IModelCustom {
|
||||
}
|
||||
}
|
||||
if(!skip){
|
||||
callList(p.getRight());
|
||||
GL11.glCallList(p.getRight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static void callList(int i) {
|
||||
boolean prevBlend = GL11.glIsEnabled(GL11.GL_BLEND);
|
||||
GL11.glCallList(i);
|
||||
boolean newBlend = GL11.glIsEnabled(GL11.GL_BLEND);
|
||||
if(prevBlend && !newBlend) GL11.glEnable(GL11.GL_BLEND);
|
||||
if(!prevBlend && newBlend) GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user