PrismarineJS / mineflayer-pathfinder

Pathfinding plugin that gives bot the ability to go from A to B
MIT License
222 stars 67 forks source link

GoalLookAtBlock uses collision boxes. It should use selection boxes. #341

Open BF5258 opened 1 month ago

BF5258 commented 1 month ago

GoalLookAtBlock.isEnd uses world.raycast to check if the target is visible from the current node. world.raycast only checks for collision boxes, not selection boxes.

These pages explain the difference: Collision box Selection box

Some blocks do not have collision boxes. Without a collision box to detect, the raycast will always fail. This prevents the agent recognizing when the goal has been reached. This prevents mineflayer-collectblocks collecting these blocks.

Code:

mineflayer-pathfinder\lib\goals.js line 195: const rayPos = this.world.raycast(startPos, targetPos.clone().subtract(startPos).normalize(), this.reach)?.position prismarine-world\worldsync.js line 52: const intersect = iter.intersect(block.shapes, position)

Steps to reproduce:

Expected result:

Bot looks at the block's selection box.

Observed result:

Bot moves towards the block but never marks the goal as complete.

Affected blocks include but are not limited to:

Possible steps to fix:

BF5258 commented 1 month ago

Does minecraft-data have data for selection boxes?