Carpet

Carpet

3M Downloads

CustomPacketPayload doesn't apply when another mod registers a packet handler in init with fabric api

fayer3 opened this issue ยท 2 comments

commented

Hi Vivecraft dev here, and got a report that people can't join their server when vivecraft is installed with the carpet mod, so I did some digging.

it looks like this mixin (https://github.com/gnembon/fabric-carpet/blob/c241594eb6afb9e44253a6d45d4aaec9d1da555e/src/main/java/carpet/mixins/CustomPacketPayload_networkStuffMixin.java), just silently fails to apply when I register my packets and packethandlers in the mod init

here is how I register my packets (https://github.com/Vivecraft/VivecraftMod/blob/Multiloader-1.21.4/fabric/src/main/java/org/vivecraft/fabric/VivecraftMod.java)

when I tried to run both mods in dev I at least got some error, which might be the same that get's ignored outside of dev

Mixin prepare for mod carpet failed preparing CustomPacketPayload_networkStuffMixin in carpet.mixins.json:
org.spongepowered.asm.mixin.transformer.throwables.MixinTargetAlreadyLoadedException Critical problem:
carpet.mixins.json:CustomPacketPayload_networkStuffMixin from mod carpet target net.minecraft.network.protocol.common.custom.CustomPacketPayload was loaded too early.

it looks like there are some other reports here, that probably have the same root cause, that that mixin isn't applied

#1922
#1974
#2005
#2016

commented

Encounted with the same problem with Minecraft Server 1.21.4 & Carpet 1.4.161+v241203 & Vivecraft 1.2.5.

The error logs given when a player joins the server:

[09:23:52] [Server thread/INFO]: yqs112358 joined the game
[09:23:52] [Netty Server IO #2/ERROR]: Error sending packet clientbound/minecraft:custom_payload
io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (carpet:hello)
        at knot/net.minecraft.class_9136.handler$zoh000$fabric-networking-api-v1$encode(class_9136.java:547) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9136.method_56426(class_9136.java:55) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9136.encode(class_9136.java:14) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_2545.method_10838(class_2545.java:26) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_2545.encode(class_2545.java:12) ~[server-intermediary.jar:?]
        at knot/io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:113) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/net.minecraft.class_2535$2.write(class_2535.java:530) ~[server-intermediary.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:956) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:982) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:950) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:1000) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:974) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:305) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/net.minecraft.class_2535.method_36942(class_2535.java:350) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_2535.method_52917(class_2535.java:345) ~[server-intermediary.jar:?]
        at knot/io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173) ~[netty-common-4.1.115.Final.jar:?]
        at knot/io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166) ~[netty-common-4.1.115.Final.jar:?]
        at knot/io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.115.Final.jar:?]
        at knot/io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[netty-transport-4.1.115.Final.jar:?]
        at knot/io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.115.Final.jar:?]
        at knot/io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.115.Final.jar:?]
        at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.ClassCastException: class carpet.network.CarpetClient$CarpetPayload cannot be cast to class net.minecraft.class_8711 (carpet.network.CarpetClient$CarpetPayload and net.minecraft.class_8711 are in unnamed module of loader 'knot' @490ab905)
        at knot/net.minecraft.class_9139$8.encode(class_9139.java:44) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_8710$1.method_56489(class_8710.java:52) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_8710$1.method_56490(class_8710.java:57) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_8710$1.encode(class_8710.java:39) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9139$10.encode(class_9139.java:83) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9139$11.method_56442(class_9139.java:99) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9139$11.encode(class_9139.java:89) ~[server-intermediary.jar:?]
        at knot/net.minecraft.class_9136.method_56426(class_9136.java:53) ~[server-intermediary.jar:?]
        ... 31 more
[09:23:52] [Server thread/INFO]: yqs112358 lost connection: Internal Exception: io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (carpet:hello)
[09:23:52] [Server thread/INFO]: yqs112358 left the game

I think it's a serious problem that need to be treated instantly, as there are several other mods reporting the same incompatibility. @gnembon

commented

Bumping this, as I've encountered the same issue: Vivecraft issue