[SPIGOT-7947] addPassenger doesn't work if the vehicle is a player Created: 05/Nov/24  Updated: 25/Dec/24  Resolved: 06/Nov/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Traks Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Version: CraftBukkit version 4372-Spigot-e65d67a-7b44d46 (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

This was reported for an older version at https://hub.spigotmc.org/jira/browse/SPIGOT-7048, but the bug has resurfaced again in 1.21.3. It's not possible to make e.g. a cow ride a player with addPassenger at the moment.

The plugin attached in the old report can be used to test this. Do note that the first addPassenger call in the onInteract method should be removed, otherwise the second call will always print false regardless of whether the issue is fixed.

The cause of the issue is this line:

// Entity#startRiding(Entity entity, boolean flag)
} else if (!this.level().isClientSide() && !entity.type.canSerialize()) {
    return false;
}

If "entity" (the vehicle) is a player, the canSerialize call returns false (because the construction of the PLAYER entity type in EntityTypes involves a noSave call).

A simple fix is changing that line to this

} else if (!flag && !this.level().isClientSide() && !entity.type.canSerialize()) {
    return false;
}

Though I'm not sure if this breaks anything. At least it works as expected when you relog: if you log out with a cow on your head and log back in, the cow will still be there (but no longer on your head).

By the way, I was wondering whether I should comment on the old report or make a new report, but opted for the latter in the end. Not sure what y'all prefer.


Generated at Sun Dec 14 07:56:33 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.