Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to check if pathfinder allows the mob to fly #11820

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ default boolean moveTo(PathResult path) {
*/
void setCanFloat(boolean canFloat);

/**
* Checks if this pathfinder allows the mob to fly
*
* @return if this pathfinder allows the mob to fly
*/
boolean canFly();

/**
* Represents the result of a pathfinding calculation
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.destroystokyo.paper.entity;

import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
Expand Down Expand Up @@ -99,6 +100,11 @@ public void setCanFloat(boolean canFloat) {
entity.getNavigation().pathFinder.nodeEvaluator.setCanFloat(canFloat);
}

@Override
public boolean canFly() {
return entity.getNavigation() instanceof FlyingPathNavigation;
}

public class PaperPathResult implements com.destroystokyo.paper.entity.PaperPathfinder.PathResult {

private final Path path;
Expand Down
Loading