For Minecraft, utilizing the Spigot API, I have a LivingEntity
Villager
that I would like to path, or "walk" to a Location
.
I have seen some older examples using PathEntity
to perform this effect, to varying degrees of success, but such methods now appear to have been removed from more modern versions of the Spigot API.
I am currently using the spigot-api-1.21.1-R0.1-SNAPSHOT-shaded
& craftbukkit-1.21.1
jar libraries in my build path, so I would like to find a solution that works with v1.21.1
or higher. Thank you.
The easiest way would be to use paper spigot. It got way more optimizations than normal spigot and you can access the pathfinder of every mob easily.
Villager entity = // your entity
Location location = // your location
entity.getPathfinder().moveTo(location);
https://jd.papermc.io/paper/1.21.1/com/destroystokyo/paper/entity/Pathfinder.html