fix bug in pathfinder

This commit is contained in:
seanspt 2025-06-10 11:39:43 +08:00
parent e930a0b340
commit 512fac9622

View file

@ -1,5 +1,5 @@
diff --git a/node_modules/mineflayer-pathfinder/index.js b/node_modules/mineflayer-pathfinder/index.js
index b38bd30..069c1af 100644
index b38bd30..fb39b45 100644
--- a/node_modules/mineflayer-pathfinder/index.js
+++ b/node_modules/mineflayer-pathfinder/index.js
@@ -170,6 +170,16 @@ function inject (bot) {
@ -19,7 +19,17 @@ index b38bd30..069c1af 100644
if (b && (b.type === waterType || ((b.type === ladderId || b.type === vineId) && i + 1 < path.length && path[i + 1].y < curPoint.y))) {
curPoint.x = Math.floor(curPoint.x) + 0.5
curPoint.y = Math.floor(curPoint.y)
@@ -550,6 +560,7 @@ function inject (bot) {
@@ -524,6 +534,9 @@ function inject (bot) {
bot.activateBlock(bot.blockAt(new Vec3(placingBlock.x, placingBlock.y, placingBlock.z))).then(() => {
lockUseBlock.release()
placingBlock = nextPoint.toPlace.shift()
+ if (!placingBlock) {
+ placing = false
+ }
}, err => {
console.error(err)
lockUseBlock.release()
@@ -550,6 +563,7 @@ function inject (bot) {
lockEquipItem.release()
const refBlock = bot.blockAt(new Vec3(placingBlock.x, placingBlock.y, placingBlock.z), false)
if (!lockPlaceBlock.tryAcquire()) return
@ -27,7 +37,7 @@ index b38bd30..069c1af 100644
if (interactableBlocks.includes(refBlock.name)) {
bot.setControlState('sneak', true)
}
@@ -557,6 +568,7 @@ function inject (bot) {
@@ -557,6 +571,7 @@ function inject (bot) {
.then(function () {
// Dont release Sneak if the block placement was not successful
bot.setControlState('sneak', false)