EncoderException when sending FallingTreeConfigPacket to client
SimplyYourAverageDev opened this issue ยท 3 comments
Describe the bug
Description
When a player joins the server, the mod is failing to send a custom configuration packet to the client, resulting in an EncoderException
being thrown. The stack trace indicates that there is a ClassCastException
when trying to encode the FallingTreeConfigPacket
payload.
Steps to Reproduce
- Start the Minecraft server with the FallingTree mod installed.
- Join the server as a player.
Expected Behavior
The mod should successfully send the configuration packet to the client without any exceptions.
Actual Behavior
The server throws an EncoderException
with the following error message:
io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (fallingtree:configuration-packet)
Caused by: java.lang.ClassCastException: class fr.rakambda.fallingtree.fabric.network.FallingTreeConfigPacket cannot be cast to class net.minecraft.class_8711
Minecraft version
1.20.6
Fabric API version
fabric-api-0.97.8+1.20.6
Mod version
1.20.6.1
Configuration
{
"trees": {
"allowedLogs": [],
"deniedLogs": [],
"allowedLeaves": [],
"allowedNonDecayLeaves": [],
"deniedLeaves": [],
"breakMode": "INSTANTANEOUS",
"detectionMode": "WHOLE_TREE",
"maxScanSize": 500,
"maxSize": 100,
"maxLeafDistanceFromLog": 15,
"maxSizeAction": "ABORT",
"breakOrder": "FURTHEST_FIRST",
"minimumLeavesAroundRequired": 1,
"includePersistentLeavesInRequiredCount": true,
"treeBreaking": true,
"leavesBreaking": true,
"leavesBreakingForceRadius": 0,
"allowMixedLogs": false,
"breakNetherTreeWarts": true,
"breakMangroveRoots": true,
"searchAreaRadius": -1,
"allowedAdjacentBlocks": [],
"adjacentStopMode": "STOP_ALL"
},
"tools": {
"allowed": [],
"denied": [],
"preserve": false,
"ignoreTools": false,
"damageMultiplicand": 1.0,
"damageRounding": "ROUND_DOWN",
"speedMultiplicand": 0.0,
"forceToolUsage": false
},
"player": {
"allowedTags": []
},
"enchantment": {
"registerEnchant": false,
"registerSpecificEnchant": false,
"hideEnchant": false,
"requireEnchantment": false
},
"sneakMode": "SNEAK_DISABLE",
"breakInCreative": false,
"lootInCreative": true,
"notificationMode": "ACTION_BAR"
}
Relevant log output
[13:24:41] [User Authenticator #1/INFO]: UUID of player YourAverageDev is bbe2b169-ed14-4b0b-85a5-e3ebceccf41c
[13:24:41] [Netty Epoll Server IO #0/ERROR]: Error sending packet clientbound/minecraft:custom_payload
io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (fallingtree:configuration-packet)
at net.minecraft.network.handler.PacketCodecDispatcher.handler$zej000$fabric-networking-api-v1$encode(PacketCodecDispatcher.java:547) ~[server-intermediary.jar:?]
at net.minecraft.network.handler.PacketCodecDispatcher.encode(PacketCodecDispatcher.java:55) ~[server-intermediary.jar:?]
at net.minecraft.network.handler.PacketCodecDispatcher.encode(PacketCodecDispatcher.java:14) ~[server-intermediary.jar:?]
at net.minecraft.network.handler.EncoderHandler.encode(EncoderHandler.java:26) ~[server-intermediary.jar:?]
at net.minecraft.network.handler.EncoderHandler.encode(EncoderHandler.java:12) ~[server-intermediary.jar:?]
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:113) ~[netty-transport-4.1.97.Final.jar:?]
at net.minecraft.network.ClientConnection$2.write(class_2535.java:518) ~[server-intermediary.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[netty-transport-4.1.97.Final.jar:?]
at net.minecraft.network.ClientConnection.sendInternal(ClientConnection.java:342) ~[server-intermediary.jar:?]
at net.minecraft.network.ClientConnection.sendImmediately(ClientConnection.java:335) ~[server-intermediary.jar:?]
at net.minecraft.network.ClientConnection.send(ClientConnection.java:317) ~[server-intermediary.jar:?]
at net.minecraft.server.network.ServerCommonNetworkHandler.send(ServerCommonNetworkHandler.java:151) ~[server-intermediary.jar:?]
at net.minecraft.server.network.ServerCommonNetworkHandler.sendPacket(ServerCommonNetworkHandler.java:142) ~[server-intermediary.jar:?]
at net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking.send(ServerConfigurationNetworking.java:222) ~[fabric-networking-api-v1-4.0.8+0dca0349ff-2294ced5f266771f.jar:?]
at fr.rakambda.fallingtree.fabric.network.FabricServerPacketHandler.lambda$registerServer$0(FabricServerPacketHandler.java:18) ~[FallingTree-1.20.6-1.20.6.1.jar:?]
at net.fabricmc.fabric.api.networking.v1.ServerConfigurationConnectionEvents.lambda$static$2(ServerConfigurationConnectionEvents.java:61) ~[fabric-networking-api-v1-4.0.8+0dca0349ff-2294ced5f266771f.jar:?]
at net.fabricmc.fabric.impl.networking.server.ServerConfigurationNetworkAddon.configuration(ServerConfigurationNetworkAddon.java:67) ~[fabric-networking-api-v1-4.0.8+0dca0349ff-2294ced5f266771f.jar:?]
at net.minecraft.server.network.ServerConfigurationNetworkHandler.handler$zfe000$fabric-networking-api-v1$onClientReady(ServerConfigurationNetworkHandler.java:616) ~[server-intermediary.jar:?]
at net.minecraft.class_8610.method_52409(class_8610.java) ~[server-intermediary.jar:?]
at net.fabricmc.fabric.impl.networking.server.ServerConfigurationNetworkAddon.receiveRegistration(ServerConfigurationNetworkAddon.java:94) ~[fabric-networking-api-v1-4.0.8+0dca0349ff-2294ced5f266771f.jar:?]
at net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon.handle(AbstractChanneledNetworkAddon.java:80) ~[fabric-networking-api-v1-4.0.8+0dca0349ff-2294ced5f266771f.jar:?]
at net.minecraft.server.network.ServerCommonNetworkHandler.handler$zfd000$fabric-networking-api-v1$handleCustomPayloadReceivedAsync(ServerCommonNetworkHandler.java:541) ~[server-intermediary.jar:?]
at net.minecraft.class_8609.method_52392(class_8609.java) ~[server-intermediary.jar:?]
at net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket.apply(CustomPayloadC2SPacket.java:36) ~[server-intermediary.jar:?]
at net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket.apply(CustomPayloadC2SPacket.java:15) ~[server-intermediary.jar:?]
at net.minecraft.network.ClientConnection.handlePacket(ClientConnection.java:200) ~[server-intermediary.jar:?]
at net.minecraft.network.ClientConnection.channelRead0(ClientConnection.java:185) ~[server-intermediary.jar:?]
at net.minecraft.network.ClientConnection.channelRead0(ClientConnection.java:69) ~[server-intermediary.jar:?]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:202) ~[netty-handler-4.1.97.Final.jar:?]
at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:164) ~[netty-handler-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:333) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:454) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) ~[netty-handler-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.97.Final.jar:?]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800) ~[netty-transport-classes-epoll-4.1.97.Final.jar:?]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:509) ~[netty-transport-classes-epoll-4.1.97.Final.jar:?]
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407) ~[netty-transport-classes-epoll-4.1.97.Final.jar:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar:?]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.ClassCastException: class fr.rakambda.fallingtree.fabric.network.FallingTreeConfigPacket cannot be cast to class net.minecraft.class_8711 (fr.rakambda.fallingtree.fabric.network.FallingTreeConfigPacket and net.minecraft.class_8711 are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @57ad2aa7)
at net.minecraft.network.codec.PacketCodec$6.encode(class_9139.java:42) ~[server-intermediary.jar:?]
at net.minecraft.network.packet.CustomPayload$1.encode(class_8710.java:52) ~[server-intermediary.jar:?]
at net.minecraft.network.packet.CustomPayload$1.encode(class_8710.java:57) ~[server-intermediary.jar:?]
at net.minecraft.network.packet.CustomPayload$1.encode(class_8710.java:39) ~[server-intermediary.jar:?]
at net.minecraft.network.codec.PacketCodec$8.encode(class_9139.java:81) ~[server-intermediary.jar:?]
at net.minecraft.network.codec.PacketCodec$9.encode(class_9139.java:97) ~[server-intermediary.jar:?]
at net.minecraft.network.codec.PacketCodec$9.encode(class_9139.java:87) ~[server-intermediary.jar:?]
at net.minecraft.network.handler.PacketCodecDispatcher.encode(PacketCodecDispatcher.java:53) ~[server-intermediary.jar:?]
... 81 more
[13:24:41] [Server thread/INFO]: com.mojang.authlib.GameProfile@680bbf50[id=bbe2b169-ed14-4b0b-85a5-e3ebceccf41c,name=YourAverageDev,properties={textures=[Property[name=textures, value=ewogICJ0aW1lc3RhbXAiIDogMTcxNDU4NDI4MDk1MSwKICAicHJvZmlsZUlkIiA6ICJiYmUyYjE2OWVkMTQ0YjBiODVhNWUzZWJjZWNjZjQxYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJZb3VyQXZlcmFnZURldiIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9kMWU1ZDM5MjM1ODMzOGQzOWI0NGUxZjBkNzlkOTM4MDEyYWI5ODdkZWQ2OGQyZTAyZmNjYWQ2Y2JjMmNmNzY3IgogICAgfQogIH0KfQ==, signature=flvgpv6GenlUTVT7vgJdQcwnEMpo3f22JO0FLujZ+H1m5Qg/Z2pkem9E4pE6pvAfzk1gPgaiQCLC0Sm998wYqCiepSyRGShT2WSQKQQ+GqG7OfBU3i1OT+PF8X+O63aMWuA/K1LXU1CDKTjNkgS0A3H2BhrnDsmGd3bZMKHwpGmOVwCXT1bgZpWJcj8eeSoaCzCm6+mXCpAB70u7y/FBkEWrxC5An320HnhPOu3XxiEd7L+RsvFSCMQM/R+iEaiU4DFTyr9Z1uPAtz5aZm0UR1hZS4jU2KSzPuXySqruqqpT5u0+ZvujAlxK2ZMUtrjWPhI0tvFIPkI2r/6Nq03xOCO23a3n92iAve0es0aFcDzcqwOsQF6fjK/ck8IEz05u9ekKpEBIva/HL9a9Ymx4RpgvuhwQ/VlIkqElFygEXwaEIuHI17w7cpmoQ2oi3g3P7m5AaV09kZcPb8EHwMiB6I2AC+9iF2Xq2krpDF98KF6oDJ1bc9BVxeESYv37RY+b3hfKOUSQ5O323d0ioEKyJ/XkNEmU/BrSa8pPbDQboYwxdJPIOH4m4nwwRC6/nMePKM63vMxHYU6ryFtRDEIRyMaWN5oYrvPdI26c6SKU0EtsWoJML9wZwCLR8TFVN7auS6Uilxl0XCOC7jtjs6H8Mm9ShiVvj5mKxvT5Jf19KtQ=]]}] lost connection: Internal Exception: io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:custom_payload' (fallingtree:configuration-packet)
package fr.rakambda.fallingtree.fabric.network;
import fr.rakambda.fallingtree.common.network.ConfigurationPacket;
import fr.rakambda.fallingtree.fabric.FallingTree;
import fr.rakambda.fallingtree.fabric.common.wrapper.FriendlyByteBufWrapper;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
@RequiredArgsConstructor
public class FallingTreeConfigPacket implements CustomPacketPayload {
public static final Type<FallingTreeConfigPacket> TYPE = new Type<>(new ResourceLocation(FallingTree.MOD_ID, "configuration-packet"));
@Getter
private final ConfigurationPacket packet;
@Override
@NotNull
public Type<FallingTreeConfigPacket> type() {
return TYPE;
}
@Override
public void write(FriendlyByteBuf buf) {
packet.write(new FriendlyByteBufWrapper(buf));
}
public static FallingTreeConfigPacket read(FriendlyByteBuf buf) {
return new FallingTreeConfigPacket(ConfigurationPacket.read(new FriendlyByteBufWrapper(buf)));
}
}
Wrote some code to try and fix this bug, this looks good?
It has already been released
https://github.com/RakambdaOrg/FallingTree/releases/tag/1.20.6.2