EntityAIRestrictOpenDoor .java

net.minecraft.entity.ai.EntityAIRestrictOpenDoor (class, 85 lines): members: frontDoor, entityObj, updateTask, resetTask, continueExecuting, shouldExecute.

net.minecraft.entity.aiclass85 linescommonextends EntityAIBase2.4 KB

API Surface (5)

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

Fields & Constants (2)

entityObj
frontDoor

String literals (1)

"Unsupported mob type for RestrictOpenDoorGoal"

Code Graph: Dependencies (6)

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

Full Source

EntityAIRestrictOpenDoor.java85 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.entity.EntityCreature;
4
import net.minecraft.pathfinding.PathNavigateGround;
5
import net.minecraft.util.BlockPos;
6
import net.minecraft.village.Village;
7
import net.minecraft.village.VillageDoorInfo;
8
9
public class EntityAIRestrictOpenDoor extends EntityAIBase
10
{
11
    private EntityCreature entityObj;
12
    private VillageDoorInfo frontDoor;
13
14
    public EntityAIRestrictOpenDoor(EntityCreature creatureIn)
15
    {
16
        this.entityObj = creatureIn;
17
18
        if (!(creatureIn.getNavigator() instanceof PathNavigateGround))
19
        {
20
            throw new IllegalArgumentException("Unsupported mob type for RestrictOpenDoorGoal");
21
        }
22
    }
23
24
    /**
25
     * Returns whether the EntityAIBase should begin execution.
26
     */
27
    public boolean shouldExecute()
28
    {
29
        if (this.entityObj.worldObj.isDaytime())
30
        {
31
            return false;
32
        }
33
        else
34
        {
35
            BlockPos blockpos = new BlockPos(this.entityObj);
36
            Village village = this.entityObj.worldObj.getVillageCollection().getNearestVillage(blockpos, 16);
37
38
            if (village == null)
39
            {
40
                return false;
41
            }
42
            else
43
            {
44
                this.frontDoor = village.getNearestDoor(blockpos);
45
                return this.frontDoor == null ? false : (double)this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
46
            }
47
        }
48
    }
49
50
    /**
51
     * Returns whether an in-progress EntityAIBase should continue executing
52
     */
53
    public boolean continueExecuting()
54
    {
55
        return this.entityObj.worldObj.isDaytime() ? false : !this.frontDoor.getIsDetachedFromVillageFlag() && this.frontDoor.func_179850_c(new BlockPos(this.entityObj));
56
    }
57
58
    /**
59
     * Execute a one shot task or start executing a continuous task
60
     */
61
    public void startExecuting()
62
    {
63
        ((PathNavigateGround)this.entityObj.getNavigator()).setBreakDoors(false);
64
        ((PathNavigateGround)this.entityObj.getNavigator()).setEnterDoors(false);
65
    }
66
67
    /**
68
     * Resets the task
69
     */
70
    public void resetTask()
71
    {
72
        ((PathNavigateGround)this.entityObj.getNavigator()).setBreakDoors(true);
73
        ((PathNavigateGround)this.entityObj.getNavigator()).setEnterDoors(true);
74
        this.frontDoor = null;
75
    }
76
77
    /**
78
     * Updates the task
79
     */
80
    public void updateTask()
81
    {
82
        this.frontDoor.incrementDoorOpeningRestrictionCounter();
83
    }
84
}
85

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