Compare commits

..

No commits in common. "2f88eedce93f8490adbc43491d89619e149ceb74" and "974d46006154d4f0cefd09af8e60e0f2964e1ee1" have entirely different histories.

2 changed files with 24 additions and 64 deletions

View File

@ -217,17 +217,6 @@ function command(username, message) {
subcommand("go follow once") subcommand("go follow once")
} }
break; break;
case "ride":
case "mount":
cfg.plugins.mover.command(message_parts)
break
case "unride":
case "getoff":
case "unmount":
case "dismount":
bot.dismount()
bot.vehicle = void 0
break
case "move": case "move":
case "go": case "go":
cfg.plugins.mover.command(message_parts.slice(1), player) cfg.plugins.mover.command(message_parts.slice(1), player)
@ -329,6 +318,18 @@ function command(username, message) {
case "info": case "info":
cfg.plugins.informer.command(message_parts.splice(1)) cfg.plugins.informer.command(message_parts.splice(1))
break break
case "ride":
case "mount":
bot.mount(bot.nearestEntity())
break
case "getoff":
case "unmount":
case "dismount":
bot.dismount()
break
case "go":
bot.moveVehicle(0, 10)
break
// case "use": // case "use":
// bot.useOn(bot.nearestEntity()) // bot.useOn(bot.nearestEntity())
// break; // break;

View File

@ -67,12 +67,12 @@ function follow(entity, dynamic = true, distance = 3) {
console.assert(entity) console.assert(entity)
const { GoalFollow } = require('mineflayer-pathfinder').goals const { GoalFollow } = require('mineflayer-pathfinder').goals
// console.log(entity) cfg.quiet && console.log(entity)
cfg.quiet || bot.chat( || bot.chat(
`following ${entity.type `following ${entity.type
}: ${entity.username || entity.displayName }: ${entity.username || entity.displayName
}${dynamic ? "" : " once"}` }${dynamic ? "" : " once"}`
) )
entity = entity.entity ? entity.entity : entity entity = entity.entity ? entity.entity : entity
@ -82,38 +82,6 @@ function follow(entity, dynamic = true, distance = 3) {
bot.pathfinder.setGoal(new GoalFollow(entity, distance), dynamic) bot.pathfinder.setGoal(new GoalFollow(entity, distance), dynamic)
} }
function ride(entity) {
entity = entity?.entity || entity
const ridableMobs = ["Horse", "Donkey", "Pig", "Strider"]
const vehicle = entity && typeof entity !== "string" ? entity : bot.nearestEntity(e => {
if (typeof entity === "string") return e.name === entity
const maybeRidableMob = e.mobType?.split(" ")
return e.kind == "Vehicles"
|| ridableMobs.includes(e.mobType)
|| maybeRidableMob && ridableMobs.includes(maybeRidableMob[maybeRidableMob.length - 1])
})
if (!vehicle) {
return cfg.quiet || bot.chat(`nothing to ride!`)
} else if ((dist = bot.entity.position.distanceSquared(vehicle.position)) > 36) {
bot.lookAt(vehicle.position)
follow(vehicle, false)
bot.once('goal_reached', ride)
return cfg.quiet || bot.chat(`${vehicle.name} bit far`)
}
console.log("vehicle:", vehicle)
bot.mount(vehicle)
}
function moveOrRide(turn = false, reverse = -1, directionLabel, message_parts2) {
// bot.once("attach", state = "vehiccel")
if (bot.vehicle) {
const amount = parseInt(message_parts2[0]) || 10 * -reverse
bot.moveVehicle(turn && amount || 0, !turn && amount || 0)
} else {
command([directionLabel].concat(message_parts2))
}
}
function hit(blockOrEntity) { function hit(blockOrEntity) {
bot.chat(`hitting ${entity.name || entity.type}`) bot.chat(`hitting ${entity.name || entity.type}`)
} }
@ -226,25 +194,21 @@ function command(message_parts, player) {
break break
} }
break break
case "ride":
case "mount":
ride(message_parts2[0])
break
case "w": case "w":
case "f": case "f":
moveOrRide(0, -1, "forward", message_parts2) command(["forward"].concat(message_parts.slice(1)))
break break
case "s": case "s":
case "b": case "b":
moveOrRide(0, 1, "back", message_parts2) command(["back"].concat(message_parts.slice(1)))
break break
case "a": case "a":
case "l": case "l":
moveOrRide(1, -1, "right", message_parts2) command(["right"].concat(message_parts.slice(1)))
break break
case "d": case "d":
case "r": case "r":
moveOrRide(1, 1, "left", message_parts2) command(["left"].concat(message_parts.slice(1)))
break break
case "back": case "back":
case "forward": case "forward":
@ -256,7 +220,7 @@ function command(message_parts, player) {
console.info(bot.controlState[message_parts[0]], bot.entity.position.floored()) console.info(bot.controlState[message_parts[0]], bot.entity.position.floored())
bot.setControlState(message_parts[0], true) bot.setControlState(message_parts[0], true)
console.info(bot.controlState[message_parts[0]]) console.info(bot.controlState[message_parts[0]])
setTimeout(bot.setControlState, 100 * (message_parts[1] || 2), message_parts[0], false) setTimeout(bot.setControlState, 200 * (message_parts[1] || 1), message_parts[0], false)
setTimeout(console.info, 5000, bot.controlState[message_parts[0]], bot.entity.position.floored()) setTimeout(console.info, 5000, bot.controlState[message_parts[0]], bot.entity.position.floored())
break break
case "stop": case "stop":
@ -292,9 +256,4 @@ const unload = () => {
bot.off('goal_reached', goalReached) bot.off('goal_reached', goalReached)
} }
module.exports = { module.exports = { load, unload, command, stop, initMoves, moveNear, moveXZ, moveY, follow }
load, unload, command,
stop, initMoves,
moveNear, moveXZ, moveY, follow,
ride
}