From 68fd2156dceefd7d2c8df557189efa2873c9b47b Mon Sep 17 00:00:00 2001 From: shBLOCK <50770712+shBLOCK@users.noreply.github.com> Date: Mon, 15 Jan 2024 00:19:11 +0800 Subject: [PATCH] Fix quantum bridge infinite update loop (#7558) Account for quantum bridge nodes not being initialized when neighbor updates trigger multiblock updates. Stop swallowing exceptions during multiblock updates, since that hid this problem for years, preventing it from being fixed. --------- Co-authored-by: Sebastian Hartte (cherry picked from commit 332da2230217f1748ee47c50994caee50a2c04f1) --- .../guidebook/command/GuidebookStructureCommands.java | 7 +++++++ src/main/java/appeng/me/cluster/MBCalculator.java | 4 ---- .../appeng/me/cluster/implementations/QuantumCluster.java | 6 +----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/appeng/client/guidebook/command/GuidebookStructureCommands.java b/src/main/java/appeng/client/guidebook/command/GuidebookStructureCommands.java index 3cfee8dd450..3148b2857d6 100644 --- a/src/main/java/appeng/client/guidebook/command/GuidebookStructureCommands.java +++ b/src/main/java/appeng/client/guidebook/command/GuidebookStructureCommands.java @@ -21,6 +21,8 @@ import org.lwjgl.PointerBuffer; import org.lwjgl.system.MemoryStack; import org.lwjgl.util.tinyfd.TinyFileDialogs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.PauseScreen; @@ -50,6 +52,8 @@ @OnlyIn(Dist.CLIENT) public class GuidebookStructureCommands { + private static final Logger LOG = LoggerFactory.getLogger(GuidebookStructureCommands.class); + @Nullable private static String lastOpenedOrSavedPath; @@ -106,6 +110,7 @@ private static void importStructure(ServerLevel level, BlockPos origin) { try { compound = NbtUtils.snbtToStructure(textInFile); } catch (CommandSyntaxException e) { + LOG.error("Failed to parse structure.", e); player.sendSystemMessage(Component.literal(e.toString())); return null; } @@ -127,6 +132,7 @@ private static void importStructure(ServerLevel level, BlockPos origin) { player.sendSystemMessage(Component.literal("Placed structure")); } } catch (Exception e) { + LOG.error("Failed to place structure.", e); player.sendSystemMessage(Component.literal(e.toString())); } @@ -212,6 +218,7 @@ private static void exportStructure(ServerLevel level, BlockPos origin, Vec3i si player.sendSystemMessage(Component.literal("Saved structure")); } catch (IOException e) { + LOG.error("Failed to save structure.", e); player.sendSystemMessage(Component.literal(e.toString())); } diff --git a/src/main/java/appeng/me/cluster/MBCalculator.java b/src/main/java/appeng/me/cluster/MBCalculator.java index 1463df3d655..73ccf49bcb2 100644 --- a/src/main/java/appeng/me/cluster/MBCalculator.java +++ b/src/main/java/appeng/me/cluster/MBCalculator.java @@ -27,8 +27,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import appeng.core.AELog; - public abstract class MBCalculator, TCluster extends IAECluster> { /** @@ -145,8 +143,6 @@ public void calculateMultiblock(ServerLevel level, BlockPos loc) { cluster.updateStatus(updateGrid); return; } - } catch (Throwable err) { - AELog.debug(err); } finally { setModificationInProgress(null); } diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java index f9236c4233b..706e3c3fa2e 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java @@ -162,11 +162,7 @@ private boolean canUseNode(long qe) { } private boolean isActive() { - if (this.isDestroyed || !this.registered) { - return false; - } - - return this.hasQES(); + return !this.isDestroyed && this.registered && hasQES() && getNode() != null; } private IGridNode getNode() {