EntityAILookAtVillager .java

net.minecraft.entity.ai.EntityAILookAtVillager (class): members: lookTime, theGolem, theVillager, updateTask, resetTask, continueExecuting, startExecuting.

net.minecraft.entity.aiclass73 linescommonextends EntityAIBase1.8 KB

API Surface (5)

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

Fields & Constants (3)

theGolem
theVillager
lookTime

Code Graph: Dependencies (3)

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

Full Source

EntityAILookAtVillager.java73 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.monster.EntityIronGolem;
4
import net.minecraft.entity.passive.EntityVillager;
5
6
public class EntityAILookAtVillager extends EntityAIBase
7
{
8
    private EntityIronGolem theGolem;
9
    private EntityVillager theVillager;
10
    private int lookTime;
11
12
    public EntityAILookAtVillager(EntityIronGolem theGolemIn)
13
    {
14
        this.theGolem = theGolemIn;
15
        this.setMutexBits(3);
16
    }
17
18
    /**
19
     * Returns whether the EntityAIBase should begin execution.
20
     */
21
    public boolean shouldExecute()
22
    {
23
        if (!this.theGolem.worldObj.isDaytime())
24
        {
25
            return false;
26
        }
27
        else if (this.theGolem.getRNG().nextInt(8000) != 0)
28
        {
29
            return false;
30
        }
31
        else
32
        {
33
            this.theVillager = (EntityVillager)this.theGolem.worldObj.findNearestEntityWithinAABB(EntityVillager.class, this.theGolem.getEntityBoundingBox().expand(6.0D, 2.0D, 6.0D), this.theGolem);
34
            return this.theVillager != null;
35
        }
36
    }
37
38
    /**
39
     * Returns whether an in-progress EntityAIBase should continue executing
40
     */
41
    public boolean continueExecuting()
42
    {
43
        return this.lookTime > 0;
44
    }
45
46
    /**
47
     * Execute a one shot task or start executing a continuous task
48
     */
49
    public void startExecuting()
50
    {
51
        this.lookTime = 400;
52
        this.theGolem.setHoldingRose(true);
53
    }
54
55
    /**
56
     * Resets the task
57
     */
58
    public void resetTask()
59
    {
60
        this.theGolem.setHoldingRose(false);
61
        this.theVillager = null;
62
    }
63
64
    /**
65
     * Updates the task
66
     */
67
    public void updateTask()
68
    {
69
        this.theGolem.getLookHelper().setLookPositionWithEntity(this.theVillager, 30.0F, 30.0F);
70
        --this.lookTime;
71
    }
72
}
73

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