Paper/src/main/java/net/minecraft/server/EntitySkeleton.java

128 lines
4.3 KiB
Java
Raw Normal View History

2011-01-08 08:40:42 +01:00
package net.minecraft.server;
import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
2011-01-29 22:50:29 +01:00
public class EntitySkeleton extends EntityMonster {
2011-01-08 08:40:42 +01:00
2012-07-29 09:33:13 +02:00
private static final ItemStack d = 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";
2012-07-29 09:33:13 +02:00
this.bw = 0.25F;
2012-03-01 11:49:23 +01:00
this.goalSelector.a(1, new PathfinderGoalFloat(this));
this.goalSelector.a(2, new PathfinderGoalRestrictSun(this));
2012-07-29 09:33:13 +02:00
this.goalSelector.a(3, new PathfinderGoalFleeSun(this, this.bw));
this.goalSelector.a(4, new PathfinderGoalArrowAttack(this, this.bw, 1, 60));
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, this.bw));
2012-03-01 11:49:23 +01:00
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, true));
2012-03-01 11:49:23 +01:00
}
2012-07-29 09:33:13 +02:00
public boolean aV() {
2012-03-01 11:49:23 +01:00
return true;
2011-01-10 09:30:34 +01:00
}
2011-11-20 09:01:14 +01:00
public int getMaxHealth() {
return 20;
}
2012-07-29 09:33:13 +02:00
protected String aQ() {
2011-01-10 09:30:34 +01:00
return "mob.skeleton";
}
2012-07-29 09:33:13 +02:00
protected String aR() {
2011-01-10 09:30:34 +01:00
return "mob.skeletonhurt";
}
2012-07-29 09:33:13 +02:00
protected String aS() {
2011-01-10 09:30:34 +01:00
return "mob.skeletonhurt";
}
2012-07-29 09:33:13 +02:00
public EnumMonsterType getMonsterType() {
return EnumMonsterType.UNDEAD;
2012-03-01 11:49:23 +01:00
}
2012-07-29 09:33:13 +02:00
public void d() {
if (this.world.r() && !this.world.isStatic) {
float f = this.c(1.0F);
2012-03-01 11:49:23 +01:00
2012-07-29 09:33:13 +02:00
if (f > 0.5F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setOnFire(event.getDuration());
}
// CraftBukkit end
2012-03-01 11:49:23 +01:00
}
}
2012-07-29 09:33:13 +02:00
super.d();
2011-09-15 02:23:52 +02:00
}
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-07-29 09:33:13 +02:00
if (damagesource.f() 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);
}
}
}
protected int getLootId() {
2011-01-29 22:50:29 +01:00
return Item.ARROW.id;
2011-01-14 14:31:10 +01:00
}
protected void dropDeathLoot(boolean flag, int i) {
2011-02-23 13:56:36 +01:00
// CraftBukkit start - whole method
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
2012-07-29 09:33:13 +02:00
int j = this.random.nextInt(3 + i);
2011-01-14 14:31:10 +01:00
2011-11-20 09:01:14 +01:00
int count = this.random.nextInt(3 + i);
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);
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
// Determine rare item drops and add them to the loot
if (this.lastDamageByPlayerTime > 0) {
int k = this.random.nextInt(200) - i;
if (k < 5) {
2012-07-29 09:33:13 +02:00
ItemStack itemstack = this.l(k <= 0 ? 1 : 0);
if (itemstack != null) {
loot.add(new org.bukkit.craftbukkit.inventory.CraftItemStack(itemstack));
}
}
}
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
// CraftBukkit start - return rare dropped item instead of dropping it
2012-07-29 09:33:13 +02:00
protected ItemStack l(int i) {
2012-03-01 11:49:23 +01:00
if (i > 0) {
ItemStack itemstack = new ItemStack(Item.BOW);
EnchantmentManager.a(this.random, itemstack, 5);
return itemstack;
2012-03-01 11:49:23 +01:00
} else {
return new ItemStack(Item.BOW.id, 1, 0);
2012-03-01 11:49:23 +01:00
}
2011-11-20 09:01:14 +01:00
}
// CraftBukkit end
2011-01-08 08:40:42 +01:00
}