CuboidDroid / cuboidmod

CuboidDroid's Support Mod for Cuboid Outpost modpack
GNU Lesser General Public License v3.0
0 stars 1 forks source link

[1.20.1-0.3.2] Asymmetric network buffer packing/unpacking in QuantumCollapsingRecipe.java #13

Closed TigerWalts closed 2 weeks ago

TigerWalts commented 1 month ago

Unable to connect to a server. Client gets either a ResourceLocationException or some other Netty Error.

Problem experienced in Cuboid Outpost LE 0.5. Added the Connectivity mod to the client to narrow it down to Recipe packets and the QuantumCollapsingRecipe class.

Disabling Cuboid Mod removes the problem. Running just Cuboid Mod and its dependencies is enough to cause the problem.

The network (de)serialization uses writeInt to serialize but readVarInt to deserialize some of the values:

https://github.com/CuboidDroid/cuboidmod/blob/4e0012837436d8419a21a6ab6b3a36bc7cb7bf6a/src/main/java/com/cuboiddroid/cuboidmod/modules/collapser/recipe/QuantumCollapsingRecipe.java#L213-L229

TigerWalts commented 1 month ago

I rebuilt the mod from source with the writeInt()s in toNetwork() replaced with writeVarInt().

 @Override 
 public void toNetwork(FriendlyByteBuf buf, QuantumCollapsingRecipe recipe) { 
     buf.writeVarInt(recipe.workTicks); 
     buf.writeVarInt(recipe.inputAmount); 
     recipe.ingredient.toNetwork(buf); 
     buf.writeItemStack(recipe.result, false); 
 } 

Installing the rebuilt mod on the server I was able to connect.