From 0a1ee81780d3298f526e23ab1be666e2b072831f Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 23 Mar 2023 06:46:13 +0100 Subject: [PATCH] Add comments for `needUpdateConnections` (#112) * imrpove canConnectToExternal() * needUpdateConnections * add comments for needUpdateconnections --- .../enderio/conduit/AbstractConduit.java | 17 +++++++++++++++++ .../enderio/conduit/me/MEConduit.java | 1 + 2 files changed, 18 insertions(+) diff --git a/src/main/java/crazypants/enderio/conduit/AbstractConduit.java b/src/main/java/crazypants/enderio/conduit/AbstractConduit.java index 96937029..5434ad54 100644 --- a/src/main/java/crazypants/enderio/conduit/AbstractConduit.java +++ b/src/main/java/crazypants/enderio/conduit/AbstractConduit.java @@ -84,6 +84,14 @@ public abstract class AbstractConduit implements IConduit { protected boolean connectionsDirty = true; + /** + * This shows if the currently running connection update should not finish with settings connectionsDirty to false. + * If this is true, it will trigger a reconnection on the next Tick. + *

+ * Use the method needUpdateConnections() instead of setting this to true. + * + * @see needUpdateConnections() + */ protected boolean needUpdateConnections = false; protected AbstractConduit() {} @@ -464,12 +472,21 @@ public abstract class AbstractConduit implements IConduit { } if (needUpdateConnections) { + // Seems the update was not successfull, let's try on the next Tick. needUpdateConnections = false; } else { connectionsDirty = false; } } + /** + * This method prevents connection update from getting completed successfully by not settings connectionsDirty to + * false. This will trigger an connection update at the next Tick. + *

+ * Only use this while executing updateConnections(). + *

+ * See this PR for more info: https://github.com/GTNewHorizons/EnderIO/pull/111 + */ protected void needUpdateConnections() { needUpdateConnections = true; } diff --git a/src/main/java/crazypants/enderio/conduit/me/MEConduit.java b/src/main/java/crazypants/enderio/conduit/me/MEConduit.java index c3b43c55..89a10ab4 100644 --- a/src/main/java/crazypants/enderio/conduit/me/MEConduit.java +++ b/src/main/java/crazypants/enderio/conduit/me/MEConduit.java @@ -175,6 +175,7 @@ public class MEConduit extends AbstractConduit implements IMEConduit { node = part.getGridNode(); } if (node == null) { + // The GridNode has not been initialized yet, let's try on the next Tick. needUpdateConnections(); } }