Skip to content

Commit ab6ec1d

Browse files
authored
Fix crash on dummy ClientPacketListener (#229)
1 parent 0d1668b commit ab6ec1d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fabric-networking-api-v1/src/client/java/net/fabricmc/fabric/mixin/networking/client/ClientPlayNetworkHandlerMixin.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ protected ClientPlayNetworkHandlerMixin(Minecraft client, Connection connection,
4949

5050
@Inject(method = "<init>", at = @At("RETURN"))
5151
private void initAddon(CallbackInfo ci) {
52-
Set<ResourceLocation> channels = ChannelAttributes.getOrCreateCommonChannels(this.getConnection(), this.protocol());
53-
NeoClientCommonNetworking.onRegisterPacket((ClientPacketListener) (Object) this, channels);
52+
Connection connection = this.getConnection();
53+
if (connection != null && connection.channel() != null) {
54+
Set<ResourceLocation> channels = ChannelAttributes.getOrCreateCommonChannels(connection, this.protocol());
55+
NeoClientCommonNetworking.onRegisterPacket((ClientPacketListener) (Object) this, channels);
56+
}
5457

5558
NeoClientPlayNetworking.setTempPacketListener((ClientPacketListener) (Object) this);
5659
ClientPlayConnectionEvents.INIT.invoker().onPlayInit((ClientPacketListener) (Object) this, this.minecraft);

0 commit comments

Comments
 (0)