aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-09-08 00:55:35 +0200
committerLinnea Gräf <nea@nea.moe>2025-09-08 00:55:35 +0200
commitd11912b5e15758ef72926976f9e7ead6ee263e92 (patch)
treec4adf3457ef117b5f2757653a800a1f3c3f3ef29 /src/main/kotlin
parent4d25ce70d1c0b6336a5739ee831013b822c0e346 (diff)
downloadFirmament-d11912b5e15758ef72926976f9e7ead6ee263e92.tar.gz
Firmament-d11912b5e15758ef72926976f9e7ead6ee263e92.tar.bz2
Firmament-d11912b5e15758ef72926976f9e7ead6ee263e92.zip
fix: address some concerns
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/features/misc/ModAnnouncer.kt22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/kotlin/features/misc/ModAnnouncer.kt b/src/main/kotlin/features/misc/ModAnnouncer.kt
index a99c6db..0eae9d7 100644
--- a/src/main/kotlin/features/misc/ModAnnouncer.kt
+++ b/src/main/kotlin/features/misc/ModAnnouncer.kt
@@ -2,11 +2,13 @@ package moe.nea.firmament.features.misc
import io.netty.buffer.ByteBuf
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
+import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.network.codec.PacketCodec
import net.minecraft.network.codec.PacketCodecs
import net.minecraft.network.packet.CustomPayload
+import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket
import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.JoinServerEvent
@@ -60,15 +62,17 @@ object ModAnnouncer {
@Subscribe
fun onServerJoin(event: JoinServerEvent) {
- event.networkHandler.sendPacket(
- event.packetSender.createPacket(
- ModPacket(
- FabricLoader.getInstance()
- .allMods
- .filter { !it.metadata.containsCustomValue("firmament:hide_from_modlist") }
- .map { ModEntry(it.metadata.id, it.metadata.version.friendlyString) })
- )
- )
+ val packet = ModPacket(
+ FabricLoader.getInstance()
+ .allMods
+ .filter { !it.metadata.containsCustomValue("firmament:hide_from_modlist") }
+ .map { ModEntry(it.metadata.id, it.metadata.version.friendlyString) })
+ val pbb = PacketByteBufs.create()
+ ModPacket.CODEC.encode(pbb, packet)
+ if (pbb.writerIndex() > CustomPayloadC2SPacket.MAX_PAYLOAD_SIZE)
+ return
+
+ event.networkHandler.sendPacket(event.packetSender.createPacket(packet))
}
init {