diff --git a/src/main/java/api/hbm/energymk2/Nodespace.java b/src/main/java/api/hbm/energymk2/Nodespace.java index a950c2b24..82b431742 100644 --- a/src/main/java/api/hbm/energymk2/Nodespace.java +++ b/src/main/java/api/hbm/energymk2/Nodespace.java @@ -25,13 +25,38 @@ public class Nodespace { return null; } + public static void createNode(World world, PowerNode node) { + NodeWorld nodeWorld = worlds.get(world); + if(nodeWorld == null) { + nodeWorld = new NodeWorld(); + worlds.put(world, nodeWorld); + } + nodeWorld.pushNode(node); + } + + public static void destroyNode(World world, int x, int y, int z) { + PowerNode node = getNode(world, x, y, z); + if(node != null) worlds.get(world).popNode(node); + } + public static void updateNodespace() { for(World world : MinecraftServer.getServer().worldServers) { NodeWorld nodes = worlds.get(world); + + for(Entry entry : nodes.nodes.entrySet()) { + PowerNode node = entry.getValue(); + if(node.net == null || !node.net.isValid()) { + tryConnectNode(world, node); + } + } } } + private static void tryConnectNode(World world, PowerNode node) { + + } + public static class NodeWorld { /** Contains a map showing where each node is, a node is every spot that a cable exists at. @@ -47,6 +72,7 @@ public class Nodespace { /** Removes the specified node from all positions from nodespace */ public void popNode(PowerNode node) { + if(node.net != null) node.net.destroy(); for(BlockPos pos : node.positions) { nodes.remove(pos); } diff --git a/src/main/java/com/hbm/render/loader/WavefrontObjDisplayList.java b/src/main/java/com/hbm/render/loader/WavefrontObjDisplayList.java index 99eef4360..79f33e16f 100644 --- a/src/main/java/com/hbm/render/loader/WavefrontObjDisplayList.java +++ b/src/main/java/com/hbm/render/loader/WavefrontObjDisplayList.java @@ -56,7 +56,7 @@ public class WavefrontObjDisplayList implements IModelCustom { @Override public void renderAll() { for(Pair p : nameToCallList) - GL11.glCallList(p.getRight()); + callList(p.getRight()); } @Override @@ -64,7 +64,7 @@ public class WavefrontObjDisplayList implements IModelCustom { for(Pair p : nameToCallList){ for(String name : groupNames){ if(p.getLeft().equalsIgnoreCase(name)){ - GL11.glCallList(p.getRight()); + callList(p.getRight()); break; } } @@ -75,7 +75,7 @@ public class WavefrontObjDisplayList implements IModelCustom { public void renderPart(String partName) { for(Pair p : nameToCallList){ if(p.getLeft().equalsIgnoreCase(partName)){ - GL11.glCallList(p.getRight()); + callList(p.getRight()); } } } @@ -91,8 +91,16 @@ public class WavefrontObjDisplayList implements IModelCustom { } } if(!skip){ - GL11.glCallList(p.getRight()); + callList(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); + } } \ No newline at end of file