PathEntity .java

net.minecraft.pathfinding.PathEntity (class): members: getPathPointFromIndex, getCurrentPathLength, setCurrentPathLength, getCurrentPathIndex, isSamePath.

net.minecraft.pathfindingclass130 linescommon3.3 KB

API Surface (12)

void incrementPathIndex()
boolean isFinished()
PathPoint getFinalPathPoint()
PathPoint getPathPointFromIndex(int index)
int getCurrentPathLength()
void setCurrentPathLength(int length)
int getCurrentPathIndex()
void setCurrentPathIndex(int currentPathIndexIn)
Vec3 getVectorFromIndex(Entity entityIn, int index)
Vec3 getPosition(Entity entityIn)
boolean isSamePath(PathEntity pathentityIn)
boolean isDestinationSame(Vec3 vec)

Fields & Constants (3)

points
currentPathIndex
pathLength

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PathEntity.java130 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.pathfinding;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.util.Vec3;
5
6
public class PathEntity
7
{
8
    /** The actual points in the path */
9
    private final PathPoint[] points;
10
11
    /** PathEntity Array Index the Entity is currently targeting */
12
    private int currentPathIndex;
13
14
    /** The total length of the path */
15
    private int pathLength;
16
17
    public PathEntity(PathPoint[] pathpoints)
18
    {
19
        this.points = pathpoints;
20
        this.pathLength = pathpoints.length;
21
    }
22
23
    /**
24
     * Directs this path to the next point in its array
25
     */
26
    public void incrementPathIndex()
27
    {
28
        ++this.currentPathIndex;
29
    }
30
31
    /**
32
     * Returns true if this path has reached the end
33
     */
34
    public boolean isFinished()
35
    {
36
        return this.currentPathIndex >= this.pathLength;
37
    }
38
39
    /**
40
     * returns the last PathPoint of the Array
41
     */
42
    public PathPoint getFinalPathPoint()
43
    {
44
        return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
45
    }
46
47
    /**
48
     * return the PathPoint located at the specified PathIndex, usually the current one
49
     */
50
    public PathPoint getPathPointFromIndex(int index)
51
    {
52
        return this.points[index];
53
    }
54
55
    public int getCurrentPathLength()
56
    {
57
        return this.pathLength;
58
    }
59
60
    public void setCurrentPathLength(int length)
61
    {
62
        this.pathLength = length;
63
    }
64
65
    public int getCurrentPathIndex()
66
    {
67
        return this.currentPathIndex;
68
    }
69
70
    public void setCurrentPathIndex(int currentPathIndexIn)
71
    {
72
        this.currentPathIndex = currentPathIndexIn;
73
    }
74
75
    /**
76
     * Gets the vector of the PathPoint associated with the given index.
77
     */
78
    public Vec3 getVectorFromIndex(Entity entityIn, int index)
79
    {
80
        double d0 = (double)this.points[index].xCoord + (double)((int)(entityIn.width + 1.0F)) * 0.5D;
81
        double d1 = (double)this.points[index].yCoord;
82
        double d2 = (double)this.points[index].zCoord + (double)((int)(entityIn.width + 1.0F)) * 0.5D;
83
        return new Vec3(d0, d1, d2);
84
    }
85
86
    /**
87
     * returns the current PathEntity target node as Vec3D
88
     */
89
    public Vec3 getPosition(Entity entityIn)
90
    {
91
        return this.getVectorFromIndex(entityIn, this.currentPathIndex);
92
    }
93
94
    /**
95
     * Returns true if the EntityPath are the same. Non instance related equals.
96
     */
97
    public boolean isSamePath(PathEntity pathentityIn)
98
    {
99
        if (pathentityIn == null)
100
        {
101
            return false;
102
        }
103
        else if (pathentityIn.points.length != this.points.length)
104
        {
105
            return false;
106
        }
107
        else
108
        {
109
            for (int i = 0; i < this.points.length; ++i)
110
            {
111
                if (this.points[i].xCoord != pathentityIn.points[i].xCoord || this.points[i].yCoord != pathentityIn.points[i].yCoord || this.points[i].zCoord != pathentityIn.points[i].zCoord)
112
                {
113
                    return false;
114
                }
115
            }
116
117
            return true;
118
        }
119
    }
120
121
    /**
122
     * Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
123
     */
124
    public boolean isDestinationSame(Vec3 vec)
125
    {
126
        PathPoint pathpoint = this.getFinalPathPoint();
127
        return pathpoint == null ? false : pathpoint.xCoord == (int)vec.xCoord && pathpoint.zCoord == (int)vec.zCoord;
128
    }
129
}
130

Deobfuscated MCP 1.8.9 source of PathEntity from Marcelektro/MavenMCP-1.8.9 (net/minecraft/pathfinding/PathEntity.java), stored verbatim.