-
Type:
New Feature
-
Resolution: Fixed
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
CraftBukkit version 4534-Spigot-7c52c66-65f1f11 (MC: 1.21.8) (Implementing API version 1.21.8-R0.1-SNAPSHOT)
-
Yes
In the current Spigot API, leash functionality is exposed only through the LivingEntity interface:
boolean isLeashed(); @Nullable Entity getLeashHolder(); boolean setLeashHolder(Entity holder);
However, in vanilla Minecraft now, non-living entities (only boats at the moment) can also be attached to a leash. Since these entities are not LivingEntity instances, plugins cannot interact with or even detect this leash state.
For example:
if (ent instanceof LivingEntity && ((LivingEntity) ent).isLeashed()) { Entity holder = ((LivingEntity) ent).getLeashHolder(); }
The above works for mobs but fails for leashed boats. The API provides no alternative method to determine if a non-living entity (like a Boat) is leashed or who its leash holder is.
Observed Behavior
Leashing a boat does trigger the PlayerLeashEntityEvent but the Entity involved is a CraftBoat, not a LivingEntity. As a result, plugins attempting to cast or check leash state via the existing API throw a ClassCastException. Stacktrace for this provided below.
Issue with current implementation
LivingEntity exposes leash methods, but:
- Some LivingEntity subclasses (e.g., ArmorStand, ComplexLivingEntity, Player) cannot actually be leashed.
- Some non-living entities (like Boat) can be leashed but do not implement LivingEntity.
This creates a mismatch where the API’s type does not accurately represent leashable entities.
Ideally a dedicated Leashable interface to represent all entities capable of being leashed, regardless of whether they are living would be ideal. LivingEntity could extend this interface to maintain backward compatibility, if so desired, while other leashable entities (such as Boat) implement it directly?
Thanks for reading!