2011-01-08 08:40:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-12-28 21:36:02 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
2011-01-08 08:40:42 +01:00
|
|
|
import org.bukkit.event.entity.EntityCombustEvent;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class EntitySkeleton extends EntityMonster {
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private static final ItemStack a = new ItemStack(Item.BOW, 1);
|
2011-01-10 09:30:34 +01:00
|
|
|
|
|
|
|
public EntitySkeleton(World world) {
|
|
|
|
super(world);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.texture = "/mob/skeleton.png";
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public int getMaxHealth() {
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected String c_() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeleton";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String m() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeletonhurt";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String n() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeletonhurt";
|
|
|
|
}
|
|
|
|
|
2011-09-15 05:13:14 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
2011-09-15 02:23:52 +02:00
|
|
|
return super.damageEntity(damagesource, i);
|
|
|
|
}
|
|
|
|
|
2011-09-15 05:13:14 +02:00
|
|
|
public void die(DamageSource damagesource) {
|
2011-09-15 02:23:52 +02:00
|
|
|
super.die(damagesource);
|
2012-01-12 23:10:13 +01:00
|
|
|
if (damagesource.b() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
|
2011-09-15 18:36:27 +02:00
|
|
|
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
|
2011-09-15 02:23:52 +02:00
|
|
|
double d0 = entityhuman.locX - this.locX;
|
|
|
|
double d1 = entityhuman.locZ - this.locZ;
|
|
|
|
|
|
|
|
if (d0 * d0 + d1 * d1 >= 2500.0D) {
|
|
|
|
entityhuman.a((Statistic) AchievementList.v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void d() {
|
|
|
|
if (this.world.e() && !this.world.isStatic) {
|
|
|
|
float f = this.a(1.0F);
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-11-29 08:10:05 +01:00
|
|
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-01-10 09:30:34 +01:00
|
|
|
if (!event.isCancelled()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.setOnFire(event.getDuration());
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
super.d();
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected void a(Entity entity, float f) {
|
|
|
|
if (f < 10.0F) {
|
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
double d1 = entity.locZ - this.locZ;
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.attackTicks == 0) {
|
2011-09-15 02:23:52 +02:00
|
|
|
EntityArrow entityarrow = new EntityArrow(this.world, this, 1.0F);
|
2012-01-12 23:10:13 +01:00
|
|
|
double d2 = entity.locY + (double) entity.y() - 0.699999988079071D - entityarrow.locY;
|
2012-01-14 21:03:48 +01:00
|
|
|
float f1 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 0.2F;
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-12-28 21:36:02 +01:00
|
|
|
this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
|
|
|
|
// this.world.addEntity(entityarrow); // CraftBukkit - moved down
|
2012-01-12 16:27:39 +01:00
|
|
|
entityarrow.shoot(d0, d2 + (double) f1, d1, 1.6F, 12.0F);
|
2011-09-15 02:23:52 +02:00
|
|
|
this.attackTicks = 60;
|
2011-12-28 21:36:02 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(this, null, entityarrow, 0.5F);
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
if (event.getProjectile() != null) {
|
|
|
|
event.getProjectile().remove();
|
|
|
|
}
|
|
|
|
} else if (event.getProjectile() == entityarrow.getBukkitEntity()) {
|
|
|
|
world.addEntity(entityarrow);
|
|
|
|
}
|
|
|
|
this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
|
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
|
|
|
|
this.e = true;
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return Item.ARROW.id;
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start - whole method
|
2011-06-27 00:25:01 +02:00
|
|
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
int count = this.random.nextInt(3 + i);
|
2011-01-30 21:21:24 +01:00
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count));
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
count = this.random.nextInt(3 + i);
|
2011-01-30 21:21:24 +01:00
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count));
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-10-04 16:04:45 +02:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public MonsterType getMonsterType() {
|
|
|
|
return MonsterType.UNDEAD;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|