Fix "Cannot register receiver while client is not logging in!"
Since MC provides no reliable way to get the connection while still in the login phase, Fabric API tries to determine it either from MinecraftClient's connection field (for the integrated server) or from the ConnectScreen (for multiplayer). However, neither is present during a replay, leading to the aforementioned error. To fix this, we store our ClientConnection in MinecraftClient's connection field. This should have no significant effect on vanilla behavior. Also remove the dead Forge 1.14 code which was in the same place.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -50,4 +51,9 @@ public interface MinecraftAccessor {
|
||||
//$$ @Accessor
|
||||
//$$ List<IResourcePack> getDefaultResourcePacks();
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
@Accessor
|
||||
void setConnection(ClientConnection connection);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -308,8 +308,8 @@ public class ReplayHandler {
|
||||
channel.pipeline().addLast("packet_handler", networkManager);
|
||||
channel.pipeline().fireChannelActive();
|
||||
|
||||
//#if MC>=11400 && MC<11400
|
||||
//$$ NetworkHooks.registerClientLoginChannel(networkManager);
|
||||
//#if MC>=11400
|
||||
((MinecraftAccessor) mc).setConnection(networkManager);
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user