diff --git a/projects/common/src/client/java/dan200/computercraft/client/ClientHooks.java b/projects/common/src/client/java/dan200/computercraft/client/ClientHooks.java index 36b331939..3ecd0bdc6 100644 --- a/projects/common/src/client/java/dan200/computercraft/client/ClientHooks.java +++ b/projects/common/src/client/java/dan200/computercraft/client/ClientHooks.java @@ -64,6 +64,9 @@ public final class ClientHooks { public static void onWorldUnload() { MonitorRenderState.destroyAll(); SpeakerManager.reset(); + } + + public static void onDisconnect() { ClientPocketComputers.reset(); } diff --git a/projects/fabric/src/client/java/dan200/computercraft/mixin/client/MinecraftMixin.java b/projects/fabric/src/client/java/dan200/computercraft/mixin/client/MinecraftMixin.java index 23244e8b9..e413c3a40 100644 --- a/projects/fabric/src/client/java/dan200/computercraft/mixin/client/MinecraftMixin.java +++ b/projects/fabric/src/client/java/dan200/computercraft/mixin/client/MinecraftMixin.java @@ -28,6 +28,7 @@ class MinecraftMixin { @SuppressWarnings("unused") private void clearLevel(Screen screen, CallbackInfo ci) { ClientHooks.onWorldUnload(); + ClientHooks.onDisconnect(); } @Inject(method = "setLevel", at = @At("HEAD")) diff --git a/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientHooks.java b/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientHooks.java index ea97bf120..7aa52b03a 100644 --- a/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientHooks.java +++ b/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientHooks.java @@ -38,6 +38,10 @@ public final class ForgeClientHooks { if (event.getLevel().isClientSide()) ClientHooks.onWorldUnload(); } + @SubscribeEvent + public static void onDisconnect(ClientPlayerNetworkEvent.LoggingOut event) { + ClientHooks.onDisconnect(); + } @SubscribeEvent public static void drawHighlight(RenderHighlightEvent.Block event) {