2011-01-17 04:03:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 03:37:56 +01:00
|
|
|
import java.util.ArrayList;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.Server;
|
2011-01-17 09:17:16 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
2011-02-20 23:22:28 +01:00
|
|
|
import org.bukkit.craftbukkit.TrigMath;
|
2011-03-17 18:24:36 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
2011-01-20 09:10:47 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 09:17:16 +01:00
|
|
|
|
2011-01-17 04:03:19 +01:00
|
|
|
public abstract class EntityLiving extends Entity {
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public int maxNoDamageTicks = 20;
|
2011-05-26 14:48:22 +02:00
|
|
|
public float H;
|
|
|
|
public float I;
|
|
|
|
public float J = 0.0F;
|
|
|
|
public float K = 0.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
protected float L;
|
2011-05-26 14:48:22 +02:00
|
|
|
protected float M;
|
|
|
|
protected float N;
|
|
|
|
protected float O;
|
|
|
|
protected boolean P = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
protected String texture = "/mob/char.png";
|
2011-05-26 14:48:22 +02:00
|
|
|
protected boolean R = true;
|
|
|
|
protected float S = 0.0F;
|
|
|
|
protected String T = null;
|
|
|
|
protected float U = 1.0F;
|
|
|
|
protected int V = 0;
|
|
|
|
protected float W = 0.0F;
|
|
|
|
public boolean X = false;
|
|
|
|
public float Y;
|
|
|
|
public float Z;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int health = 10;
|
2011-05-26 14:48:22 +02:00
|
|
|
public int ab;
|
2011-01-17 04:03:19 +01:00
|
|
|
private int a;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int hurtTicks;
|
2011-05-26 14:48:22 +02:00
|
|
|
public int ad;
|
|
|
|
public float ae = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int deathTicks = 0;
|
|
|
|
public int attackTicks = 0;
|
2011-05-26 14:48:22 +02:00
|
|
|
public float ah;
|
|
|
|
public float ai;
|
|
|
|
protected boolean aj = false;
|
|
|
|
public int ak = -1;
|
|
|
|
public float al = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D);
|
|
|
|
public float am;
|
|
|
|
public float an;
|
|
|
|
public float ao;
|
|
|
|
protected int ap;
|
2011-02-23 03:37:56 +01:00
|
|
|
protected double aq;
|
2011-04-20 22:47:26 +02:00
|
|
|
protected double ar;
|
2011-05-26 14:48:22 +02:00
|
|
|
protected double as;
|
|
|
|
protected double at;
|
|
|
|
protected double au;
|
|
|
|
float av = 0.0F;
|
2011-05-14 16:29:42 +02:00
|
|
|
public int lastDamage = 0; // CraftBukkit - protected -> public
|
2011-05-26 14:48:22 +02:00
|
|
|
protected int ax = 0;
|
|
|
|
protected float ay;
|
|
|
|
protected float az;
|
|
|
|
protected float aA;
|
|
|
|
protected boolean aB = false;
|
|
|
|
protected float aC = 0.0F;
|
|
|
|
protected float aD = 0.7F;
|
2011-01-17 04:03:19 +01:00
|
|
|
private Entity b;
|
2011-05-26 14:48:22 +02:00
|
|
|
protected int aE = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
public EntityLiving(World world) {
|
|
|
|
super(world);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aH = true;
|
|
|
|
this.I = (float) (Math.random() + 1.0D) * 0.01F;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.H = (float) Math.random() * 12398.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.br = 0.5F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void b() {}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public boolean e(Entity entity) {
|
2011-04-20 22:47:26 +02:00
|
|
|
return this.world.a(Vec3D.create(this.locX, this.locY + (double) this.s(), this.locZ), Vec3D.create(entity.locX, entity.locY + (double) entity.s(), entity.locZ)) == null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean o_() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean d_() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public float s() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.width * 0.85F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public int e() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void N() {
|
2011-04-20 22:47:26 +02:00
|
|
|
String s = this.g();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
if (s != null) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.world.makeSound(this, s, this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void O() {
|
|
|
|
this.Y = this.Z;
|
|
|
|
super.O();
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextInt(1000) < this.a++) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a = -this.e();
|
2011-05-26 14:48:22 +02:00
|
|
|
this.N();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.Q() && this.H()) {
|
2011-01-20 09:49:35 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
2011-01-20 09:49:35 +01:00
|
|
|
org.bukkit.entity.Entity victim = this.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.SUFFOCATION;
|
2011-02-28 07:43:56 +01:00
|
|
|
int damage = 1;
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-28 07:43:56 +01:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(victim, damageType, damage);
|
2011-01-29 22:50:29 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.damageEntity((Entity) null, event.getDamage());
|
2011-01-20 09:49:35 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.bC || this.world.isStatic) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.fireTicks = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
int i;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.Q() && this.a(Material.WATER) && !this.b_()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
--this.airTicks;
|
|
|
|
if (this.airTicks == -20) {
|
|
|
|
this.airTicks = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; ++i) {
|
|
|
|
float f = this.random.nextFloat() - this.random.nextFloat();
|
|
|
|
float f1 = this.random.nextFloat() - this.random.nextFloat();
|
|
|
|
float f2 = this.random.nextFloat() - this.random.nextFloat();
|
|
|
|
|
|
|
|
this.world.a("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-30 10:26:45 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
2011-01-30 10:26:45 +01:00
|
|
|
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING;
|
|
|
|
int damageDone = 2;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
|
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-30 10:26:45 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.damageEntity((Entity) null, event.getDamage());
|
2011-01-30 10:26:45 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.fireTicks = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.airTicks = this.maxAirTicks;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ah = this.ai;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.attackTicks > 0) {
|
|
|
|
--this.attackTicks;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.hurtTicks > 0) {
|
|
|
|
--this.hurtTicks;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.noDamageTicks > 0) {
|
|
|
|
--this.noDamageTicks;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health <= 0) {
|
|
|
|
++this.deathTicks;
|
|
|
|
if (this.deathTicks > 20) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.U();
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
for (i = 0; i < 20; ++i) {
|
|
|
|
double d0 = this.random.nextGaussian() * 0.02D;
|
|
|
|
double d1 = this.random.nextGaussian() * 0.02D;
|
|
|
|
double d2 = this.random.nextGaussian() * 0.02D;
|
|
|
|
|
|
|
|
this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, this.locY + (double) (this.random.nextFloat() * this.width), this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, d0, d1, d2);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.O = this.N;
|
|
|
|
this.K = this.J;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastYaw = this.yaw;
|
|
|
|
this.lastPitch = this.pitch;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void P() {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < 20; ++i) {
|
|
|
|
double d0 = this.random.nextGaussian() * 0.02D;
|
|
|
|
double d1 = this.random.nextGaussian() * 0.02D;
|
|
|
|
double d2 = this.random.nextGaussian() * 0.02D;
|
|
|
|
double d3 = 10.0D;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.width) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length - d2 * d3, d0, d1, d2);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void B() {
|
|
|
|
super.B();
|
2011-05-26 14:48:22 +02:00
|
|
|
this.L = this.M;
|
|
|
|
this.M = 0.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void p_() {
|
|
|
|
super.p_();
|
|
|
|
this.u();
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
|
|
|
float f = MathHelper.a(d0 * d0 + d1 * d1);
|
2011-05-26 14:48:22 +02:00
|
|
|
float f1 = this.J;
|
2011-01-29 22:50:29 +01:00
|
|
|
float f2 = 0.0F;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.L = this.M;
|
2011-01-17 04:03:19 +01:00
|
|
|
float f3 = 0.0F;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f > 0.05F) {
|
|
|
|
f3 = 1.0F;
|
|
|
|
f2 = f * 3.0F;
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - Math -> TrigMath
|
2011-02-23 13:56:36 +01:00
|
|
|
f1 = (float) TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.Z > 0.0F) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f1 = this.yaw;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (!this.onGround) {
|
|
|
|
f3 = 0.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.M += (f3 - this.M) * 0.3F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
float f4;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (f4 = f1 - this.J; f4 < -180.0F; f4 += 360.0F) {
|
2011-01-17 04:03:19 +01:00
|
|
|
;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (f4 >= 180.0F) {
|
|
|
|
f4 -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J += f4 * 0.3F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
float f5;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (f5 = this.yaw - this.J; f5 < -180.0F; f5 += 360.0F) {
|
2011-01-17 04:03:19 +01:00
|
|
|
;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (f5 >= 180.0F) {
|
|
|
|
f5 -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = f5 < -90.0F || f5 >= 90.0F;
|
|
|
|
|
|
|
|
if (f5 < -75.0F) {
|
|
|
|
f5 = -75.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f5 >= 75.0F) {
|
|
|
|
f5 = 75.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J = this.yaw - f5;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f5 * f5 > 2500.0F) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J += f5 * 0.2F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-01-17 04:03:19 +01:00
|
|
|
if (flag) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f2 *= -1.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (this.yaw - this.lastYaw < -180.0F) {
|
|
|
|
this.lastYaw -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (this.yaw - this.lastYaw >= 180.0F) {
|
|
|
|
this.lastYaw += 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
while (this.J - this.K < -180.0F) {
|
|
|
|
this.K -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
while (this.J - this.K >= 180.0F) {
|
|
|
|
this.K += 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (this.pitch - this.lastPitch < -180.0F) {
|
|
|
|
this.lastPitch -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (this.pitch - this.lastPitch >= 180.0F) {
|
|
|
|
this.lastPitch += 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.N += f2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected void b(float f, float f1) {
|
|
|
|
super.b(f, f1);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void b(int i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health > 0) {
|
|
|
|
this.health += i;
|
|
|
|
if (this.health > 20) {
|
|
|
|
this.health = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.noDamageTicks = this.maxNoDamageTicks / 2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean damageEntity(Entity entity, int i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.world.isStatic) {
|
2011-01-17 04:03:19 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ax = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health <= 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.an = 1.5F;
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = true;
|
|
|
|
|
|
|
|
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
|
|
|
|
if (i <= this.lastDamage) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c(i - this.lastDamage);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastDamage = i;
|
|
|
|
flag = false;
|
|
|
|
} else {
|
|
|
|
this.lastDamage = i;
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ab = this.health;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.noDamageTicks = this.maxNoDamageTicks;
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c(i);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.hurtTicks = this.ad = 10;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ae = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (flag) {
|
|
|
|
this.world.a(this, (byte) 2);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ac();
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entity != null) {
|
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
|
|
|
|
double d1;
|
|
|
|
|
|
|
|
for (d1 = entity.locZ - this.locZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
|
|
|
|
d0 = (Math.random() - Math.random()) * 0.01D;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ae = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(entity, i, d0, d1);
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ae = (float) ((int) (Math.random() * 2.0D) * 180);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.health <= 0) {
|
|
|
|
if (flag) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.world.makeSound(this, this.i(), this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.a(entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (flag) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.world.makeSound(this, this.h(), this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected void c(int i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.health -= i;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected float k() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 1.0F;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String g() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String h() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "random.hurt";
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected String i() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return "random.hurt";
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Entity entity, int i, double d0, double d1) {
|
|
|
|
float f = MathHelper.a(d0 * d0 + d1 * d1);
|
|
|
|
float f1 = 0.4F;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX /= 2.0D;
|
|
|
|
this.motY /= 2.0D;
|
|
|
|
this.motZ /= 2.0D;
|
|
|
|
this.motX -= d0 / (double) f * (double) f1;
|
|
|
|
this.motY += 0.4000000059604645D;
|
|
|
|
this.motZ -= d1 / (double) f * (double) f1;
|
|
|
|
if (this.motY > 0.4000000059604645D) {
|
|
|
|
this.motY = 0.4000000059604645D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void a(Entity entity) {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.V >= 0 && entity != null) {
|
|
|
|
entity.c(this, this.V);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
entity.a(this);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aj = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!this.world.isStatic) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.r();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.world.a(this, (byte) 3);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void r() {
|
|
|
|
int i = this.j();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
|
|
|
// CraftBukkit start - whole method
|
2011-01-30 21:21:24 +01:00
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
|
|
|
|
int count = random.nextInt(3);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
if ((i > 0) && (count > 0)) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(i, count));
|
2011-01-30 21:21:24 +01:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
CraftEntity entity = (CraftEntity) getBukkitEntity();
|
2011-03-26 22:32:56 +01:00
|
|
|
EntityDeathEvent event = new EntityDeathEvent(entity, loot);
|
2011-02-23 13:56:36 +01:00
|
|
|
CraftWorld cworld = ((WorldServer) world).getWorld();
|
|
|
|
Server server = ((WorldServer) world).getServer();
|
2011-01-30 21:21:24 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
for (org.bukkit.inventory.ItemStack stack: event.getDrops()) {
|
2011-01-30 21:21:24 +01:00
|
|
|
cworld.dropItemNaturally(entity.getLocation(), stack);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected int j() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected void a(float f) {
|
2011-05-26 14:48:22 +02:00
|
|
|
super.a(f);
|
2011-01-29 22:50:29 +01:00
|
|
|
int i = (int) Math.ceil((double) (f - 3.0F));
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (i > 0) {
|
2011-01-20 09:10:47 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
2011-01-20 09:10:47 +01:00
|
|
|
org.bukkit.entity.Entity victim = this.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.FALL;
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(victim, damageType, i);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (!event.isCancelled() && event.getDamage() != 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.damageEntity((Entity) null, event.getDamage());
|
2011-01-20 09:10:47 +01:00
|
|
|
}
|
2011-01-20 09:11:08 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ));
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
StepSound stepsound = Block.byId[j].stepSound;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void a(float f, float f1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.aa()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locY;
|
|
|
|
this.a(f, f1, 0.02F);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX *= 0.800000011920929D;
|
|
|
|
this.motY *= 0.800000011920929D;
|
|
|
|
this.motZ *= 0.800000011920929D;
|
|
|
|
this.motY -= 0.02D;
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.positionChanged && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.30000001192092896D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
} else if (this.ab()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locY;
|
|
|
|
this.a(f, f1, 0.02F);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motX *= 0.5D;
|
|
|
|
this.motY *= 0.5D;
|
|
|
|
this.motZ *= 0.5D;
|
|
|
|
this.motY -= 0.02D;
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.positionChanged && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.30000001192092896D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
float f2 = 0.91F;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.onGround) {
|
|
|
|
f2 = 0.54600006F;
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ));
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (i > 0) {
|
|
|
|
f2 = Block.byId[i].frictionFactor * 0.91F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
float f3 = 0.16277136F / (f2 * f2 * f2);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(f, f1, this.onGround ? 0.1F * f3 : 0.02F);
|
|
|
|
f2 = 0.91F;
|
|
|
|
if (this.onGround) {
|
|
|
|
f2 = 0.54600006F;
|
2011-04-20 19:05:14 +02:00
|
|
|
int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ));
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
f2 = Block.byId[j].frictionFactor * 0.91F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.p()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
float f4 = 0.15F;
|
|
|
|
|
|
|
|
if (this.motX < (double) (-f4)) {
|
|
|
|
this.motX = (double) (-f4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.motX > (double) f4) {
|
|
|
|
this.motX = (double) f4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.motZ < (double) (-f4)) {
|
|
|
|
this.motZ = (double) (-f4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.motZ > (double) f4) {
|
|
|
|
this.motZ = (double) f4;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.fallDistance = 0.0F;
|
|
|
|
if (this.motY < -0.15D) {
|
|
|
|
this.motY = -0.15D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isSneaking() && this.motY < 0.0D) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.motY = 0.0D;
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.move(this.motX, this.motY, this.motZ);
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.positionChanged && this.p()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.2D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.motY -= 0.08D;
|
|
|
|
this.motY *= 0.9800000190734863D;
|
|
|
|
this.motX *= (double) f2;
|
|
|
|
this.motZ *= (double) f2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.am = this.an;
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
2011-05-26 14:48:22 +02:00
|
|
|
float f5 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (f5 > 1.0F) {
|
|
|
|
f5 = 1.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.an += (f5 - this.an) * 0.4F;
|
|
|
|
this.ao += this.an;
|
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
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.boundingBox.b);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
return this.world.getTypeId(i, j, k) == Block.LADDER.id;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
2011-01-29 22:50:29 +01:00
|
|
|
nbttagcompound.a("Health", (short) this.health);
|
|
|
|
nbttagcompound.a("HurtTime", (short) this.hurtTicks);
|
|
|
|
nbttagcompound.a("DeathTime", (short) this.deathTicks);
|
|
|
|
nbttagcompound.a("AttackTime", (short) this.attackTicks);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.health = nbttagcompound.d("Health");
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!nbttagcompound.hasKey("Health")) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.health = 10;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.hurtTicks = nbttagcompound.d("HurtTime");
|
|
|
|
this.deathTicks = nbttagcompound.d("DeathTime");
|
|
|
|
this.attackTicks = nbttagcompound.d("AttackTime");
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean Q() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead && this.health > 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public boolean b_() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void u() {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.ap > 0) {
|
|
|
|
double d0 = this.locX + (this.aq - this.locX) / (double) this.ap;
|
|
|
|
double d1 = this.locY + (this.ar - this.locY) / (double) this.ap;
|
|
|
|
double d2 = this.locZ + (this.as - this.locZ) / (double) this.ap;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
double d3;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (d3 = this.at - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) {
|
2011-01-17 04:03:19 +01:00
|
|
|
;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (d3 >= 180.0D) {
|
|
|
|
d3 -= 360.0D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.yaw = (float) ((double) this.yaw + d3 / (double) this.ap);
|
|
|
|
this.pitch = (float) ((double) this.pitch + (this.au - (double) this.pitch) / (double) this.ap);
|
|
|
|
--this.ap;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(d0, d1, d2);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c(this.yaw, this.pitch);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.A()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aB = false;
|
|
|
|
this.ay = 0.0F;
|
|
|
|
this.az = 0.0F;
|
|
|
|
this.aA = 0.0F;
|
|
|
|
} else if (!this.X) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.c_();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag = this.aa();
|
|
|
|
boolean flag1 = this.ab();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.aB) {
|
2011-01-17 04:03:19 +01:00
|
|
|
if (flag) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY += 0.03999999910593033D;
|
2011-01-17 04:03:19 +01:00
|
|
|
} else if (flag1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY += 0.03999999910593033D;
|
|
|
|
} else if (this.onGround) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.L();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ay *= 0.98F;
|
|
|
|
this.az *= 0.98F;
|
|
|
|
this.aA *= 0.9F;
|
|
|
|
this.a(this.ay, this.az);
|
2011-01-29 22:50:29 +01:00
|
|
|
List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity = (Entity) list.get(i);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (entity.d_()) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.collide(this);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected boolean A() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.health <= 0;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void L() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.41999998688697815D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected boolean l_() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
protected void R() {
|
2011-01-29 22:50:29 +01:00
|
|
|
EntityHuman entityhuman = this.world.a(this, -1.0D);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.l_() && entityhuman != null) {
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0 = entityhuman.locX - this.locX;
|
|
|
|
double d1 = entityhuman.locY - this.locY;
|
|
|
|
double d2 = entityhuman.locZ - this.locZ;
|
|
|
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d3 > 16384.0D) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.ax > 600 && this.random.nextInt(800) == 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d3 < 1024.0D) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.ax = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void c_() {
|
2011-05-26 14:48:22 +02:00
|
|
|
++this.ax;
|
2011-04-20 22:47:26 +02:00
|
|
|
EntityHuman entityhuman = this.world.a(this, -1.0D);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.R();
|
|
|
|
this.ay = 0.0F;
|
|
|
|
this.az = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
float f = 8.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextFloat() < 0.02F) {
|
|
|
|
entityhuman = this.world.a(this, (double) f);
|
|
|
|
if (entityhuman != null) {
|
|
|
|
this.b = entityhuman;
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aE = 10 + this.random.nextInt(20);
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aA = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (this.b != null) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(this.b, 10.0F, (float) this.v());
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.aE-- <= 0 || this.b.dead || this.b.g(this) > (double) (f * f)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b = null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextFloat() < 0.05F) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aA = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.yaw += this.aA;
|
|
|
|
this.pitch = this.aC;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag = this.aa();
|
|
|
|
boolean flag1 = this.ab();
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
if (flag || flag1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.aB = this.random.nextFloat() < 0.8F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected int v() {
|
|
|
|
return 40;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Entity entity, float f, float f1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
double d1 = entity.locZ - this.locZ;
|
|
|
|
double d2;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
EntityLiving entityliving = (EntityLiving) entity;
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
d2 = this.locY + (double) this.s() - (entityliving.locY + (double) entityliving.s());
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-04-20 22:47:26 +02:00
|
|
|
d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.s());
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1);
|
2011-03-31 22:40:00 +02:00
|
|
|
float f2 = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
float f3 = (float) (-(Math.atan2(d2, d3) * 180.0D / 3.1415927410125732D));
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
this.pitch = -this.b(this.pitch, f3, f1);
|
|
|
|
this.yaw = this.b(this.yaw, f2, f);
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean S() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return this.b != null;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public Entity T() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return this.b;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private float b(float f, float f1, float f2) {
|
|
|
|
float f3;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (f3 = f1 - f; f3 < -180.0F; f3 += 360.0F) {
|
2011-01-17 04:03:19 +01:00
|
|
|
;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
while (f3 >= 180.0F) {
|
|
|
|
f3 -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f3 > f2) {
|
|
|
|
f3 = f2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f3 < -f2) {
|
|
|
|
f3 = -f2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
return f + f3;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void U() {}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean d() {
|
|
|
|
return this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
protected void V() {
|
2011-03-17 18:24:36 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.VOID;
|
|
|
|
org.bukkit.block.Block damager = null;
|
|
|
|
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
|
|
|
int damageDone = 4;
|
|
|
|
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (event.isCancelled() || event.getDamage() == 0) {
|
2011-03-17 18:24:36 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-03-17 18:24:36 +01:00
|
|
|
damageDone = event.getDamage();
|
2011-04-20 19:05:14 +02:00
|
|
|
this.damageEntity((Entity) null, damageDone);
|
2011-03-17 18:24:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public Vec3D W() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.b(1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public Vec3D b(float f) {
|
2011-01-29 22:50:29 +01:00
|
|
|
float f1;
|
|
|
|
float f2;
|
|
|
|
float f3;
|
|
|
|
float f4;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f == 1.0F) {
|
2011-04-20 19:05:14 +02:00
|
|
|
f1 = MathHelper.cos(-this.yaw * 0.017453292F - 3.1415927F);
|
|
|
|
f2 = MathHelper.sin(-this.yaw * 0.017453292F - 3.1415927F);
|
|
|
|
f3 = -MathHelper.cos(-this.pitch * 0.017453292F);
|
|
|
|
f4 = MathHelper.sin(-this.pitch * 0.017453292F);
|
|
|
|
return Vec3D.create((double) (f2 * f3), (double) f4, (double) (f1 * f3));
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
f1 = this.lastPitch + (this.pitch - this.lastPitch) * f;
|
|
|
|
f2 = this.lastYaw + (this.yaw - this.lastYaw) * f;
|
2011-04-20 19:05:14 +02:00
|
|
|
f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
|
|
|
|
f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
|
|
|
|
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
|
|
|
float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
return Vec3D.create((double) (f4 * f5), (double) f6, (double) (f3 * f5));
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public int l() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 4;
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isSleeping() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|