EntityAILookIdle .java

net.minecraft.entity.ai.EntityAILookIdle (class, 63 lines): members: idleEntity, idleTime, lookX, lookZ, updateTask, continueExecuting, startExecuting.

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

API Surface (4)

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

Fields & Constants (4)

idleEntity
lookX
lookZ
idleTime

Code Graph: Dependencies (2)

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

Full Source

EntityAILookIdle.java63 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityLiving;
4
5
public class EntityAILookIdle extends EntityAIBase
6
{
7
    /** The entity that is looking idle. */
8
    private EntityLiving idleEntity;
9
10
    /** X offset to look at */
11
    private double lookX;
12
13
    /** Z offset to look at */
14
    private double lookZ;
15
16
    /**
17
     * A decrementing tick that stops the entity from being idle once it reaches 0.
18
     */
19
    private int idleTime;
20
21
    public EntityAILookIdle(EntityLiving entitylivingIn)
22
    {
23
        this.idleEntity = entitylivingIn;
24
        this.setMutexBits(3);
25
    }
26
27
    /**
28
     * Returns whether the EntityAIBase should begin execution.
29
     */
30
    public boolean shouldExecute()
31
    {
32
        return this.idleEntity.getRNG().nextFloat() < 0.02F;
33
    }
34
35
    /**
36
     * Returns whether an in-progress EntityAIBase should continue executing
37
     */
38
    public boolean continueExecuting()
39
    {
40
        return this.idleTime >= 0;
41
    }
42
43
    /**
44
     * Execute a one shot task or start executing a continuous task
45
     */
46
    public void startExecuting()
47
    {
48
        double d0 = (Math.PI * 2D) * this.idleEntity.getRNG().nextDouble();
49
        this.lookX = Math.cos(d0);
50
        this.lookZ = Math.sin(d0);
51
        this.idleTime = 20 + this.idleEntity.getRNG().nextInt(20);
52
    }
53
54
    /**
55
     * Updates the task
56
     */
57
    public void updateTask()
58
    {
59
        --this.idleTime;
60
        this.idleEntity.getLookHelper().setLookPosition(this.idleEntity.posX + this.lookX, this.idleEntity.posY + (double)this.idleEntity.getEyeHeight(), this.idleEntity.posZ + this.lookZ, 10.0F, (float)this.idleEntity.getVerticalFaceSpeed());
61
    }
62
}
63

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