EntityAIBreakDoor .java

net.minecraft.entity.ai.EntityAIBreakDoor (class): members: previousBreakProgress, breakingTime, updateTask, resetTask, continueExecuting, startExecuting.

net.minecraft.entity.aiclass108 linescommonextends EntityAIDoorInteract2.8 KB

API Surface (5)

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

Fields & Constants (2)

breakingTime
previousBreakProgress

String literals (1)

"mobGriefing"

Code Graph: Dependencies (5)

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

Full Source

EntityAIBreakDoor.java108 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.BlockDoor;
5
import net.minecraft.entity.EntityLiving;
6
import net.minecraft.world.EnumDifficulty;
7
8
public class EntityAIBreakDoor extends EntityAIDoorInteract
9
{
10
    private int breakingTime;
11
    private int previousBreakProgress = -1;
12
13
    public EntityAIBreakDoor(EntityLiving entityIn)
14
    {
15
        super(entityIn);
16
    }
17
18
    /**
19
     * Returns whether the EntityAIBase should begin execution.
20
     */
21
    public boolean shouldExecute()
22
    {
23
        if (!super.shouldExecute())
24
        {
25
            return false;
26
        }
27
        else if (!this.theEntity.worldObj.getGameRules().getBoolean("mobGriefing"))
28
        {
29
            return false;
30
        }
31
        else
32
        {
33
            BlockDoor blockdoor = this.doorBlock;
34
            return !BlockDoor.isOpen(this.theEntity.worldObj, this.doorPosition);
35
        }
36
    }
37
38
    /**
39
     * Execute a one shot task or start executing a continuous task
40
     */
41
    public void startExecuting()
42
    {
43
        super.startExecuting();
44
        this.breakingTime = 0;
45
    }
46
47
    /**
48
     * Returns whether an in-progress EntityAIBase should continue executing
49
     */
50
    public boolean continueExecuting()
51
    {
52
        double d0 = this.theEntity.getDistanceSq(this.doorPosition);
53
        boolean flag;
54
55
        if (this.breakingTime <= 240)
56
        {
57
            BlockDoor blockdoor = this.doorBlock;
58
59
            if (!BlockDoor.isOpen(this.theEntity.worldObj, this.doorPosition) && d0 < 4.0D)
60
            {
61
                flag = true;
62
                return flag;
63
            }
64
        }
65
66
        flag = false;
67
        return flag;
68
    }
69
70
    /**
71
     * Resets the task
72
     */
73
    public void resetTask()
74
    {
75
        super.resetTask();
76
        this.theEntity.worldObj.sendBlockBreakProgress(this.theEntity.getEntityId(), this.doorPosition, -1);
77
    }
78
79
    /**
80
     * Updates the task
81
     */
82
    public void updateTask()
83
    {
84
        super.updateTask();
85
86
        if (this.theEntity.getRNG().nextInt(20) == 0)
87
        {
88
            this.theEntity.worldObj.playAuxSFX(1010, this.doorPosition, 0);
89
        }
90
91
        ++this.breakingTime;
92
        int i = (int)((float)this.breakingTime / 240.0F * 10.0F);
93
94
        if (i != this.previousBreakProgress)
95
        {
96
            this.theEntity.worldObj.sendBlockBreakProgress(this.theEntity.getEntityId(), this.doorPosition, i);
97
            this.previousBreakProgress = i;
98
        }
99
100
        if (this.breakingTime == 240 && this.theEntity.worldObj.getDifficulty() == EnumDifficulty.HARD)
101
        {
102
            this.theEntity.worldObj.setBlockToAir(this.doorPosition);
103
            this.theEntity.worldObj.playAuxSFX(1012, this.doorPosition, 0);
104
            this.theEntity.worldObj.playAuxSFX(2001, this.doorPosition, Block.getIdFromBlock(this.doorBlock));
105
        }
106
    }
107
}
108

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