aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-29 20:32:51 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-29 20:32:51 +0200
commit72db19defaf771fec887af6a9e632e81dc9a8628 (patch)
treef5836d7d169d7b30bc7463ec2e7e7d6661e37c58 /src
parent0662bb696bb5f003a8c0edc14e8d54dac19f78dc (diff)
downloadskyhanni-72db19defaf771fec887af6a9e632e81dc9a8628.tar.gz
skyhanni-72db19defaf771fec887af6a9e632e81dc9a8628.tar.bz2
skyhanni-72db19defaf771fec887af6a9e632e81dc9a8628.zip
hopefully fixed 'onChatPacket must not be null'
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/BlockData.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java4
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);
+ }
}
}