feat(mover): ✨ allow riding specific entity by name
This commit is contained in:
parent
b1a592dbbd
commit
a0893f2b29
|
@ -85,14 +85,15 @@ function follow(entity, dynamic = true, distance = 3) {
|
||||||
function ride(entity) {
|
function ride(entity) {
|
||||||
entity = entity?.entity || entity
|
entity = entity?.entity || entity
|
||||||
const ridableMobs = ["Horse", "Donkey", "Pig", "Strider"]
|
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(" ")
|
const maybeRidableMob = e.mobType?.split(" ")
|
||||||
return e.kind == "Vehicles"
|
return e.kind == "Vehicles"
|
||||||
|| ridableMobs.includes(e.mobType)
|
|| ridableMobs.includes(e.mobType)
|
||||||
|| maybeRidableMob && ridableMobs.includes(maybeRidableMob[maybeRidableMob.length - 1])
|
|| maybeRidableMob && ridableMobs.includes(maybeRidableMob[maybeRidableMob.length - 1])
|
||||||
})
|
})
|
||||||
if (!vehicle) {
|
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) {
|
} else if ((dist = bot.entity.position.distanceSquared(vehicle.position)) > 36) {
|
||||||
bot.lookAt(vehicle.position)
|
bot.lookAt(vehicle.position)
|
||||||
follow(vehicle, false)
|
follow(vehicle, false)
|
||||||
|
@ -227,7 +228,7 @@ function command(message_parts, player) {
|
||||||
break
|
break
|
||||||
case "ride":
|
case "ride":
|
||||||
case "mount":
|
case "mount":
|
||||||
ride()
|
ride(message_parts2[0])
|
||||||
break
|
break
|
||||||
case "w":
|
case "w":
|
||||||
case "f":
|
case "f":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user