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

Casting rod always casts directly south #3537

Open
Zetaphor opened this issue Dec 30, 2024 · 2 comments
Open

Casting rod always casts directly south #3537

Zetaphor opened this issue Dec 30, 2024 · 2 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Zetaphor
Copy link

Zetaphor commented Dec 30, 2024

  • [X ] The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.23.0
  • server: vanilla 1.21.1
  • node: 22.12.1

Detailed description of a problem

Whenever I use the bot.fish command, the rod is always cast directly south, regardless of what direction the bot is looking (head) or facing (body).

What did you try yet?

I've tried using both a look and a lookAt before using either the bot.fish or the bot.activate command.

It appears as though the direction is being hardcoded into the activate command

Your current code

const nearestWaterBlock = this.bot.helpers.world.findNearestWaterBlock(this.bot)
if (nearestWaterBlock) {
  console.log('Nearest water block:', nearestWaterBlock)
  const dx = nearestWaterBlock.x - currentPos.x
  const dy = nearestWaterBlock.y - currentPos.y
  const dz = nearestWaterBlock.z - currentPos.z
  const yaw = Math.atan2(-dx, dz)
  const groundDistance = Math.sqrt(dx * dx + dz * dz)
  const pitch = Math.atan2(dy, groundDistance)
  await this.bot.look(yaw, pitch, true)
  await new Promise(resolve => setTimeout(resolve, 1000))
} else {
  this.bot.chat('No water block found nearby.')
  return
}

this.bot.fish() // I've also tried just this.bot.activateItem()

In the above code the bot will look at the water block as expected, then after the 1 second delay it will cast the rod and change its look direction to the south.

Expected behavior

I expect the fish/activateItem function to not override the look direction

@Zetaphor Zetaphor added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Dec 30, 2024
@Zetaphor
Copy link
Author

Zetaphor commented Dec 30, 2024

I've identified the issue, it's not the direction but the hardcoded rotation

@Zetaphor
Copy link
Author

I've found that passing false to the rotation value in the client.write resolves this issue. I'm not sure if that means this value can be omitted or if the boolean is valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant