mojira.dev
MC-270878

Sniffer digging does not account for scale attribute

Sniffers digging into the ground does not account for the scale attribute, resulting in the sniffer being able to dig multiple blocks away from their own position, or dig far too close to their inner hitbox at larger scales.

Steps to Reproduce:

  1. Create a super flat world

  2. Summon/spawn a sniffer

  3. Scale it downward to 0.25

    /attribute @e[type=minecraft:sniffer,limit=1] minecraft:scale base set 0.25
  4. Wait for it to sniff a block

Observed Behavior:

The sniffer will play the animation as expected, but the block they dig over (and the block that shows particles) will be upwards of 2-3 blocks away from themselves. The behavior when scaling the sniffer upwards will be that the sniffer digs central to it's hitbox, disregarding it's head position.

Expected Behavior:

The sniffer in all cases would dig where it's head enters the ground, underneath it's hitbox.

Screenshots/Videos:

[media]

Code Analysis:

(From @unknown in this comment)
The SnifferEntity#getDigLocation method uses a constant value of 2.25 when calculating the magnitude of the vector from the entity's rotation and bottom-center position, which is proportional to the typical sniffer's dimensions. A scaled sniffer, however, does not scale this constant value. A proposed fix is to use the expression 2.25 * this.getScale() instead.

Linked issues

Attachments

Comments 1

Code analysis (Yarn mappings)

The SnifferEntity#getDigLocation method uses a constant value of 2.25 when calculating the magnitude of the vector from the entity's rotation and bottom-center position, which is proportional to the typical sniffer's dimensions. A scaled sniffer, however, does not scale this constant value. A proposed fix is to use the expression 2.25 * this.getScale() instead.

[Mod] Jingy

(Unassigned)

Confirmed

Platform

Low

Commands

attribute, mob-behavior, scale, sniffer, sniffer_dig

23w51a, 24w13a, 1.20.5 Pre-Release 4, 1.20.5, 1.20.6 Release Candidate 1, 1.20.6, 24w19b, 1.21

Retrieved