mojira.dev
MC-148458

Ridable mobs aren't knocked back upon death

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

Attachments

Comments 9

This is very likely caused by the fix of MC-109954

Can confirm in 21w06a.

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.

Can confirm in 1.17.1.

Can confirm in 1.18.2 and 22w13a.

Can confirm in 1.19.

Can confirm in 1.19.2.

Th0mas_02

(Unassigned)

Confirmed

Low

Mob behaviour

Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 3, 1.15 Pre-release 6, 1.15.1, 1.15.2, ..., 1.18.2, 22w13a, 1.19, 1.19.2, 1.19.3

1.19.4 Pre-release 3

Retrieved