EntityAIPanic .java

net.minecraft.entity.ai.EntityAIPanic (class, 64 lines): members: theEntityCreature, randPosX, randPosY, randPosZ, speed, continueExecuting, shouldExecute.

net.minecraft.entity.aiclass64 linescommonextends EntityAIBase1.6 KB

API Surface (3)

boolean shouldExecute()
void startExecuting()
boolean continueExecuting()

Fields & Constants (5)

theEntityCreature
speed
randPosX
randPosY
randPosZ

Code Graph: Dependencies (4)

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

Full Source

EntityAIPanic.java64 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 EntityAIPanic extends EntityAIBase
7
{
8
    private EntityCreature theEntityCreature;
9
    protected double speed;
10
    private double randPosX;
11
    private double randPosY;
12
    private double randPosZ;
13
14
    public EntityAIPanic(EntityCreature creature, double speedIn)
15
    {
16
        this.theEntityCreature = creature;
17
        this.speed = speedIn;
18
        this.setMutexBits(1);
19
    }
20
21
    /**
22
     * Returns whether the EntityAIBase should begin execution.
23
     */
24
    public boolean shouldExecute()
25
    {
26
        if (this.theEntityCreature.getAITarget() == null && !this.theEntityCreature.isBurning())
27
        {
28
            return false;
29
        }
30
        else
31
        {
32
            Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4);
33
34
            if (vec3 == null)
35
            {
36
                return false;
37
            }
38
            else
39
            {
40
                this.randPosX = vec3.xCoord;
41
                this.randPosY = vec3.yCoord;
42
                this.randPosZ = vec3.zCoord;
43
                return true;
44
            }
45
        }
46
    }
47
48
    /**
49
     * Execute a one shot task or start executing a continuous task
50
     */
51
    public void startExecuting()
52
    {
53
        this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed);
54
    }
55
56
    /**
57
     * Returns whether an in-progress EntityAIBase should continue executing
58
     */
59
    public boolean continueExecuting()
60
    {
61
        return !this.theEntityCreature.getNavigator().noPath();
62
    }
63
}
64

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