From 69d0f5830dedd191af28282e152f2d5cacbf8d4a Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 5 Jan 2021 08:11:11 +0500 Subject: [PATCH] feat(mover): :sparkles: add close(er) command to follow / come closer --- lib/plugins/command.js | 14 ++++++++++++-- lib/plugins/mover.js | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/plugins/command.js b/lib/plugins/command.js index 318397c..7ef7d78 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -196,7 +196,14 @@ function command(username, message) { subcommand("go follow " + message_parts.slice(2).join(" ")) break; case "come": - subcommand("go follow once") + switch (message_parts[1]) { + case "close": + case "closer": + subcommand("go follow close") + break + default: + subcommand("go follow once") + } break; case "move": case "go": @@ -252,11 +259,14 @@ function command(username, message) { cfg.plugins.mover.follow(bot.nearestEntity()) break case 1: + let dist = 3 switch (message_parts2[0]) { + case "close": + dist = 1 case "me": case "once": if (player) { - cfg.plugins.mover.follow(player, message_parts2[0] !== "once") + cfg.plugins.mover.follow(player, message_parts2[0] === "me", dist) } else { cfg.quiet || bot.chat("can't see you") } diff --git a/lib/plugins/mover.js b/lib/plugins/mover.js index 21bada2..c0c6e2b 100644 --- a/lib/plugins/mover.js +++ b/lib/plugins/mover.js @@ -37,7 +37,7 @@ function moveNear(pos, distance = 3) { bot.pathfinder.setGoal(new GoalNear(pos.x, pos.y, pos.z, distance)) } -function follow(entity, dynamic = true) { +function follow(entity, dynamic = true, distance = 3) { console.assert(entity) const { GoalFollow } = require('mineflayer-pathfinder').goals @@ -53,7 +53,7 @@ function follow(entity, dynamic = true) { // console.log(entity) bot.pathfinder.setMovements(movements.defaultMove) - bot.pathfinder.setGoal(new GoalFollow(entity, 3), dynamic) + bot.pathfinder.setGoal(new GoalFollow(entity, distance), dynamic) } function hit(blockOrEntity) {