aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/features/misc/ModAnnouncer.kt22
-rw-r--r--src/main/resources/firmament.accesswidener2
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