PrismarineJS / mineflayer-navigate

mineflayer plugin which gives bots a high level 3d navigating API using A*
59 stars 22 forks source link

Bot doesn't jump over a 2 block gap 1 block lower than it. #39

Open GoogleSites opened 5 years ago

GoogleSites commented 5 years ago

Bot keeps getting stuck in this type of scenario:

https://gyazo.com/f9f36242c761fc442da3247542517ab4

Make this and have the bot walk over it and it'll fall each time - doesn't even try to jump the gap.

GoogleSites commented 5 years ago

Here's a video: https://youtu.be/TfIrl4GpYGQ

An easy way to fix this is to have the bot jump - it can make it over easily without sprinting.

GoogleSites commented 5 years ago

Here's another path-finding issue (same type of thing): https://gyazo.com/8ecb5c78b2d921df898fd8d7b6ff48de

rom1504 commented 5 years ago

Indeed looks like a bug related to jumping in mineflayer. You can try to tweak jumping in mineflayer and tweak the way it's used in mineflayer-navigate

GoogleSites commented 5 years ago

For mineflayer-navigate, do you mean this code block?

  } else if (delta.y > -0.1) {
    // possibly jump over a hole
    gottaJump = 1.5 < horizontalDelta && horizontalDelta < 2.5;
  }
  bot.setControlState('jump', gottaJump);
rom1504 commented 5 years ago

Yes

rom1504 commented 5 years ago

I guess it doesn't jump for long enough

GoogleSites commented 5 years ago

Kinda rough but this works. I'll clean it up later.

  if (delta.y > 0.1) {
    // gotta jump up when we're close enough
    gottaJump = horizontalDelta < 1.75;
  } else if (delta.y > -0.1) {
    // possibly jump over a hole
    gottaJump = 1.5 < horizontalDelta && horizontalDelta < 2.5;
  } else if (Math.floor(nextPoint.y) === Math.floor(currentPosition.y - 1)) {
    gottaJump = 1.5 < horizontalDelta && horizontalDelta <= 4;
  }
  bot.setControlState('jump', gottaJump);
GoogleSites commented 5 years ago

better version:

  if (delta.y > 0.1) {
    // gotta jump up when we're close enough
    gottaJump = horizontalDelta < 1.75;
  } else if (delta.y > -0.1) {
    // possibly jump over a hole
    gottaJump = 1.5 < horizontalDelta && horizontalDelta < 2.5;
  } else if (delta.y < -0.1) {
    // possibly jump over a hole 1 block lower
    gottaJump = 3 < horizontalDelta && horizontalDelta <= 4;
  }
  bot.setControlState('jump', gottaJump);