From 72db19defaf771fec887af6a9e632e81dc9a8628 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 29 Jul 2023 20:32:51 +0200 Subject: hopefully fixed 'onChatPacket must not be null' --- src/main/java/at/hannibal2/skyhanni/data/BlockData.kt | 5 ++++- .../java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt | 4 +++- .../hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt index 0c45a7bb1..651312599 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt @@ -12,9 +12,12 @@ class BlockData { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { val packet = event.packet + if (packet == null) return if (packet is S23PacketBlockChange) { - ServerBlockChangeEvent(packet.blockPosition, packet.blockState).postAndCatch() + val blockPos = packet.blockPosition ?: return + val blockState = packet.blockState ?: return + ServerBlockChangeEvent(blockPos, blockState).postAndCatch() } else if (packet is S22PacketMultiBlockChange) { for (block in packet.changedBlocks) { ServerBlockChangeEvent(block.pos, block.blockState).postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt index b9265587a..b5b4ec0ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt @@ -6,5 +6,7 @@ import net.minecraft.network.Packet import org.spongepowered.asm.mixin.injection.callback.CallbackInfo fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) { - if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() + if (packet != null) { + if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() + } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java index 459da17a1..7c0e47113 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java @@ -15,6 +15,8 @@ public abstract class MixinNetworkManager extends SimpleChannelInboundHandler packet, CallbackInfo ci) { - NetworkManagerHookKt.onReceivePacket(context, packet, ci); + if (packet != null) { + NetworkManagerHookKt.onReceivePacket(context, packet, ci); + } } } -- cgit