Merge branch 'minecraft-lod-mod-refactor/client-world-close'

This commit is contained in:
James Seibel
2023-10-29 16:09:47 -05:00
2 changed files with 13 additions and 15 deletions
@@ -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
@@ -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();
}
}