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

fix pathfinder not sprint jumping #338

Closed
wants to merge 1 commit into from

Conversation

qwqtoday
Copy link

No description provided.

@qwqtoday
Copy link
Author

qwqtoday commented May 22, 2024

umm what, this doesn't seem like to be my fault
(it works fine in local)

@IceTank
Copy link
Collaborator

IceTank commented May 22, 2024

What does this change about the behavior? Does it just sprint jump over block gaps or also on flat terrain?

@qwqtoday
Copy link
Author

What does this change about the behavior? Does it just sprint jump over block gaps or also on flat terrain?

if you look at the original code you will see this

@qwqtoday qwqtoday closed this May 23, 2024
@qwqtoday
Copy link
Author

Oops i accidentally closed it

@qwqtoday qwqtoday reopened this May 23, 2024
@qwqtoday
Copy link
Author

What does this change about the behavior? Does it just sprint jump over block gaps or also on flat terrain?

If you look at the original code you will see this

if (bot.entity.isInWater) {
      bot.setControlState('jump', true)
      bot.setControlState('sprint', false)
    } else if (stateMovements.allowSprinting && physics.canStraightLine(path, true)) {
      bot.setControlState('jump', false)
      bot.setControlState('sprint', true)
    } else if (stateMovements.allowSprinting && physics.canSprintJump(path)) {
      bot.setControlState('jump', true)
      bot.setControlState('sprint', true)
    } else if (physics.canStraightLine(path)) {
      bot.setControlState('jump', false)
      bot.setControlState('sprint', false)
    } else if (physics.canWalkJump(path)) {
      bot.setControlState('jump', true)
      bot.setControlState('sprint', false)
    } else {
      bot.setControlState('forward', false)
      bot.setControlState('sprint', false)
    }

The code first check is the bot in water, and it does make the bot start jumping but not sprinting, but if it’s something else like sprinting is allowed and the bot can go straight line to that direction, it makes the bot start sprinting without jumping, after that it checks can the bot sprint jumping and is sprinting allowed, but wait, if the bot can go sprint jump to that location, it also means that it can go straight line into that location. But the code checks the bot goes straight line first, so it will skip everything and never starts sprint jumping.
My change solved it by first let the bot check can it sprint jump then it let the bot sprint jump then check can it go straight line

@qwqtoday
Copy link
Author

這是一個if else if先後次序問題,原本是先檢查不可以直線走過去,然後就檢查是不是可以用跑跳過去,能跑跳過去即代表可以直線走過去,先檢查服務可否直線走過去意味着會直接跳過檢查跑跳過去

@qwqtoday qwqtoday closed this May 23, 2024
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

Successfully merging this pull request may close these issues.

2 participants