Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks
BF5258 opened this issue Sep 24, 2024 · 1 comment
Open
3 tasks

Comments

@BF5258
Copy link

BF5258 commented Sep 24, 2024

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:

  • place a block with no collision box
  • const goal = new mineflayer_pathfinder_1.goals.GoalLookAtBlock(blockWithNoCollision, bot.world); bot.pathfinder.goto(goal);

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:

  • water
  • pressure plates
  • buttons
  • fire
  • torches

Possible steps to fix:

  • Add block.selectionShapes with data about selection boxes.
  • Update the documentation of block.shapes to make the difference between selection and collision boxes clearer.
  • Add an option to WorldSync.raycast to check for selection boxes instead of collision or create a matcher for this.
@BF5258
Copy link
Author

BF5258 commented Sep 24, 2024

Does minecraft-data have data for selection boxes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant