Compare commits
8 Commits
974d460061
...
2f88eedce9
Author | SHA1 | Date | |
---|---|---|---|
|
2f88eedce9 | ||
|
a0893f2b29 | ||
|
b1a592dbbd | ||
|
f336e3d736 | ||
|
d953bd4cf6 | ||
|
fc43985337 | ||
|
6b1157147d | ||
|
e6d29576e7 |
|
@ -217,6 +217,17 @@ 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)
|
||||
|
@ -318,18 +329,6 @@ 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;
|
||||
|
|
|
@ -67,12 +67,12 @@ function follow(entity, dynamic = true, distance = 3) {
|
|||
console.assert(entity)
|
||||
const { GoalFollow } = require('mineflayer-pathfinder').goals
|
||||
|
||||
cfg.quiet && console.log(entity)
|
||||
|| bot.chat(
|
||||
`following ${entity.type
|
||||
}: ${entity.username || entity.displayName
|
||||
}${dynamic ? "" : " once"}`
|
||||
)
|
||||
// console.log(entity)
|
||||
cfg.quiet || bot.chat(
|
||||
`following ${entity.type
|
||||
}: ${entity.username || entity.displayName
|
||||
}${dynamic ? "" : " once"}`
|
||||
)
|
||||
|
||||
entity = entity.entity ? entity.entity : entity
|
||||
|
||||
|
@ -82,6 +82,38 @@ 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}`)
|
||||
}
|
||||
|
@ -194,21 +226,25 @@ function command(message_parts, player) {
|
|||
break
|
||||
}
|
||||
break
|
||||
case "ride":
|
||||
case "mount":
|
||||
ride(message_parts2[0])
|
||||
break
|
||||
case "w":
|
||||
case "f":
|
||||
command(["forward"].concat(message_parts.slice(1)))
|
||||
moveOrRide(0, -1, "forward", message_parts2)
|
||||
break
|
||||
case "s":
|
||||
case "b":
|
||||
command(["back"].concat(message_parts.slice(1)))
|
||||
moveOrRide(0, 1, "back", message_parts2)
|
||||
break
|
||||
case "a":
|
||||
case "l":
|
||||
command(["right"].concat(message_parts.slice(1)))
|
||||
moveOrRide(1, -1, "right", message_parts2)
|
||||
break
|
||||
case "d":
|
||||
case "r":
|
||||
command(["left"].concat(message_parts.slice(1)))
|
||||
moveOrRide(1, 1, "left", message_parts2)
|
||||
break
|
||||
case "back":
|
||||
case "forward":
|
||||
|
@ -220,7 +256,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, 200 * (message_parts[1] || 1), message_parts[0], false)
|
||||
setTimeout(bot.setControlState, 100 * (message_parts[1] || 2), message_parts[0], false)
|
||||
setTimeout(console.info, 5000, bot.controlState[message_parts[0]], bot.entity.position.floored())
|
||||
break
|
||||
case "stop":
|
||||
|
@ -256,4 +292,9 @@ const unload = () => {
|
|||
bot.off('goal_reached', goalReached)
|
||||
}
|
||||
|
||||
module.exports = { load, unload, command, stop, initMoves, moveNear, moveXZ, moveY, follow }
|
||||
module.exports = {
|
||||
load, unload, command,
|
||||
stop, initMoves,
|
||||
moveNear, moveXZ, moveY, follow,
|
||||
ride
|
||||
}
|
Loading…
Reference in New Issue
Block a user