EntityAIFollowGolem .java

net.minecraft.entity.ai.EntityAIFollowGolem (class, 104 lines): members: takeGolemRoseTick, tookGolemRose, theGolem, theVillager, updateTask, resetTask.

net.minecraft.entity.aiclass104 linescommonextends EntityAIBase2.8 KB

API Surface (5)

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

Fields & Constants (4)

theVillager
theGolem
takeGolemRoseTick
tookGolemRose

Code Graph: Dependencies (3)

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

Full Source

EntityAIFollowGolem.java104 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import java.util.List;
4
import net.minecraft.entity.monster.EntityIronGolem;
5
import net.minecraft.entity.passive.EntityVillager;
6
7
public class EntityAIFollowGolem extends EntityAIBase
8
{
9
    private EntityVillager theVillager;
10
    private EntityIronGolem theGolem;
11
    private int takeGolemRoseTick;
12
    private boolean tookGolemRose;
13
14
    public EntityAIFollowGolem(EntityVillager theVillagerIn)
15
    {
16
        this.theVillager = theVillagerIn;
17
        this.setMutexBits(3);
18
    }
19
20
    /**
21
     * Returns whether the EntityAIBase should begin execution.
22
     */
23
    public boolean shouldExecute()
24
    {
25
        if (this.theVillager.getGrowingAge() >= 0)
26
        {
27
            return false;
28
        }
29
        else if (!this.theVillager.worldObj.isDaytime())
30
        {
31
            return false;
32
        }
33
        else
34
        {
35
            List<EntityIronGolem> list = this.theVillager.worldObj.<EntityIronGolem>getEntitiesWithinAABB(EntityIronGolem.class, this.theVillager.getEntityBoundingBox().expand(6.0D, 2.0D, 6.0D));
36
37
            if (list.isEmpty())
38
            {
39
                return false;
40
            }
41
            else
42
            {
43
                for (EntityIronGolem entityirongolem : list)
44
                {
45
                    if (entityirongolem.getHoldRoseTick() > 0)
46
                    {
47
                        this.theGolem = entityirongolem;
48
                        break;
49
                    }
50
                }
51
52
                return this.theGolem != null;
53
            }
54
        }
55
    }
56
57
    /**
58
     * Returns whether an in-progress EntityAIBase should continue executing
59
     */
60
    public boolean continueExecuting()
61
    {
62
        return this.theGolem.getHoldRoseTick() > 0;
63
    }
64
65
    /**
66
     * Execute a one shot task or start executing a continuous task
67
     */
68
    public void startExecuting()
69
    {
70
        this.takeGolemRoseTick = this.theVillager.getRNG().nextInt(320);
71
        this.tookGolemRose = false;
72
        this.theGolem.getNavigator().clearPathEntity();
73
    }
74
75
    /**
76
     * Resets the task
77
     */
78
    public void resetTask()
79
    {
80
        this.theGolem = null;
81
        this.theVillager.getNavigator().clearPathEntity();
82
    }
83
84
    /**
85
     * Updates the task
86
     */
87
    public void updateTask()
88
    {
89
        this.theVillager.getLookHelper().setLookPositionWithEntity(this.theGolem, 30.0F, 30.0F);
90
91
        if (this.theGolem.getHoldRoseTick() == this.takeGolemRoseTick)
92
        {
93
            this.theVillager.getNavigator().tryMoveToEntityLiving(this.theGolem, 0.5D);
94
            this.tookGolemRose = true;
95
        }
96
97
        if (this.tookGolemRose && this.theVillager.getDistanceSqToEntity(this.theGolem) < 4.0D)
98
        {
99
            this.theGolem.setHoldingRose(false);
100
            this.theVillager.getNavigator().clearPathEntity();
101
        }
102
    }
103
}
104

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