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")
}
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 "go":
cfg.plugins.mover.command(message_parts.slice(1), player)
@ -329,6 +318,18 @@ function command(username, message) {
case "info":
cfg.plugins.informer.command(message_parts.splice(1))
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":
// bot.useOn(bot.nearestEntity())
// break;

View File

@ -67,8 +67,8 @@ function follow(entity, dynamic = true, distance = 3) {
console.assert(entity)
const { GoalFollow } = require('mineflayer-pathfinder').goals
// console.log(entity)
cfg.quiet || bot.chat(
cfg.quiet && console.log(entity)
|| bot.chat(
`following ${entity.type
}: ${entity.username || entity.displayName
}${dynamic ? "" : " once"}`
@ -82,38 +82,6 @@ function follow(entity, dynamic = true, distance = 3) {
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) {
bot.chat(`hitting ${entity.name || entity.type}`)
}
@ -226,25 +194,21 @@ function command(message_parts, player) {
break
}
break
case "ride":
case "mount":
ride(message_parts2[0])
break
case "w":
case "f":
moveOrRide(0, -1, "forward", message_parts2)
command(["forward"].concat(message_parts.slice(1)))
break
case "s":
case "b":
moveOrRide(0, 1, "back", message_parts2)
command(["back"].concat(message_parts.slice(1)))
break
case "a":
case "l":
moveOrRide(1, -1, "right", message_parts2)
command(["right"].concat(message_parts.slice(1)))
break
case "d":
case "r":
moveOrRide(1, 1, "left", message_parts2)
command(["left"].concat(message_parts.slice(1)))
break
case "back":
case "forward":
@ -256,7 +220,7 @@ function command(message_parts, player) {
console.info(bot.controlState[message_parts[0]], bot.entity.position.floored())
bot.setControlState(message_parts[0], true)
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())
break
case "stop":
@ -292,9 +256,4 @@ const unload = () => {
bot.off('goal_reached', goalReached)
}
module.exports = {
load, unload, command,
stop, initMoves,
moveNear, moveXZ, moveY, follow,
ride
}
module.exports = { load, unload, command, stop, initMoves, moveNear, moveXZ, moveY, follow }