diff --git a/utils/coder.js b/utils/coder.js index 760142d..9549447 100644 --- a/utils/coder.js +++ b/utils/coder.js @@ -102,7 +102,7 @@ export class Coder { this.agent.bot.abort_code = true; this.agent.bot.collectBlock.cancelTask(); this.agent.bot.pathfinder.stop(); - await new Promise(resolve => setTimeout(resolve, 2000)); + await new Promise(resolve => setTimeout(resolve, 1000)); } this.current_code = ''; this.abort_code = false; diff --git a/utils/skills.js b/utils/skills.js index 893aa9c..b978ded 100644 --- a/utils/skills.js +++ b/utils/skills.js @@ -198,7 +198,7 @@ export async function goToPlayer(bot, username) { export async function followPlayer(bot, username) { /** - * Follow the given player endlessly. + * Follow the given player endlessly. Will not return until the code is manually stopped. * @param {MinecraftBot} bot, reference to the minecraft bot. * @param {string} username, the username of the player to follow. * @returns {Promise} true if the player was found, false otherwise. @@ -210,10 +210,11 @@ export async function followPlayer(bot, username) { return false; bot.pathfinder.setMovements(new pf.Movements(bot)); - while (!bot.abort) { + bot.pathfinder.setGoal(new pf.goals.GoalFollow(player, 2), true); + + while (!bot.abort_code) { await new Promise(resolve => setTimeout(resolve, 1000)); - let pos = player.position; - await bot.pathfinder.goto(new pf.goals.GoalNear(pos.x, pos.y, pos.z, 3)); } + return true; } \ No newline at end of file