Fix crash when changing dimensions

This commit is contained in:
mcrcortex
2025-03-24 13:57:52 +10:00
parent 68a17f0578
commit 4a613ff145

View File

@@ -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 (this.world != null) {
var engine = ((IVoxyWorldGetter)this.world).getWorldEngine();
if (engine != null) {
VoxyCommon.getInstance().stopWorld(engine);
}
((IVoxyWorldSetter)this.refCopy).setWorldEngine(null);
((IVoxyWorldSetter)this.world).setWorldEngine(null);
}
}
}