2011-01-17 04:03:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-01-26 20:26:24 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
2011-11-27 05:22:24 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2011-01-26 20:26:24 +01:00
|
|
|
import org.bukkit.event.entity.EntityTargetEvent;
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 09:17:16 +01:00
|
|
|
|
2011-01-17 04:03:19 +01:00
|
|
|
public class EntityPigZombie extends EntityZombie {
|
|
|
|
|
2011-07-03 04:15:06 +02:00
|
|
|
public int angerLevel = 0; // CraftBukkit - private -> public
|
2011-04-20 19:05:14 +02:00
|
|
|
private int soundDelay = 0;
|
2011-09-15 02:23:52 +02:00
|
|
|
private static final ItemStack g = new ItemStack(Item.GOLD_SWORD, 1);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
public EntityPigZombie(World world) {
|
|
|
|
super(world);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.texture = "/mob/pigzombie.png";
|
2012-01-12 23:10:13 +01:00
|
|
|
this.bb = 0.5F;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.damage = 5;
|
2011-06-27 00:25:01 +02:00
|
|
|
this.fireProof = true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected boolean as() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void y_() {
|
|
|
|
this.bb = this.target != null ? 0.95F : 0.5F;
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.soundDelay > 0 && --this.soundDelay == 0) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.world.makeSound(this, "mob.zombiepig.zpigangry", this.o() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
super.y_();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public boolean canSpawn() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.world.difficulty > 0 && this.world.containsEntity(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setShort("Anger", (short) this.angerLevel);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.angerLevel = nbttagcompound.getShort("Anger");
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
protected Entity findTarget() {
|
|
|
|
return this.angerLevel == 0 ? null : super.findTarget();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void d() {
|
|
|
|
super.d();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
2011-09-15 18:36:27 +02:00
|
|
|
Entity entity = damagesource.getEntity();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entity instanceof EntityHuman) {
|
2012-01-12 16:27:39 +01:00
|
|
|
List list = this.world.getEntities(this, this.boundingBox.grow(32.0D, 32.0D, 32.0D));
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int j = 0; j < list.size(); ++j) {
|
2011-01-17 04:03:19 +01:00
|
|
|
Entity entity1 = (Entity) list.get(j);
|
|
|
|
|
|
|
|
if (entity1 instanceof EntityPigZombie) {
|
|
|
|
EntityPigZombie entitypigzombie = (EntityPigZombie) entity1;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
entitypigzombie.f(entity);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
this.f(entity);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
return super.damageEntity(damagesource, i);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void f(Entity entity) {
|
2011-01-26 20:26:24 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getTarget() == null) {
|
|
|
|
this.target = null;
|
|
|
|
return;
|
2011-01-26 20:26:24 +01:00
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
entity = ((CraftEntity) event.getTarget()).getHandle();
|
2011-01-26 20:26:24 +01:00
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
|
|
|
|
this.target = entity;
|
|
|
|
this.angerLevel = 400 + this.random.nextInt(400);
|
|
|
|
this.soundDelay = this.random.nextInt(40);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String c_() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.zombiepig.zpig";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String m() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.zombiepig.zpighurt";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String n() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.zombiepig.zpigdeath";
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-11-27 05:22:24 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-11-20 09:01:14 +01:00
|
|
|
int j = this.random.nextInt(2 + i);
|
|
|
|
|
|
|
|
int k;
|
|
|
|
|
2011-11-27 05:22:24 +01:00
|
|
|
if (j > 0) {
|
|
|
|
loot.add(new CraftItemStack(Item.ROTTEN_FLESH.id, j));
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
j = this.random.nextInt(2 + i);
|
|
|
|
|
2011-11-27 05:22:24 +01:00
|
|
|
if (j > 0) {
|
|
|
|
loot.add(new CraftItemStack(Item.GOLD_NUGGET.id, j));
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-11-27 05:22:24 +01:00
|
|
|
CraftEventFactory.callEntityDeathEvent(this, loot);
|
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return Item.ROTTEN_FLESH.id;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|