diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
3 files changed, 10 insertions, 3 deletions
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<Pa @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) { - NetworkManagerHookKt.onReceivePacket(context, packet, ci); + if (packet != null) { + NetworkManagerHookKt.onReceivePacket(context, packet, ci); + } } } |