2011-01-08 08:40:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
import java.util.Calendar;
|
2012-03-21 02:55:45 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public class EntitySkeleton extends EntityMonster implements IRangedEntity {
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
private PathfinderGoalArrowAttack d = new PathfinderGoalArrowAttack(this, 0.25F, 60, 10.0F);
|
|
|
|
private PathfinderGoalMeleeAttack e = new PathfinderGoalMeleeAttack(this, EntityHuman.class, 0.31F, false);
|
|
|
|
|
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";
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bI = 0.25F;
|
2012-03-01 11:49:23 +01:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalFloat(this));
|
|
|
|
this.goalSelector.a(2, new PathfinderGoalRestrictSun(this));
|
2013-03-13 23:33:27 +01:00
|
|
|
this.goalSelector.a(3, new PathfinderGoalFleeSun(this, this.bI));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, this.bI));
|
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));
|
2012-03-22 21:39:39 +01:00
|
|
|
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, true));
|
2012-11-06 13:05:28 +01:00
|
|
|
if (world != null && !world.isStatic) {
|
|
|
|
this.m();
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
|
|
|
this.datawatcher.a(13, new Byte((byte) 0));
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bh() {
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bb() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.skeleton.say";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bc() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.skeleton.hurt";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bd() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.skeleton.death";
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected void a(int i, int j, int k, int l) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.skeleton.step", 0.15F, 1.0F);
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean m(Entity entity) {
|
|
|
|
if (super.m(entity)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.getSkeletonType() == 1 && entity instanceof EntityLiving) {
|
|
|
|
((EntityLiving) entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 200));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int c(Entity entity) {
|
|
|
|
if (this.getSkeletonType() == 1) {
|
2013-03-13 23:33:27 +01:00
|
|
|
ItemStack itemstack = this.bG();
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = 4;
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
|
|
|
i += itemstack.a((Entity) this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
} else {
|
|
|
|
return super.c(entity);
|
|
|
|
}
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumMonsterType getMonsterType() {
|
|
|
|
return EnumMonsterType.UNDEAD;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.world.u() && !this.world.isStatic) {
|
2012-07-29 09:33:13 +02:00
|
|
|
float f = this.c(1.0F);
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.l(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))) {
|
2012-10-25 05:53:23 +02:00
|
|
|
boolean flag = true;
|
|
|
|
ItemStack itemstack = this.getEquipment(4);
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemstack.g()) {
|
|
|
|
itemstack.setData(itemstack.j() + this.random.nextInt(2));
|
|
|
|
if (itemstack.j() >= itemstack.l()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a(itemstack);
|
|
|
|
this.setEquipment(4, (ItemStack) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
// CraftBukkit start
|
2012-07-22 08:18:00 +02:00
|
|
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
2012-03-15 23:42:30 +01:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.setOnFire(event.getDuration());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.world.isStatic && this.getSkeletonType() == 1) {
|
|
|
|
this.a(0.72F, 2.34F);
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
super.c();
|
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);
|
2013-03-13 23:33:27 +01:00
|
|
|
if (damagesource.h() 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.getSkeletonType() == 1) {
|
|
|
|
int count = this.random.nextInt(3 + i) - 1;
|
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.COAL, count));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int count = this.random.nextInt(3 + i);
|
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count));
|
|
|
|
}
|
2011-01-30 21:21:24 +01:00
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2012-10-25 05:53:23 +02: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.BONE, count));
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2012-03-21 02:55:45 +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);
|
2012-03-21 02:55:45 +01:00
|
|
|
if (itemstack != null) {
|
2012-12-17 08:31:41 +01:00
|
|
|
loot.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
|
2012-03-21 02:55:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 08:18:00 +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
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
// CraftBukkit - return rare dropped item instead of dropping it
|
2012-07-29 09:33:13 +02:00
|
|
|
protected ItemStack l(int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.getSkeletonType() == 1) {
|
|
|
|
return new ItemStack(Item.SKULL.id, 1, 1); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bH() {
|
|
|
|
super.bH();
|
2012-10-25 05:53:23 +02:00
|
|
|
this.setEquipment(0, new ItemStack(Item.BOW));
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void bJ() {
|
|
|
|
if (this.world.worldProvider instanceof WorldProviderHell && this.aE().nextInt(5) > 0) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.goalSelector.a(4, this.e);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.setSkeletonType(1);
|
|
|
|
this.setEquipment(0, new ItemStack(Item.STONE_SWORD));
|
|
|
|
} else {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.goalSelector.a(4, this.d);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bH();
|
|
|
|
this.bI();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.h(this.random.nextFloat() < au[this.world.difficulty]);
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.getEquipment(4) == null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
Calendar calendar = this.world.U();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) {
|
|
|
|
this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Block.JACK_O_LANTERN : Block.PUMPKIN));
|
|
|
|
this.dropChances[4] = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public void m() {
|
|
|
|
this.goalSelector.a((PathfinderGoal) this.e);
|
|
|
|
this.goalSelector.a((PathfinderGoal) this.d);
|
2013-03-13 23:33:27 +01:00
|
|
|
ItemStack itemstack = this.bG();
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
if (itemstack != null && itemstack.id == Item.BOW.id) {
|
|
|
|
this.goalSelector.a(4, this.d);
|
|
|
|
} else {
|
|
|
|
this.goalSelector.a(4, this.e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(EntityLiving entityliving, float f) {
|
|
|
|
EntityArrow entityarrow = new EntityArrow(this.world, this, entityliving, 1.6F, (float) (14 - this.world.difficulty * 4));
|
|
|
|
int i = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, this.bG());
|
|
|
|
int j = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, this.bG());
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
entityarrow.b((double) (f * 2.0F) + this.random.nextGaussian() * 0.25D + (double) ((float) this.world.difficulty * 0.11F));
|
2012-03-01 11:49:23 +01:00
|
|
|
if (i > 0) {
|
2012-10-25 05:53:23 +02:00
|
|
|
entityarrow.b(entityarrow.c() + (double) i * 0.5D + 0.5D);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
entityarrow.a(j);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, this.bG()) > 0 || this.getSkeletonType() == 1) {
|
2012-10-25 05:53:23 +02:00
|
|
|
entityarrow.setOnFire(100);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.makeSound("random.bow", 1.0F, 1.0F / (this.aE().nextFloat() * 0.4F + 0.8F));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addEntity(entityarrow);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSkeletonType() {
|
|
|
|
return this.datawatcher.getByte(13);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSkeletonType(int i) {
|
|
|
|
this.datawatcher.watch(13, Byte.valueOf((byte) i));
|
|
|
|
this.fireProof = i == 1;
|
|
|
|
if (i == 1) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.a(0.72F, 2.34F);
|
2012-10-25 05:53:23 +02:00
|
|
|
} else {
|
|
|
|
this.a(0.6F, 1.8F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
if (nbttagcompound.hasKey("SkeletonType")) {
|
|
|
|
byte b0 = nbttagcompound.getByte("SkeletonType");
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.setSkeletonType(b0);
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
this.m();
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setByte("SkeletonType", (byte) this.getSkeletonType());
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
public void setEquipment(int i, ItemStack itemstack) {
|
|
|
|
super.setEquipment(i, itemstack);
|
|
|
|
if (!this.world.isStatic && i == 0) {
|
|
|
|
this.m();
|
|
|
|
}
|
|
|
|
}
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|