From db2b96bd9801d1e9f0dc108520310f9add8df4b7 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 5 Jun 2024 01:04:55 +0200 Subject: Fix custom payload event [no changelog] --- src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt | 4 ++++ src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt | 1 + 2 files changed, 5 insertions(+) (limited to 'src/main/kotlin/moe/nea/firmament/apis') diff --git a/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt b/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt index 460df91..00e6aa9 100644 --- a/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt +++ b/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt @@ -6,6 +6,7 @@ package moe.nea.firmament.apis.ingame +import net.hypixel.modapi.fabric.event.HypixelModAPICallback import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket import net.minecraft.text.Text import moe.nea.firmament.annotations.Subscribe @@ -30,6 +31,9 @@ object HypixelModAPI : SubscriptionOwner { InGameCodecWrapper.createStealthyCodec( PartyInfoResponse.intoType() ) + HypixelModAPICallback.EVENT.register(HypixelModAPICallback { + MC.sendChat(Text.literal("Official API: $it")) + }) } @JvmStatic diff --git a/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt b/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt index 0720dbf..447b902 100644 --- a/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt +++ b/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt @@ -35,6 +35,7 @@ class InGameCodecWrapper( override fun decode(buf: PacketByteBuf): CustomPayload { val duplicateBuffer = PacketByteBuf(buf.slice()) val original = wrapped.decode(buf) + buf.skipBytes(buf.readableBytes()) val duplicate = direction.customCodec.decode(duplicateBuffer) if (duplicate is FirmamentCustomPayload.Unhandled) return original -- cgit