2011-01-17 04:03:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
2011-01-17 09:17:16 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class EntitySpider extends EntityMonster {
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
public EntitySpider(World world) {
|
|
|
|
super(world);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.texture = "/mob/spider.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(1.4F, 0.9F);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bI = 0.8F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
2011-11-20 09:01:14 +01:00
|
|
|
this.datawatcher.a(16, new Byte((byte) 0));
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void l_() {
|
|
|
|
super.l_();
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!this.world.isStatic) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.a(this.positionChanged);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxHealth() {
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public double W() {
|
2011-11-30 00:17:43 +01:00
|
|
|
return (double) this.length * 0.75D - 0.5D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
protected Entity findTarget() {
|
2012-07-29 09:33:13 +02:00
|
|
|
float f = this.c(1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f < 0.5F) {
|
|
|
|
double d0 = 16.0D;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
return this.world.findNearbyVulnerablePlayer(this, d0);
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bb() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.spider.say";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bc() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.spider.say";
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bd() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.spider.death";
|
2011-01-17 04:03:19 +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.spider.step", 0.15F, 1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected void a(Entity entity, float f) {
|
2012-07-29 09:33:13 +02:00
|
|
|
float f1 = this.c(1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f1 > 0.5F && this.random.nextInt(100) == 0) {
|
2011-01-26 20:26:24 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
|
|
|
this.world.getServer().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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.target = null;
|
2011-01-26 20:26:24 +01:00
|
|
|
} else {
|
2012-07-22 08:18:00 +02:00
|
|
|
this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
|
2011-01-26 20:26:24 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) {
|
|
|
|
if (this.onGround) {
|
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
double d1 = entity.locZ - this.locZ;
|
2012-01-14 21:03:48 +01:00
|
|
|
float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D;
|
|
|
|
this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D;
|
|
|
|
this.motY = 0.4000000059604645D;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
super.a(entity, f);
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return Item.STRING.id;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Whole method; adapted from super.dropDeathLoot.
|
2012-07-22 08:18:00 +02:00
|
|
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-12-10 21:44:58 +01:00
|
|
|
|
2012-01-14 23:02:10 +01:00
|
|
|
int k = this.random.nextInt(3);
|
2011-12-10 21:44:58 +01:00
|
|
|
|
2012-01-14 23:02:10 +01:00
|
|
|
if (i > 0) {
|
|
|
|
k += this.random.nextInt(i + 1);
|
|
|
|
}
|
2011-12-10 21:44:58 +01:00
|
|
|
|
2012-01-14 23:02:10 +01:00
|
|
|
if (k > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(Item.STRING.id, k));
|
|
|
|
}
|
2011-12-10 21:44:58 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) {
|
2011-12-10 21:44:58 +01:00
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(Item.SPIDER_EYE.id, 1));
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-12-10 21:44:58 +01:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot
|
2011-12-10 21:44:58 +01:00
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean g_() {
|
|
|
|
return this.o();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void al() {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumMonsterType getMonsterType() {
|
|
|
|
return EnumMonsterType.ARTHROPOD;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean e(MobEffect mobeffect) {
|
|
|
|
return mobeffect.getEffectId() == MobEffectList.POISON.id ? false : super.e(mobeffect);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean o() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return (this.datawatcher.getByte(16) & 1) != 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(boolean flag) {
|
2011-11-20 09:01:14 +01:00
|
|
|
byte b0 = this.datawatcher.getByte(16);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
b0 = (byte) (b0 | 1);
|
|
|
|
} else {
|
|
|
|
b0 &= -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf(b0));
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void bJ() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.world.random.nextInt(100) == 0) {
|
|
|
|
EntitySkeleton entityskeleton = new EntitySkeleton(this.world);
|
|
|
|
|
|
|
|
entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
|
2013-03-13 23:33:27 +01:00
|
|
|
entityskeleton.bJ();
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addEntity(entityskeleton);
|
|
|
|
entityskeleton.mount(this);
|
|
|
|
}
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|