The bug
When killing mobs, they usually are knocked back when they die. But there are a few mobs for which this is no longer the case.
Affected mobs
It seems like all rideable mobs are affected:
Pigs
Horses
Donkeys
Mules
Llamas
Trader llamas
Skeleton horses
Zombie horses
Striders
Camels
Video
[media]Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 5
Attachments
Comments 9
This is very likely caused by the fix of MC-109954.
The mobs listed above all override the method LivingEntity::travel
which controls the movement logic for mobs and players alike. Horses, donkeys, mules, llamas, trader llamas, zombie horses and skeleton horses all extend the same base class called AbstractHorse
. Pigs and striders implement the interface ItemSteerable
which handles its movement when ridden while its rider is holding the needed item for steering.
In the beginning of this method, these mobs checks if it is alive, which means all motion is skipped when it is dead. This check was likely put to stop these mobs moving when dying while being ridden. This check should be removed from the travel method and instead the method LivingEntity::isImmobile
should be overridden which if true stop all AI logic for mobs. By default this method returns LivingEntity::isDeadOrDying
. It seems this was attempted in the AbstractHorse
class, however there is a simple mistake. Instead of this:
protected boolean isImmobile() {
return super.isImmobile() && this.isVehicle() && this.isSaddled() || this.isEating() || this.isStanding();
}
The logical AND should be replaced with logical OR after super.isImmobile()
, like this:
protected boolean isImmobile() {
return super.isImmobile() || this.isVehicle() && this.isSaddled() || this.isEating() || this.isStanding();
}
The above code should be applied to pigs and striders as well without the specific horse methods.
Relates to MCPE-19222