diff --git a/build.gradle.kts b/build.gradle.kts index 47bdc2857..249e73362 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -148,7 +148,7 @@ dependencies { shadowMe(project(":events")) shadowMe(project(":hypixel-api:types")) - shadowMe("net.hypixel:mod-api:0.3.1") + shadowMe("net.hypixel:mod-api:0.3.2") shadowMe(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")!!) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/commands/impl/SkytilsCommand.kt b/src/main/kotlin/gg/skytils/skytilsmod/commands/impl/SkytilsCommand.kt index e3aaf3c2a..a9e5c2105 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/commands/impl/SkytilsCommand.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/commands/impl/SkytilsCommand.kt @@ -61,6 +61,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import net.hypixel.modapi.HypixelModAPI import net.hypixel.modapi.packet.ClientboundHypixelPacket +import net.hypixel.modapi.packet.impl.serverbound.ServerboundVersionedPacket import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.gui.GuiScreen import net.minecraft.command.WrongUsageException @@ -385,9 +386,9 @@ object SkytilsCommand : BaseCommand("skytils", listOf("st")) { UChat.chat("$failPrefix §cPacket not found!") } else { registry as AccessorHypixelPacketRegistry - val packetClass = registry.classToIdentifier.entries.find { it.value == id && !ClientboundHypixelPacket::class.java.isAssignableFrom(it.key) } + val packetClass = registry.classToIdentifier.entries.find { it.value == id && ServerboundVersionedPacket::class.java.isAssignableFrom(it.key) } ?: return UChat.chat("$failPrefix §cPacket not found!") - val packet = packetClass.key.newInstance() + val packet = packetClass.key.newInstance() as ServerboundVersionedPacket UChat.chat("$successPrefix §aPacket created: $packet") Skytils.IO.launch { runCatching { diff --git a/src/main/kotlin/gg/skytils/skytilsmod/listeners/ServerPayloadInterceptor.kt b/src/main/kotlin/gg/skytils/skytilsmod/listeners/ServerPayloadInterceptor.kt index 7f5c2f961..4dcfe6117 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/listeners/ServerPayloadInterceptor.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/listeners/ServerPayloadInterceptor.kt @@ -31,6 +31,7 @@ import net.hypixel.modapi.HypixelModAPI import net.hypixel.modapi.error.ErrorReason import net.hypixel.modapi.packet.ClientboundHypixelPacket import net.hypixel.modapi.packet.HypixelPacket +import net.hypixel.modapi.packet.impl.serverbound.ServerboundVersionedPacket import net.hypixel.modapi.serializer.PacketSerializer import net.minecraft.client.network.NetHandlerPlayClient import net.minecraft.network.PacketBuffer @@ -75,14 +76,14 @@ object ServerPayloadInterceptor { } } - fun HypixelPacket.toCustomPayload(): C17PacketCustomPayload { + fun ServerboundVersionedPacket.toCustomPayload(): C17PacketCustomPayload { val buffer = PacketBuffer(Unpooled.buffer()) val serializer = PacketSerializer(buffer) this.write(serializer) return C17PacketCustomPayload(this.identifier, buffer) } - suspend fun HypixelPacket.getResponse(handler: NetHandlerPlayClient): T = withTimeout(1.minutes) { + suspend fun ServerboundVersionedPacket.getResponse(handler: NetHandlerPlayClient): T = withTimeout(1.minutes) { val packet: C17PacketCustomPayload = this@getResponse.toCustomPayload() handler.addToSendQueue(packet) return@withTimeout receivedPackets.filter { it.identifier == this@getResponse.identifier }.first() as T