summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityMobs.java
blob: df910e41d564ccd50fd87efd4901e6b75b75d917 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package net.minecraft.server;

import java.util.Random;

// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer;

import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end

public class EntityMobs extends EntityCreature implements IMobs {

    protected int c;

    public EntityMobs(World world) {
        super(world);
        c = 2;
        aZ = 20;
        // CraftBukkit start
        CraftServer server = ((WorldServer) this.l).getServer();
        this.bukkitEntity = new CraftMonster(server, this);
        // CraftBukkit end
    }

    public void o() {
        float f = b(1.0F);

        if (f > 0.5F) {
            bw += 2;
        }
        super.o();
    }

    public void b_() {
        super.b_();
        if (l.k == 0) {
            q();
        }
    }

    protected Entity l() {
        EntityPlayer entityplayer = l.a(((Entity) (this)), 16D);

        if (entityplayer != null && i(((Entity) (entityplayer)))) {
            return ((Entity) (entityplayer));
        } else {
            return null;
        }
    }

    public boolean a(Entity entity, int i) {
        if (super.a(entity, i)) {
            if (j == entity || k == entity) {
                return true;
            }
            if (entity != this) {
                d = entity;
            }
            return true;
        } else {
            return false;
        }
    }

    protected void a(Entity entity, float f) {
        if ((double) f < 2.5D && entity.z.e > z.b && entity.z.b < z.e) {
            bf = 20;
            // CraftBukkit start
            if(entity instanceof EntityLiving) {
                CraftServer server = ((WorldServer) l).getServer();
                org.bukkit.entity.Entity damager = this.getBukkitEntity();
                org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
                DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
                int damageDone = c;

                EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
                server.getPluginManager().callEvent(edbee);

                if (!edbee.isCancelled()){
                    entity.a(((Entity) (this)), edbee.getDamage());
                }
            } else {
                entity.a(((Entity) (this)), c);
            }
            // CraftBukkit end
        }
    }

    protected float a(int i, int j, int k) {
        return 0.5F - l.l(i, j, k);
    }

    public void a(NBTTagCompound nbttagcompound) {
        super.a(nbttagcompound);
    }

    public void b(NBTTagCompound nbttagcompound) {
        super.b(nbttagcompound);
    }

    public boolean b() {
        int i = MathHelper.b(p);
        int j = MathHelper.b(z.b);
        int k = MathHelper.b(r);

        if (l.a(EnumSkyBlock.a, i, j, k) > W.nextInt(32)) {
            return false;
        } else {
            int i1 = l.j(i, j, k);

            return i1 <= W.nextInt(8) && super.b();
        }
    }
}