mojira.dev
MC-195035

Ridden horses can be saddled by right-clicking

The bug

Horses being ridden by another player or entity can be saddled by right-clicking on them while holding a saddle. This is likely unintended as:

  • opening/interacting with the inventory of a ridden horse is otherwise disabled for all players except the rider,

  • this issue doesn't affect horse armour, and

  • this issue doesn't affect llamas being equipped with carpets.

How to reproduce

  1. Summon a tamed horse ridden by an entity:

    /summon horse ~ ~ ~ {Tame:1,Passengers:[{id:chicken}]}
  2. Attempt to open the horse's inventory by right-clicking on it while sneaking
    → ✔ The horse's inventory cannot be accessed by you, as you are not the rider

  3. Without sneaking, right-click on the horse while holding a saddle
    → ❌ The horse is equipped with the saddle

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Comments 7

Can confirm for 1.16.4-pre2

This issue still exists in Minecraft 1.19.4 pre-release 1. In addition, it affects all saddleable entities.

Code analysis (Yarn mappings)

Each implementation of the Saddleable#canBeSaddled method does not check the entity's passengers.

The suggested fix would be to check the Entity#hasPassengers method within each implementation of the Saddleable#canBeSaddled method. For example:

@Override
public boolean canBeSaddled() {
	return this.isAlive() && !this.isBaby() && this.isTame() && !this.hasPassengers();
}

This issue still exists in Minecraft 1.19.4 release candidate 3.

This issue still exists in Minecraft snapshot 23w14a.

This issue has been fixed for the horse.

Can still reproduce for horses.

Camels' inventories aren't locked while they're ridden, so I've removed them from this ticket.

j_p_smith

(Unassigned)

Confirmed

Items

1.16.1, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, ..., 24w12a, 1.20.6, 1.21, 1.21.3, 1.21.5

Retrieved