@@ -5,8 +5,8 @@ description: A guide to the Entity Pathfinder API.
5
5
6
6
# Entity Pathfinder API
7
7
8
- The Entity Pathfinder API is a way of controlling the movement of entities in Minecraft. It allows you to set a path
9
- for an entity to follow, such as moving to a location, or following a player.
8
+ The Entity Pathfinder API is a way of controlling the movement of entities in Minecraft. It allows you to set a path
9
+ for an entity to follow, such as moving to a location, or following a player.
10
10
11
11
## Accessing the Pathfinder
12
12
@@ -27,17 +27,17 @@ Player player = ...;
27
27
28
28
Pathfinder pathfinder = cow. getPathfinder();
29
29
// moveTo returns a boolean indicating whether the path was set successfully
30
- boolean success = pathfinder. moveTo(player. getLocation());
30
+ boolean success = pathfinder. moveTo(player. getLocation());
31
31
```
32
32
33
- If we want to access the current Path for the cow, we can call ` getCurrentPath() ` on the pathfinder:
33
+ If we want to access the current path for the cow, we can call ` getCurrentPath() ` on the pathfinder:
34
34
35
35
``` java
36
36
PathResult path = pathfinder. getCurrentPath();
37
37
38
38
// A PathResult is essentially a wrapper around a List of Locations. These can be accessed with:
39
39
List<Location > locations = path. getPoints();
40
- // It is important to note that the list contains points that have already been passed,
40
+ // It is important to note that the list contains points that have already been passed,
41
41
// as well as future points. If you want to get the next point, you can use:
42
42
Location nextPoint = path. getNextPoint(); // Or locations.get(path.getNextPointIndex())
43
43
// Finally, you can access the final destination with:
@@ -48,10 +48,10 @@ Location destination = path.getFinalPoint();
48
48
49
49
Much of the way that the Pathfinder works is dictated by the limitations of the actual entity pathfinding in Minecraft.
50
50
For example, a Polar Bear cannot fly. This means that if you set a path for a Polar Bear to a location that is in the air,
51
- it will not be able to reach it.
51
+ it will not be able to reach it.
52
52
53
53
Some attributes can be set on the pathfinder to change the way that the pathfinder works. These are:
54
- - ` setCanOpenDoors(boolean) ` : Whether the entity can open doors. This is relevant for Zombies breaking down doors, and
54
+ - ` setCanOpenDoors(boolean) ` : Whether the entity can open doors. This is relevant for Zombies breaking down doors, and
55
55
Villagers opening doors.
56
56
- ` setCanPassDoors(boolean) ` : Whether the entity can pass through open doors.
57
57
- ` setCanFloat(boolean) ` : Whether the entity can float in water.
@@ -60,4 +60,4 @@ These all have respective getters as well.
60
60
## Stopping the Pathfinder
61
61
62
62
You can call ` stopPathfinding() ` on the pathfinder to stop the pathfinder. This will stop the pathfinder and clear the
63
- current path. You can use ` hasPath() ` to check if the pathfinder is running.
63
+ current path. You can use ` hasPath() ` to check if the pathfinder is running.
0 commit comments