Fabric API

Fabric API

112M Downloads

[1.20.1] Cant fit X into 3 error when joining a server

sirben99 opened this issue ยท 9 comments

commented

Hey!

I have an issue where when i try to join a server, i get an issue where X number cant fit to 3 in a modpack. I have made an issue report to a mod that eliminates package errors, and apparently its an internal Fabric problem that forge does not have.

I have decided to create an issue here on Fabric to see if this error could be solved somehow.

Heres the log of the error: https://pastebin.com/RVXSCttW

Let me know if i can provide anything else to help solve this!

commented

@sirben99 Oh no, that's a lot of mods to debug through... The problem however is clear: someone's sending a very big packet. The problem being, we don't know what it is. And I don't know why this is our issue.

Hi, I made a minimal reproducible example, sending a vanilla like, 130 MB packet:

import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket;
import net.minecraft.recipe.Recipe;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(SynchronizeRecipesS2CPacket.class)
public class SynchronizeRecipesS2CPacketMixin {
    @Unique
    private static final int SIZE = 100;

    @Shadow
    @Final
    private List<Recipe<?>> recipes;

    @Inject(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At("TAIL"))
    private void onInit(PacketByteBuf buf, CallbackInfo ci) {
        for (int i = 0; i < SIZE; i++) {
            buf.readList(SynchronizeRecipesS2CPacket::readRecipe);
        }
    }

    @Inject(method = "write(Lnet/minecraft/network/PacketByteBuf;)V", at = @At("HEAD"))
    private void onRead(PacketByteBuf buf, CallbackInfo ci) {
        for (int i = 0; i < SIZE; i++) {
            buf.writeCollection(this.recipes, SynchronizeRecipesS2CPacket::writeRecipe);
        }
    }
}

Based on SynchronizeRecipesS2CPacket as this is the class having issue due to its size. Triggers only when joining a dedicated server.

Requires PacketFixer.

modImplementation files("./PacketFixer-fabric-1.1.7-1.20.1.jar")
commented

@sirben99 Please provide the full log file.

commented

I tried to post the full log, but its too big for Pastebin. Do you want me to past it as a file here or find another site to paste it on?

commented

@sirben99 Posting it as a file is fine.

commented

Server:
latest.log

Client: latest.log

commented

@sirben99 Oh no, that's a lot of mods to debug through... The problem however is clear: someone's sending a very big packet. The problem being, we don't know what it is. And I don't know why this is our issue.

commented

It is a lot of mods. I have been trying to binary search the modpack for 5 days now, and the issue seems to jump from one mod to another. For example:

I took out Forgero mod, the issue is gone. Added Regions Unexplored mod, issue is back. But if i take out Biome Makeover, the issue is gone, but if i take out Immersive Armous mod and add Biome Makeover back, the issue comes back.

The reason i made the report here is because i got told that its an Fabric specific issue that Forge doesent have and thought it could be looked at somehow (Some way to split large packages?). Although im not sure whats going on anymore... Forgive me, im just a bit tired for sorting this mess for five days.

I did however, took out the mod Chipped (https://www.curseforge.com/minecraft/mc-mods/chipped), and eveything worked without issue with all the mods added. Should i report the issue to them instead?

commented

I found and probably fixed the error and imo this should be handled by PacketFixer.

Tldr.: the PacketSplitter implementation of Mojang only supports up to 21 bits, a fix would be to just increase this limit. But in any case I don't see a relation to fabric here.

commented

We generally do not change the behavior of the network stack (the changes here would require client-side cooperation). Another mod can do this.

For the recipe-specific discussion, i.e. splitting packets ourselves, that's gonna be #2342.