Skip to content

Fabric pre-Via state does not advance when preViaInjection is enabled without ViaVersion #3

@runningbird8

Description

@runningbird8

Describe the bug
I think there is a Fabric regression in the pre-Via/post-Via state split introduced in c44d85c.

On Fabric, when a bundled PE user enables preViaInjection(true), PacketEvents runs a pre-Via packet pass even when ViaVersion is not installed. That pre-Via pass is dispatched only to listeners where isPreVia() == true.

Bukkit registers a second internal pre-Via listener in c44d85c, but Fabric still appears to register only the normal InternalFabricPacketListener. Because of that, the pre-Via connection state can stay behind during login/configuration. A later configuration-phase packet can then be mapped using the stale LOGIN state, and the connection is closed before the player finishes joining.

This seems to affect:

  • Bad: c44d85c10021bd669b63bf529b64d515bd7ad2e8
  • Still bad: 0759fbb4600a3b8eb314fa9027cedc7defbcc14d
  • Last known good in my tests: 22c9961f3aa5e6071c47a0d846cdaeda944af723

0759fbb adjusts decoder state transitions, but it does not seem to add a Fabric pre-Via internal listener or skip the synthetic pre-Via pass when ViaVersion is absent.

Software brand
Fabric 1.21.11

Plugins
Minimal reproduction:

  • Fabric API
  • GrimAC Fabric build bundling PacketEvents

No ViaVersion, ViaFabric, ViaBackwards, or other server mods were required to reproduce it.

How To Reproduce

  1. Start a clean Fabric 1.21.11 server.
  2. Install Fabric API.
  3. Install a GrimAC Fabric build that bundles PE 2.12.2+c44d85c-SNAPSHOT or 2.12.2+0759fbb-SNAPSHOT.
  4. Join the server.
  5. The player disconnects before the backend logs a successful join.

In the same environment:

  • Fabric API only: login succeeds.
  • Grim build with PE 2.12.2+22c9961-SNAPSHOT: login succeeds.
  • Grim build with PE 2.12.2+c44d85c-SNAPSHOT: login fails.
  • Grim build with PE 2.12.2+0759fbb-SNAPSHOT: login fails.

Expected behavior
Fabric should either:

  1. Register an internal pre-Via Fabric listener, equivalent to the Bukkit pre-Via listener added in c44d85c, so pre-Via state transitions are maintained, or
  2. Avoid running the synthetic pre-Via pass on Fabric when ViaVersion is not actually available.

Screenshots
N/A

Additional context
The relevant change looks like c44d85c added separate preViaEncoderState / preViaDecoderState and changed event creation to choose pre-Via or post-Via state based on autoProtocolTranslation.

Fabric PacketDecoder still has this path:

if (!preViaVersion && PacketEvents.getAPI().getSettings().isPreViaInjection() && !ViaVersionUtil.isAvailable(user)) {
    PacketEventsImplHelper.handleServerBoundPacket(ctx.channel(), user, player, msg, false);
}

But Fabric API load still appears to register only:

this.getEventManager().registerListener(new InternalFabricPacketListener());

So the synthetic pre-Via pass runs, but the internal state listener for that pass is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions