From 1bb2ef29f5ba4efa9dd41d7de12ac0d8784ca914 Mon Sep 17 00:00:00 2001 From: s809 <11816467-s809@users.noreply.gitlab.com> Date: Sat, 28 Oct 2023 19:43:22 +0500 Subject: [PATCH] Move closing of client world to a proper place --- coreSubProjects | 2 +- .../client/MixinClientPacketListener.java | 11 ++--------- .../client/MixinClientPacketListener.java | 17 +++++++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/coreSubProjects b/coreSubProjects index 62bf59f09..5e2accadc 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 62bf59f098a167115d7dbbab3d992aded4b1be0d +Subproject commit 5e2accadcaf359d632324a465b387db2a2c23118 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinClientPacketListener.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinClientPacketListener.java index a38e84d1f..d9ca84a05 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinClientPacketListener.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinClientPacketListener.java @@ -23,14 +23,6 @@ public class MixinClientPacketListener @Shadow private ClientLevel level; - - - @Inject(method = "handleLogin", at = @At("HEAD")) - void onHandleLoginStart(CallbackInfo ci) - { - // not the best way to notify Core that we are no longer in the previous world, but it will have to do for now - ClientApi.INSTANCE.onClientOnlyDisconnected(); - } @Inject(method = "handleLogin", at = @At("RETURN")) void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); } @@ -46,11 +38,12 @@ public class MixinClientPacketListener #endif void onCleanupStart(CallbackInfo ci) { - // TODO which unload method should be used? do we need both? + // TODO Is this even needed here? if (level != null) { ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level)); } + ClientApi.INSTANCE.onClientOnlyDisconnected(); } #if POST_MC_1_20_1 diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinClientPacketListener.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinClientPacketListener.java index 2b1efec4e..1bb20e3fa 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinClientPacketListener.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinClientPacketListener.java @@ -1,5 +1,6 @@ package com.seibel.distanthorizons.forge.mixins.client; +import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.core.api.internal.ClientApi; import net.minecraft.client.multiplayer.ClientPacketListener; import org.spongepowered.asm.mixin.Mixin; @@ -12,13 +13,17 @@ public class MixinClientPacketListener { // TODO update fabric version as well - @Inject(method = "handleLogin", at = @At("HEAD")) - void onHandleLoginStart(CallbackInfo ci) - { - // not the best way to notify Core that we are no longer in the previous world, but it will have to do for now - ClientApi.INSTANCE.onClientOnlyDisconnected(); - } @Inject(method = "handleLogin", at = @At("RETURN")) void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); } + #if PRE_MC_1_19_4 + @Inject(method = "cleanup", at = @At("HEAD")) + #else + @Inject(method = "close", at = @At("HEAD")) + #endif + void onCleanupStart(CallbackInfo ci) + { + ClientApi.INSTANCE.onClientOnlyDisconnected(); + } + }