From 4a613ff145d41973eb244b047a7410a29c97dc7c Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:57:52 +1000 Subject: [PATCH] Fix crash when changing dimensions --- .../mixin/minecraft/MixinWorldRenderer.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java index 925ca751..c33432f9 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java @@ -48,25 +48,18 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { } } - @Unique private ClientWorld refCopy; - @Inject(method = "setWorld", at = @At("HEAD")) private void voxy$captureSetWorld(ClientWorld world, CallbackInfo ci) { - this.refCopy = this.world; - } - - @Inject(method = "setWorld", at = @At("TAIL")) - private void voxy$setWorld(ClientWorld world, CallbackInfo ci) { - if (world == null) { + if (this.world != world) { this.shutdownRenderer(); - } - //Release the client world - if (this.refCopy != null) { - var engine = ((IVoxyWorldGetter)this.refCopy).getWorldEngine(); - if (engine != null) { - VoxyCommon.getInstance().stopWorld(engine); + + if (this.world != null) { + var engine = ((IVoxyWorldGetter)this.world).getWorldEngine(); + if (engine != null) { + VoxyCommon.getInstance().stopWorld(engine); + } + ((IVoxyWorldSetter)this.world).setWorldEngine(null); } - ((IVoxyWorldSetter)this.refCopy).setWorldEngine(null); } }