EntityAIDefendVillage .java

net.minecraft.entity.ai.EntityAIDefendVillage (class): members: villageAgressorTarget, irongolem, startExecuting, shouldExecute. imports: Village.

net.minecraft.entity.aiclass71 linescommonextends EntityAITarget1.9 KB

API Surface (2)

boolean shouldExecute()
void startExecuting()

Fields & Constants (2)

irongolem
villageAgressorTarget

Code Graph: Dependencies (5)

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

Full Source

EntityAIDefendVillage.java71 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityLivingBase;
4
import net.minecraft.entity.monster.EntityCreeper;
5
import net.minecraft.entity.monster.EntityIronGolem;
6
import net.minecraft.village.Village;
7
8
public class EntityAIDefendVillage extends EntityAITarget
9
{
10
    EntityIronGolem irongolem;
11
12
    /**
13
     * The aggressor of the iron golem's village which is now the golem's attack target.
14
     */
15
    EntityLivingBase villageAgressorTarget;
16
17
    public EntityAIDefendVillage(EntityIronGolem ironGolemIn)
18
    {
19
        super(ironGolemIn, false, true);
20
        this.irongolem = ironGolemIn;
21
        this.setMutexBits(1);
22
    }
23
24
    /**
25
     * Returns whether the EntityAIBase should begin execution.
26
     */
27
    public boolean shouldExecute()
28
    {
29
        Village village = this.irongolem.getVillage();
30
31
        if (village == null)
32
        {
33
            return false;
34
        }
35
        else
36
        {
37
            this.villageAgressorTarget = village.findNearestVillageAggressor(this.irongolem);
38
39
            if (this.villageAgressorTarget instanceof EntityCreeper)
40
            {
41
                return false;
42
            }
43
            else if (!this.isSuitableTarget(this.villageAgressorTarget, false))
44
            {
45
                if (this.taskOwner.getRNG().nextInt(20) == 0)
46
                {
47
                    this.villageAgressorTarget = village.getNearestTargetPlayer(this.irongolem);
48
                    return this.isSuitableTarget(this.villageAgressorTarget, false);
49
                }
50
                else
51
                {
52
                    return false;
53
                }
54
            }
55
            else
56
            {
57
                return true;
58
            }
59
        }
60
    }
61
62
    /**
63
     * Execute a one shot task or start executing a continuous task
64
     */
65
    public void startExecuting()
66
    {
67
        this.irongolem.setAttackTarget(this.villageAgressorTarget);
68
        super.startExecuting();
69
    }
70
}
71

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