PaperMC/src/main/java/net/minecraft/server/EntityPigZombie.java

116 lines
3.2 KiB
Java
Raw Normal View History

package net.minecraft.server;
import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
2011-01-26 20:26:24 +01:00
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end
public class EntityPigZombie extends EntityZombie {
2011-01-29 22:50:29 +01:00
private int a = 0;
private int b = 0;
private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1);
public EntityPigZombie(World world) {
super(world);
2011-01-29 22:50:29 +01:00
this.texture = "/mob/pigzombie.png";
2011-02-23 03:37:56 +01:00
this.az = 0.5F;
2011-01-29 22:50:29 +01:00
this.c = 5;
2011-02-23 03:37:56 +01:00
this.by = true;
}
2011-02-23 03:37:56 +01:00
public void f_() {
this.az = this.d != null ? 0.95F : 0.5F;
2011-01-29 22:50:29 +01:00
if (this.b > 0 && --this.b == 0) {
this.world.a(this, "mob.zombiepig.zpigangry", this.i() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
}
2011-01-29 22:50:29 +01:00
2011-02-23 03:37:56 +01:00
super.f_();
}
public boolean b() {
2011-02-23 03:37:56 +01:00
return this.world.j > 0 && this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
2011-01-29 22:50:29 +01:00
nbttagcompound.a("Anger", (short) this.a);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
2011-02-23 03:37:56 +01:00
this.a = nbttagcompound.d("Anger");
}
protected Entity l() {
2011-01-29 22:50:29 +01:00
return this.a == 0 ? null : super.l();
}
2011-02-23 03:37:56 +01:00
public void q() {
super.q();
}
public boolean a(Entity entity, int i) {
2011-01-29 22:50:29 +01:00
if (entity instanceof EntityHuman) {
List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D));
2011-01-29 22:50:29 +01:00
for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
if (entity1 instanceof EntityPigZombie) {
EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;
2011-02-23 03:37:56 +01:00
entitypigzombie.c(entity);
}
}
2011-02-23 03:37:56 +01:00
this.c(entity);
}
2011-01-29 22:50:29 +01:00
return super.a(entity, i);
}
2011-02-23 03:37:56 +01:00
private void c(Entity entity) {
2011-01-26 20:26:24 +01:00
// CraftBukkit start
2011-02-23 13:56:36 +01:00
CraftServer server = ((WorldServer) this.world).getServer();
2011-01-26 20:26:24 +01:00
org.bukkit.entity.Entity bukkitTarget = null;
2011-01-29 22:50:29 +01:00
if (entity != null) {
2011-01-26 20:26:24 +01:00
bukkitTarget = entity.getBukkitEntity();
}
2011-02-23 13:56:36 +01:00
2011-01-26 20:26:24 +01:00
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
server.getPluginManager().callEvent(event);
2011-02-23 13:56:36 +01:00
2011-01-29 22:50:29 +01:00
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.d = null;
2011-01-26 20:26:24 +01:00
} else {
2011-01-29 22:50:29 +01:00
this.d = ((CraftEntity) event.getTarget()).getHandle();
this.a = 400 + this.random.nextInt(400);
this.b = this.random.nextInt(40);
2011-01-26 20:26:24 +01:00
}
}
// CraftBukkit end
}
protected String e() {
return "mob.zombiepig.zpig";
}
protected String f() {
return "mob.zombiepig.zpighurt";
}
protected String g() {
return "mob.zombiepig.zpigdeath";
}
protected int h() {
2011-01-29 22:50:29 +01:00
return Item.GRILLED_PORK.id;
}
}