diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-08 00:55:35 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-08 00:55:35 +0200 |
| commit | d11912b5e15758ef72926976f9e7ead6ee263e92 (patch) | |
| tree | c4adf3457ef117b5f2757653a800a1f3c3f3ef29 | |
| parent | 4d25ce70d1c0b6336a5739ee831013b822c0e346 (diff) | |
| download | Firmament-d11912b5e15758ef72926976f9e7ead6ee263e92.tar.gz Firmament-d11912b5e15758ef72926976f9e7ead6ee263e92.tar.bz2 Firmament-d11912b5e15758ef72926976f9e7ead6ee263e92.zip | |
fix: address some concerns
| -rw-r--r-- | src/main/kotlin/features/misc/ModAnnouncer.kt | 22 | ||||
| -rw-r--r-- | src/main/resources/firmament.accesswidener | 2 |
2 files changed, 15 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 { diff --git a/src/main/resources/firmament.accesswidener b/src/main/resources/firmament.accesswidener index e600936..af71627 100644 --- a/src/main/resources/firmament.accesswidener +++ b/src/main/resources/firmament.accesswidener @@ -16,6 +16,8 @@ accessible method net/minecraft/entity/decoration/ArmorStandEntity setSmall (Z)V accessible method net/minecraft/resource/NamespaceResourceManager loadMetadata (Lnet/minecraft/resource/InputSupplier;)Lnet/minecraft/resource/metadata/ResourceMetadata; accessible method net/minecraft/client/gui/DrawContext drawTexturedQuad (Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/util/Identifier;IIIIFFFFI)V +accessible field net/minecraft/network/packet/c2s/common/CustomPayloadC2SPacket MAX_PAYLOAD_SIZE I + accessible class net/minecraft/client/render/model/BlockStatesLoader$LoadedBlockStateDefinition accessible field net/minecraft/client/render/model/BlockStatesLoader FINDER Lnet/minecraft/resource/ResourceFinder; accessible method net/minecraft/client/render/model/BlockStatesLoader$LoadedBlockStateDefinition <init> (Ljava/lang/String;Lnet/minecraft/client/render/model/json/BlockModelDefinition;)V |
