feat(mover): allow riding specific entity by name

This commit is contained in:
jay 2021-01-28 02:50:08 +05:00
parent b1a592dbbd
commit a0893f2b29

View File

@ -85,14 +85,15 @@ function follow(entity, dynamic = true, distance = 3) {
function ride(entity) {
entity = entity?.entity || entity
const ridableMobs = ["Horse", "Donkey", "Pig", "Strider"]
const vehicle = entity ? entity : bot.nearestEntity(e => {
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 ${message_parts[0]}`)
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)
@ -227,7 +228,7 @@ function command(message_parts, player) {
break
case "ride":
case "mount":
ride()
ride(message_parts2[0])
break
case "w":
case "f":