summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java
blob: c4efd2b8d52719ef322b99415b095f104b30c489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package net.minecraft.server;

public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract {

    private int i;
    private int j = -1;

    public PathfinderGoalBreakDoor(EntityLiving entityliving) {
        super(entityliving);
    }

    public boolean a() {
        return !super.a() ? false : (!this.a.world.getGameRules().getBoolean("mobGriefing") ? false : !this.e.a_(this.a.world, this.b, this.c, this.d));
    }

    public void c() {
        super.c();
        this.i = 0;
    }

    public boolean b() {
        double d0 = this.a.e((double) this.b, (double) this.c, (double) this.d);

        return this.i <= 240 && !this.e.a_(this.a.world, this.b, this.c, this.d) && d0 < 4.0D;
    }

    public void d() {
        super.d();
        this.a.world.g(this.a.id, this.b, this.c, this.d, -1);
    }

    public void e() {
        super.e();
        if (this.a.aB().nextInt(20) == 0) {
            this.a.world.triggerEffect(1010, this.b, this.c, this.d, 0);
        }

        ++this.i;
        int i = (int) ((float) this.i / 240.0F * 10.0F);

        if (i != this.j) {
            this.a.world.g(this.a.id, this.b, this.c, this.d, i);
            this.j = i;
        }

        if (this.i == 240 && this.a.world.difficulty == 3) {
            // CraftBukkit start
            if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b, this.c, this.d).isCancelled()) {
                this.e();
                return;
            }
            // CraftBukkit end

            this.a.world.setTypeId(this.b, this.c, this.d, 0);
            this.a.world.triggerEffect(1012, this.b, this.c, this.d, 0);
            this.a.world.triggerEffect(2001, this.b, this.c, this.d, this.e.id);
        }
    }
}