2011-01-17 04:03:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-01-17 09:17:16 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-01-26 20:26:24 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
|
|
|
import org.bukkit.event.entity.EntityTargetEvent;
|
|
|
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
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";
|
2011-03-31 22:40:00 +02:00
|
|
|
this.b(1.4F, 0.9F);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aD = 0.8F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public double m() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return (double) this.width * 0.75D - 0.5D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected boolean n() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
protected Entity findTarget() {
|
2011-02-23 03:37:56 +01: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-01-29 22:50:29 +01:00
|
|
|
return this.world.a(this, d0);
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String g() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.spider";
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String h() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.spider";
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String i() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "mob.spiderdeath";
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected void a(Entity entity, float f) {
|
2011-02-23 03:37:56 +01: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-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
2011-02-23 13:56:36 +01:00
|
|
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET);
|
2011-01-26 20:26:24 +01:00
|
|
|
server.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 {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.target = ((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;
|
|
|
|
float f2 = MathHelper.a(d0 * d0 + d1 * d1);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int j() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return Item.STRING.id;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean p() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.positionChanged;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|