diff --git a/examples/example.js b/examples/example.js index 3697264..85350e3 100644 --- a/examples/example.js +++ b/examples/example.js @@ -14,8 +14,8 @@ const bot = createBot({ // port: 25497 // host: "node2.endelon-hosting.de", port: 31997 - host: 'Ic3TankD2HO.aternos.me', - port: 44656 + host: 'node2.meowbot.de', + port: 5000 // host: "us1.node.minecraft.sneakyhub.com", // port: 25607, }); diff --git a/src/ThePathfinder.ts b/src/ThePathfinder.ts index b1fa794..1d2999b 100644 --- a/src/ThePathfinder.ts +++ b/src/ThePathfinder.ts @@ -165,12 +165,14 @@ export class ThePathfinder { async cancel (allowRetry = false, timeout = 1000): Promise { this.cancelCalculation = true + this.allowRetry = allowRetry if (this.currentExecutor == null) return console.log('no executor') if (this.currentMove == null) throw new Error('No current move, but there is a current executor.') - if (allowRetry) await this.currentExecutor.abort(this.currentMove, { timeout, resetting: allowRetry }) + await this.currentExecutor.abort(this.currentMove, { timeout, resetting: allowRetry }) + console.log('tried cancel frfr') // calling cleanupAll is not necessary as the end of goto already calls it. } @@ -320,6 +322,7 @@ export class ThePathfinder { async * getPathFromTo (startPos: Vec3, startVel: Vec3, goal: goals.Goal, settings = this.defaultMoveSettings): PathGenerator { this.cancelCalculation = false + this.allowRetry = false; this.currentGoal = goal const move = Move.startMove(new IdleMovement(this.bot, this.world), startPos.clone(), startVel.clone(), this.getScaffoldCount()) @@ -438,7 +441,6 @@ export class ThePathfinder { const movementHandler = path.context.movementProvider as MovementHandler const movements = movementHandler.getMovements() - this.allowRetry = false // eslint-disable-next-line no-labels outer: while (currentIndex < path.path.length) { diff --git a/src/mineflayer-specific/movements/movementExecutor.ts b/src/mineflayer-specific/movements/movementExecutor.ts index de1d062..b2d54bc 100644 --- a/src/mineflayer-specific/movements/movementExecutor.ts +++ b/src/mineflayer-specific/movements/movementExecutor.ts @@ -72,7 +72,7 @@ export abstract class MovementExecutor extends Movement { * TODO: Implement. */ public async abort (move: Move = this.currentMove, settings: AbortOpts = {}): Promise { - if (this.cancelled) return + if (this.cancelled || this.resetting) return const timeout = settings.timeout ?? 1000 const resetting = settings.resetting ?? false diff --git a/src/mineflayer-specific/movements/movementExecutors.ts b/src/mineflayer-specific/movements/movementExecutors.ts index 7131bc0..541961e 100644 --- a/src/mineflayer-specific/movements/movementExecutors.ts +++ b/src/mineflayer-specific/movements/movementExecutors.ts @@ -283,8 +283,8 @@ export class ForwardExecutor extends MovementExecutor { throw new CancelError('ForwardMove: not on ground') } if ((this.bot.entity as any).isCollidedHorizontally as boolean) { - // if (this.bot.entity.velocity.offset(0, -this.bot.entity.velocity.y, 0).norm() < 0.02) - // throw new CancelError("ForwardMove: collided horizontally"); + if (this.bot.entity.velocity.offset(0, -this.bot.entity.velocity.y, 0).norm() < 0.02) + throw new CancelError("ForwardMove: collided horizontally"); } const faceForward = await this.faceForward()