Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import org.bukkit.craftbukkit.entity.CraftEntity;
4import org.bukkit.event.entity.EntityTargetEvent;
5
6import java.util.List;
7
8// CraftBukkit start
9// CraftBukkit end
10
11public class EntityPigZombie extends EntityZombie {
12
13 public int angerLevel = 0; // CraftBukkit - private -> public
14 private int soundDelay = 0;
15 private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1);
16
17 public EntityPigZombie(World world) {
18 super(world);
19 this.texture = "/mob/pigzombie.png";
20 this.aE = 0.5F;
21 this.damage = 5;
22 this.fireProof = true;
23 }
24
25 public void m_() {
26 this.aE = this.target != null ? 0.95F : 0.5F;
27 if (this.soundDelay > 0 && --this.soundDelay == 0) {
28 this.world.makeSound(this, "mob.zombiepig.zpigangry", this.k() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
29 }
30
31 super.m_();
32 }
33
34 public boolean d() {
35 return this.world.spawnMonsters > 0 && this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox);
36 }
37
38 public void b(NBTTagCompound nbttagcompound) {
39 super.b(nbttagcompound);
40 nbttagcompound.a("Anger", (short) this.angerLevel);
41 }
42
43 public void a(NBTTagCompound nbttagcompound) {
44 super.a(nbttagcompound);
45 this.angerLevel = nbttagcompound.d("Anger");
46 }
47
48 protected Entity findTarget() {
49 return this.angerLevel == 0 ? null : super.findTarget();
50 }
51
52 public void v() {
53 super.v();
54 }
55
56 public boolean damageEntity(Entity entity, int i) {
57 if (entity instanceof EntityHuman) {
58 List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D));
59
60 for (int j = 0; j < list.size(); ++j) {
61 Entity entity1 = (Entity) list.get(j);
62
63 if (entity1 instanceof EntityPigZombie) {
64 EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;
65
66 entitypigzombie.d(entity);
67 }
68 }
69
70 this.d(entity);
71 }
72
73 return super.damageEntity(entity, i);
74 }
75
76 private void d(Entity entity) {
77 // CraftBukkit start
78 org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();
79
80 EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
81 this.world.getServer().getPluginManager().callEvent(event);
82
83 if (event.isCancelled()) {
84 return;
85 }
86
87 if (event.getTarget() == null) {
88 this.target = null;
89 return;
90 }
91 entity = ((CraftEntity) event.getTarget()).getHandle();
92 // CraftBukkit end
93
94 this.target = entity;
95 this.angerLevel = 400 + this.random.nextInt(400);
96 this.soundDelay = this.random.nextInt(40);
97 }
98
99 protected String g() {
100 return "mob.zombiepig.zpig";
101 }
102
103 protected String h() {
104 return "mob.zombiepig.zpighurt";
105 }
106
107 protected String i() {
108 return "mob.zombiepig.zpigdeath";
109 }
110
111 protected int j() {
112 return Item.GRILLED_PORK.id;
113 }
114}