EntityAIWander .java

net.minecraft.entity.ai.EntityAIWander (class): members: setExecutionChance, executionChance, makeUpdate, mustUpdate, zPosition, yPosition, xPosition.

net.minecraft.entity.aiclass95 linescommonextends EntityAIBase2.2 KB

API Surface (5)

boolean shouldExecute()
boolean continueExecuting()
void startExecuting()
void makeUpdate()
void setExecutionChance(int newchance)

Fields & Constants (7)

entity
xPosition
yPosition
zPosition
speed
executionChance
mustUpdate

Code Graph: Dependencies (4)

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

Full Source

EntityAIWander.java95 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityCreature;
4
import net.minecraft.util.Vec3;
5
6
public class EntityAIWander extends EntityAIBase
7
{
8
    private EntityCreature entity;
9
    private double xPosition;
10
    private double yPosition;
11
    private double zPosition;
12
    private double speed;
13
    private int executionChance;
14
    private boolean mustUpdate;
15
16
    public EntityAIWander(EntityCreature creatureIn, double speedIn)
17
    {
18
        this(creatureIn, speedIn, 120);
19
    }
20
21
    public EntityAIWander(EntityCreature creatureIn, double speedIn, int chance)
22
    {
23
        this.entity = creatureIn;
24
        this.speed = speedIn;
25
        this.executionChance = chance;
26
        this.setMutexBits(1);
27
    }
28
29
    /**
30
     * Returns whether the EntityAIBase should begin execution.
31
     */
32
    public boolean shouldExecute()
33
    {
34
        if (!this.mustUpdate)
35
        {
36
            if (this.entity.getAge() >= 100)
37
            {
38
                return false;
39
            }
40
41
            if (this.entity.getRNG().nextInt(this.executionChance) != 0)
42
            {
43
                return false;
44
            }
45
        }
46
47
        Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);
48
49
        if (vec3 == null)
50
        {
51
            return false;
52
        }
53
        else
54
        {
55
            this.xPosition = vec3.xCoord;
56
            this.yPosition = vec3.yCoord;
57
            this.zPosition = vec3.zCoord;
58
            this.mustUpdate = false;
59
            return true;
60
        }
61
    }
62
63
    /**
64
     * Returns whether an in-progress EntityAIBase should continue executing
65
     */
66
    public boolean continueExecuting()
67
    {
68
        return !this.entity.getNavigator().noPath();
69
    }
70
71
    /**
72
     * Execute a one shot task or start executing a continuous task
73
     */
74
    public void startExecuting()
75
    {
76
        this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
77
    }
78
79
    /**
80
     * Makes task to bypass chance
81
     */
82
    public void makeUpdate()
83
    {
84
        this.mustUpdate = true;
85
    }
86
87
    /**
88
     * Changes task random possibility for execution
89
     */
90
    public void setExecutionChance(int newchance)
91
    {
92
        this.executionChance = newchance;
93
    }
94
}
95

Deobfuscated MCP 1.8.9 source of EntityAIWander from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/ai/EntityAIWander.java), stored verbatim.