mirror of
https://github.com/FabricMC/fabric.git
synced 2025-02-26 00:14:06 -05:00
Catch exception inside client-side JOIN event (#2813)
* Catch exception inside client-side JOIN event
* Update fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/impl/networking/client/ClientPlayNetworkAddon.java
Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com>
Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com>
(cherry picked from commit 4017a8cb18
)
This commit is contained in:
parent
3e1e13ab8f
commit
10eb22f456
1 changed files with 10 additions and 1 deletions
|
@ -20,6 +20,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.Packet;
|
||||
|
@ -42,6 +45,8 @@ public final class ClientPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
private final MinecraftClient client;
|
||||
private boolean sentInitialRegisterPacket;
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public ClientPlayNetworkAddon(ClientPlayNetworkHandler handler, MinecraftClient client) {
|
||||
super(ClientNetworkingImpl.PLAY, handler.getConnection(), "ClientPlayNetworkAddon for " + handler.getProfile().getName());
|
||||
this.handler = handler;
|
||||
|
@ -64,7 +69,11 @@ public final class ClientPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
}
|
||||
|
||||
public void onServerReady() {
|
||||
ClientPlayConnectionEvents.JOIN.invoker().onPlayReady(this.handler, this, this.client);
|
||||
try {
|
||||
ClientPlayConnectionEvents.JOIN.invoker().onPlayReady(this.handler, this, this.client);
|
||||
} catch (RuntimeException e) {
|
||||
LOGGER.error("Exception thrown while invoking ClientPlayConnectionEvents.JOIN", e);
|
||||
}
|
||||
|
||||
// The client cannot send any packets, including `minecraft:register` until after GameJoinS2CPacket is received.
|
||||
this.sendInitialChannelRegistrationPacket();
|
||||
|
|
Loading…
Reference in a new issue