--- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
@@ -34,8 +34,8 @@
 
             private <T extends CustomPacketPayload> void writeCap(B p_320565_, CustomPacketPayload.Type<T> p_320917_, CustomPacketPayload p_320112_) {
                 p_320565_.writeResourceLocation(p_320917_.id());
-                StreamCodec<B, T> streamcodec = this.findCodec(p_320917_.id);
-                streamcodec.encode(p_320565_, p_320112_);
+                StreamCodec<B, T> streamcodec = (StreamCodec<B, T>)this.findCodec(p_320917_.id);
+                streamcodec.encode(p_320565_, (T)p_320112_);
             }
 
             public void encode(B p_320490_, CustomPacketPayload p_319776_) {
