mojira.dev
MC-269290

Sniffers store wrong coordinates in sniffer_explored_positions

Sniffers use the sniffer_explored_positions list to store the last 20 "sniffed" locations.

The bug is that the coordinates that are stored are based on where the sniffer is standing, but they are checked against the position of a block where the sniffer's head digs. That means that even if a sniffer is stuck on a block he can continue digging seeds forever.

Steps

  1. Sniffer (center) is standing on a block (e.g. [0,64,0])

  2. Sniffer digs at location of his head (2.25 from center of body) (e.g. [2,64,0])

  3. Sniffers position is added to sniffer_explored_positions: [[0,64,0]]

  4. After cooldown, sniffer tries to sniff again at the same position of its head [2,64,0], it checks the sniffer_explored_positions list. Since [2,64,0] is not there he is allowed to dig for another seed even though he didn't move at all.

  5. Sniffers position is added to sniffer_explored_positions leading to duplicates. So the list is now [[0,64,0], [0,64,0]]

This can continue happening forever.

Expected Results

The game should store position of the block the sniffer digs rather than the sniffer's position.

Linked issues

Attachments

Comments 2

Plausible based on code analysis: Sniffer#onDiggingComplete uses this.getOnPos() when storing the block position, while Sniffer#canDig uses this.getHeadBlock().below(), which in turn uses this.position().add(this.getForward().scale(2.25))

BS-Harou

(Unassigned)

Confirmed

Gameplay

Important

Mob behaviour

1.20.4, 24w10a, 1.20.5, 1.21, 1.21.4

Retrieved