mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Update Hydrazine library
This commit is contained in:
parent
640521e6dc
commit
5c2b7f38f6
@ -143,7 +143,7 @@ dependencies {
|
||||
api "org.spongepowered:mixin:${mixinVersion}"
|
||||
|
||||
// Path finding
|
||||
api 'com.github.MadMartian:hydrazine-path-finding:1.5.1'
|
||||
api 'com.github.MadMartian:hydrazine-path-finding:1.5.2'
|
||||
|
||||
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
|
||||
|
@ -86,10 +86,12 @@ public interface NavigableEntity {
|
||||
* The position is cloned, if you want the entity to continually follow this position object
|
||||
* you need to call this when you want the path to update.
|
||||
*
|
||||
* @param position the position to find the path to, null to reset the pathfinder
|
||||
* @param position the position to find the path to, null to reset the pathfinder
|
||||
* @param bestEffort whether to use the best-effort algorithm to the destination,
|
||||
* if false then this method is more likely to return immediately
|
||||
* @return true if a path has been found
|
||||
*/
|
||||
default boolean setPathTo(@Nullable Position position) {
|
||||
default boolean setPathTo(@Nullable Position position, boolean bestEffort) {
|
||||
if (position != null && getPathPosition() != null && position.isSimilar(getPathPosition())) {
|
||||
// Tried to set path to the same target position
|
||||
return false;
|
||||
@ -122,7 +124,11 @@ public interface NavigableEntity {
|
||||
|
||||
final Position targetPosition = position.clone();
|
||||
|
||||
final IPath path = pathFinder.initiatePathTo(targetPosition.getX(), targetPosition.getY(), targetPosition.getZ());
|
||||
final IPath path = pathFinder.initiatePathTo(
|
||||
targetPosition.getX(),
|
||||
targetPosition.getY(),
|
||||
targetPosition.getZ(),
|
||||
bestEffort);
|
||||
setPath(path);
|
||||
|
||||
final boolean success = path != null;
|
||||
@ -131,6 +137,13 @@ public interface NavigableEntity {
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #setPathTo(Position, boolean) with {@code bestEffort} sets to {@code true}.
|
||||
*/
|
||||
default boolean setPathTo(@Nullable Position position) {
|
||||
return setPathTo(position, true);
|
||||
}
|
||||
|
||||
default void pathFindingTick(float speed) {
|
||||
final Position pathPosition = getPathPosition();
|
||||
if (pathPosition != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user