2011-01-17 04:03:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
2011-01-17 04:03:19 +01:00
|
|
|
import java.util.List;
|
2012-01-12 23:10:13 +01:00
|
|
|
import java.util.Random;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-02-20 23:22:28 +01:00
|
|
|
import org.bukkit.craftbukkit.TrigMath;
|
2011-09-21 16:41:24 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
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;
|
2011-06-17 22:50:56 +02:00
|
|
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
2011-06-29 02:11:23 +02:00
|
|
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
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-09-15 02:23:52 +02:00
|
|
|
public float T;
|
2011-11-20 09:01:14 +01:00
|
|
|
public float U;
|
2011-09-15 02:23:52 +02:00
|
|
|
public float V = 0.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
public float W = 0.0F;
|
2012-01-12 23:10:13 +01:00
|
|
|
public float X = 0.0F;
|
|
|
|
public float Y = 0.0F;
|
2011-09-15 02:23:52 +02:00
|
|
|
protected float Z;
|
2011-11-20 09:01:14 +01:00
|
|
|
protected float aa;
|
2012-01-12 23:10:13 +01:00
|
|
|
protected float ab;
|
|
|
|
protected float ac;
|
2011-11-20 09:01:14 +01:00
|
|
|
protected boolean ad = true;
|
2012-01-12 23:10:13 +01:00
|
|
|
protected String texture = "/mob/char.png";
|
|
|
|
protected boolean af = true;
|
|
|
|
protected float ag = 0.0F;
|
|
|
|
protected String ah = null;
|
|
|
|
protected float ai = 1.0F;
|
|
|
|
protected int aj = 0;
|
|
|
|
protected float ak = 0.0F;
|
|
|
|
public float al = 0.1F;
|
|
|
|
public float am = 0.02F;
|
2011-11-20 09:01:14 +01:00
|
|
|
public float an;
|
2012-01-12 23:10:13 +01:00
|
|
|
public float ao;
|
2011-11-20 09:01:14 +01:00
|
|
|
protected int health = this.getMaxHealth();
|
2012-01-12 23:10:13 +01:00
|
|
|
public int aq;
|
|
|
|
protected int ar;
|
2011-01-17 04:03:19 +01:00
|
|
|
private int a;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int hurtTicks;
|
2012-01-12 23:10:13 +01:00
|
|
|
public int at;
|
|
|
|
public float au = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int deathTicks = 0;
|
|
|
|
public int attackTicks = 0;
|
2011-11-20 09:01:14 +01:00
|
|
|
public float ax;
|
2012-01-12 23:10:13 +01:00
|
|
|
public float ay;
|
|
|
|
protected boolean az = false;
|
|
|
|
protected int aA;
|
|
|
|
public int aB = -1;
|
|
|
|
public float aC = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D);
|
2011-11-20 09:01:14 +01:00
|
|
|
public float aD;
|
|
|
|
public float aE;
|
2012-01-12 23:10:13 +01:00
|
|
|
public float aF;
|
2012-01-12 16:27:39 +01:00
|
|
|
public EntityHuman killer = null; // CraftBukkit - prot to pub
|
2012-01-12 23:10:13 +01:00
|
|
|
protected int aH = 0;
|
|
|
|
protected EntityLiving aI = null;
|
|
|
|
public int aJ = 0;
|
|
|
|
public int aK = 0;
|
2011-09-24 23:03:31 +02:00
|
|
|
protected HashMap effects = new HashMap();
|
2011-11-20 09:01:14 +01:00
|
|
|
private boolean b = true;
|
|
|
|
private int c;
|
2012-01-12 23:10:13 +01:00
|
|
|
private ControllerLook lookController;
|
|
|
|
private ControllerMove moveController;
|
|
|
|
private ControllerJump jumpController;
|
|
|
|
private Navigation navigation;
|
|
|
|
protected PathfinderGoalSelector goalSelector = new PathfinderGoalSelector();
|
|
|
|
protected int aN;
|
2011-11-20 09:01:14 +01:00
|
|
|
protected double aO;
|
|
|
|
protected double aP;
|
2012-01-12 23:10:13 +01:00
|
|
|
protected double aQ;
|
|
|
|
protected double aR;
|
|
|
|
protected double aS;
|
|
|
|
float aT = 0.0F;
|
2011-05-14 16:29:42 +02:00
|
|
|
public int lastDamage = 0; // CraftBukkit - protected -> public
|
2012-01-12 23:10:13 +01:00
|
|
|
protected int aV = 0;
|
|
|
|
protected float aW;
|
|
|
|
protected float aX;
|
|
|
|
protected float aY;
|
|
|
|
protected boolean aZ = false;
|
|
|
|
protected float ba = 0.0F;
|
|
|
|
protected float bb = 0.7F;
|
|
|
|
private int h = 0;
|
|
|
|
private Entity i;
|
|
|
|
protected int bc = 0;
|
2012-01-12 12:02:39 +01:00
|
|
|
public int expToDrop = 0; // CraftBukkit
|
|
|
|
public int maxAirTicks = 300; // CraftBukkit
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
public EntityLiving(World world) {
|
|
|
|
super(world);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.bf = true;
|
|
|
|
this.lookController = new ControllerLook(this);
|
|
|
|
this.moveController = new ControllerMove(this, this.bb);
|
|
|
|
this.jumpController = new ControllerJump(this);
|
|
|
|
this.navigation = new PathfinderNavigation(this, world);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.U = (float) (Math.random() + 1.0D) * 0.01F;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.T = (float) Math.random() * 12398.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.X = this.yaw;
|
|
|
|
this.bP = 0.5F;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerLook getControllerLook() {
|
|
|
|
return this.lookController;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerMove getControllerMove() {
|
|
|
|
return this.moveController;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerJump getControllerJump() {
|
|
|
|
return this.jumpController;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Navigation ah() {
|
|
|
|
return this.navigation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Random ai() {
|
|
|
|
return this.random;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityLiving aj() {
|
|
|
|
return this.aI;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int ak() {
|
|
|
|
return this.aV;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected void b() {
|
|
|
|
this.datawatcher.a(8, Integer.valueOf(this.c));
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean g(Entity entity) {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.world.a(Vec3D.create(this.locX, this.locY + (double) this.y(), this.locZ), Vec3D.create(entity.locX, entity.locY + (double) entity.y(), entity.locZ)) == null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean e_() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean f_() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public float y() {
|
2011-11-30 00:17:43 +01:00
|
|
|
return this.length * 0.85F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public int h() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void al() {
|
2011-11-20 09:01:14 +01:00
|
|
|
String s = this.c_();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
if (s != null) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.world.makeSound(this, s, this.o(), this.v());
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void am() {
|
|
|
|
this.an = this.ao;
|
|
|
|
super.am();
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a("mobBaseTick"); // CraftBukkit - not in production code
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextInt(1000) < this.a++) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.a = -this.h();
|
2012-01-12 23:10:13 +01:00
|
|
|
this.al();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-23 01:08:56 +01:00
|
|
|
// CraftBukkit start - don't inline the damage, perform it with an event
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.isAlive() && this.U()) {
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.SUFFOCATION, 1);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!event.isCancelled()) {
|
2011-09-15 18:36:27 +02:00
|
|
|
this.damageEntity(DamageSource.STUCK, 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-11-30 00:17:43 +01:00
|
|
|
if (this.isFireproof() || this.world.isStatic) {
|
|
|
|
this.extinguish();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
if (this.isAlive() && this.a(Material.WATER) && !this.f() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id))) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.setAirTicks(this.f(this.getAirTicks()));
|
|
|
|
if (this.getAirTicks() == -20) {
|
|
|
|
this.setAirTicks(0);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (int i = 0; i < 8; ++i) {
|
2011-01-29 22:50:29 +01:00
|
|
|
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-06-27 00:25:01 +02:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 2);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-01-30 10:26:45 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
if (!event.isCancelled() && event.getDamage() != 0) {
|
2011-09-15 18:36:27 +02:00
|
|
|
this.damageEntity(DamageSource.DROWN, 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
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
this.extinguish();
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2012-01-12 12:02:39 +01:00
|
|
|
if (this.getAirTicks() != 300) { // CraftBukkit - only set if needed to work around a datawatcher inefficiency
|
2011-12-06 14:52:45 +01:00
|
|
|
this.setAirTicks(maxAirTicks);
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ax = this.ay;
|
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) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.an();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aH > 0) {
|
|
|
|
--this.aH;
|
2011-09-15 02:23:52 +02:00
|
|
|
} else {
|
2012-01-12 16:27:39 +01:00
|
|
|
this.killer = null;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aB();
|
|
|
|
this.ac = this.ab;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.W = this.V;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.Y = this.X;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastYaw = this.yaw;
|
|
|
|
this.lastPitch = this.pitch;
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a(); // CraftBukkit - not in production code
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 16:41:24 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
public int getExpReward() {
|
2012-01-12 23:10:13 +01:00
|
|
|
int exp = this.a(this.killer);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (!this.world.isStatic && (this.aH > 0 || this.ac()) && !this.l()) {
|
2011-09-21 16:41:24 +02:00
|
|
|
return exp;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void an() {
|
2011-11-20 09:01:14 +01:00
|
|
|
++this.deathTicks;
|
2011-12-12 18:50:10 +01:00
|
|
|
if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead).
|
2011-11-20 09:01:14 +01:00
|
|
|
int i;
|
|
|
|
|
2011-11-23 01:08:56 +01:00
|
|
|
// CraftBukkit start - update getExpReward() above if the removed if() changes!
|
2011-11-20 09:01:14 +01:00
|
|
|
i = expToDrop;
|
|
|
|
while (i > 0) {
|
|
|
|
int j = EntityExperienceOrb.b(i);
|
|
|
|
|
|
|
|
i -= j;
|
|
|
|
this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ay();
|
2011-11-20 09:01:14 +01:00
|
|
|
this.die();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int f(int i) {
|
|
|
|
return i - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int a(EntityHuman entityhuman) {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.aA;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean ac() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void ao() {
|
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-11-30 00:17:43 +01:00
|
|
|
this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void N() {
|
|
|
|
super.N();
|
|
|
|
this.Z = this.aa;
|
|
|
|
this.aa = 0.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.fallDistance = 0.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void y_() {
|
|
|
|
super.y_();
|
|
|
|
if (this.aJ > 0) {
|
|
|
|
if (this.aK <= 0) {
|
|
|
|
this.aK = 60;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
--this.aK;
|
|
|
|
if (this.aK <= 0) {
|
|
|
|
--this.aJ;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
this.d();
|
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-11-20 09:01:14 +01:00
|
|
|
float f1 = this.V;
|
2011-01-29 22:50:29 +01:00
|
|
|
float f2 = 0.0F;
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.Z = this.aa;
|
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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.ao > 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
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aa += (f3 - this.aa) * 0.3F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
float f4;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (f4 = f1 - this.V; 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-11-20 09:01:14 +01:00
|
|
|
this.V += f4 * 0.3F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
float f5;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (f5 = this.yaw - this.V; 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-11-20 09:01:14 +01:00
|
|
|
this.V = this.yaw - f5;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (f5 * f5 > 2500.0F) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.V += 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-11-20 09:01:14 +01:00
|
|
|
while (this.V - this.W < -180.0F) {
|
|
|
|
this.W -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
while (this.V - this.W >= 180.0F) {
|
|
|
|
this.W += 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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ab += 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-06-29 02:11:23 +02:00
|
|
|
// CraftBukkit start - delegate so we can handle providing a reason for health being regained
|
2011-11-20 09:01:14 +01:00
|
|
|
public void d(int i) {
|
|
|
|
d(i, RegainReason.CUSTOM);
|
2011-06-29 02:11:23 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void d(int i, RegainReason regainReason) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health > 0) {
|
2011-06-29 02:11:23 +02:00
|
|
|
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-06-17 22:50:56 +02:00
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.health += event.getAmount();
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
if (this.health > this.getMaxHealth()) {
|
|
|
|
this.health = this.getMaxHealth();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.noDamageTicks = this.maxNoDamageTicks / 2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public abstract int getMaxHealth();
|
|
|
|
|
|
|
|
public int getHealth() {
|
|
|
|
return this.health;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHealth(int i) {
|
|
|
|
this.health = i;
|
|
|
|
if (i > this.getMaxHealth()) {
|
|
|
|
i = this.getMaxHealth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, 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 {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aV = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health <= 0) {
|
|
|
|
return false;
|
2011-11-20 09:01:14 +01:00
|
|
|
} else if (damagesource.k() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
|
|
|
|
return false;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aE = 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-11-20 09:01:14 +01:00
|
|
|
this.c(damagesource, i - this.lastDamage);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastDamage = i;
|
|
|
|
flag = false;
|
|
|
|
} else {
|
|
|
|
this.lastDamage = i;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aq = this.health;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.noDamageTicks = this.maxNoDamageTicks;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.c(damagesource, i);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.hurtTicks = this.at = 10;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.au = 0.0F;
|
2011-09-15 18:36:27 +02:00
|
|
|
Entity entity = damagesource.getEntity();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
if (entity instanceof EntityHuman) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aH = 60;
|
2012-01-12 16:27:39 +01:00
|
|
|
this.killer = (EntityHuman) entity;
|
2011-09-15 02:23:52 +02:00
|
|
|
} else if (entity instanceof EntityWolf) {
|
|
|
|
EntityWolf entitywolf = (EntityWolf) entity;
|
|
|
|
|
|
|
|
if (entitywolf.isTamed()) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aH = 60;
|
2012-01-12 16:27:39 +01:00
|
|
|
this.killer = null;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (flag) {
|
|
|
|
this.world.a(this, (byte) 2);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aM();
|
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;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.au = (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 {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.au = (float) ((int) (Math.random() * 2.0D) * 180);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.health <= 0) {
|
|
|
|
if (flag) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.world.makeSound(this, this.n(), this.o(), this.v());
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
this.die(damagesource);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (flag) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.world.makeSound(this, this.m(), this.o(), this.v());
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
private float v() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.l() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public int P() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void g(int i) {}
|
|
|
|
|
|
|
|
protected int d(DamageSource damagesource, int i) {
|
|
|
|
if (!damagesource.ignoresArmor()) {
|
2012-01-12 23:10:13 +01:00
|
|
|
int j = 25 - this.P();
|
|
|
|
int k = i * j + this.ar;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
this.g(i);
|
|
|
|
i = k / 25;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ar = k % 25;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int b(DamageSource damagesource, int i) {
|
|
|
|
if (this.hasEffect(MobEffectList.RESISTANCE)) {
|
|
|
|
int j = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
|
|
|
|
int k = 25 - j;
|
2012-01-12 23:10:13 +01:00
|
|
|
int l = i * k + this.ar;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
i = l / 25;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ar = l % 25;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void c(DamageSource damagesource, int i) {
|
|
|
|
i = this.d(damagesource, i);
|
|
|
|
i = this.b(damagesource, i);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.health -= i;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected float o() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 1.0F;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String c_() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String m() {
|
|
|
|
return "damage.hurtflesh";
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String n() {
|
|
|
|
return "damage.hurtflesh";
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(Entity entity, int i, double d0, double d1) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ce = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
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;
|
2012-01-12 23:10:13 +01:00
|
|
|
this.motY += (double) f1;
|
2011-01-29 22:50:29 +01:00
|
|
|
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-09-15 02:23:52 +02:00
|
|
|
public void die(DamageSource damagesource) {
|
2011-09-15 18:36:27 +02:00
|
|
|
Entity entity = damagesource.getEntity();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aj >= 0 && entity != null) {
|
|
|
|
entity.b(this, this.aj);
|
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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.az = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!this.world.isStatic) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (entity instanceof EntityHuman) {
|
2011-11-30 00:17:43 +01:00
|
|
|
i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel(((EntityHuman) entity).inventory);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.l()) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.dropDeathLoot(this.aH > 0, i);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
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-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int j = this.e();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
|
|
|
// CraftBukkit start - whole method
|
2011-06-27 00:25:01 +02:00
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (j > 0) {
|
|
|
|
int k = this.random.nextInt(3);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (i > 0) {
|
|
|
|
k += this.random.nextInt(i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(j, k));
|
|
|
|
}
|
|
|
|
}
|
2011-12-02 11:31:31 +01:00
|
|
|
|
|
|
|
CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot
|
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected int e() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected void b(float f) {
|
|
|
|
super.b(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-06-27 00:25:01 +02:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FALL, i);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (!event.isCancelled() && event.getDamage() != 0) {
|
2011-11-20 09:01:14 +01:00
|
|
|
i = event.getDamage();
|
|
|
|
|
|
|
|
if (i > 4) {
|
|
|
|
this.world.makeSound(this, "damage.fallbig", 1.0F, 1.0F);
|
|
|
|
} else {
|
|
|
|
this.world.makeSound(this, "damage.fallsmall", 1.0F, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.damageEntity(DamageSource.FALL, i);
|
2011-01-20 09:10:47 +01:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
// CraftBukkit end
|
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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aK()) {
|
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-07-08 14:25:53 +02:00
|
|
|
if (this.positionChanged && this.d(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
|
|
|
}
|
2012-01-12 23:10:13 +01:00
|
|
|
} else if (this.aL()) {
|
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-07-08 14:25:53 +02:00
|
|
|
if (this.positionChanged && this.d(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);
|
2012-01-12 23:10:13 +01:00
|
|
|
float f4 = this.onGround ? this.al * f3 : this.am;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
this.a(f, f1, f4);
|
2011-01-29 22:50:29 +01:00
|
|
|
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-11-20 09:01:14 +01:00
|
|
|
if (this.r()) {
|
2011-09-15 02:23:52 +02:00
|
|
|
float f5 = 0.15F;
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.motX < (double) (-f5)) {
|
|
|
|
this.motX = (double) (-f5);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.motX > (double) f5) {
|
|
|
|
this.motX = (double) f5;
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.motZ < (double) (-f5)) {
|
|
|
|
this.motZ = (double) (-f5);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.motZ > (double) f5) {
|
|
|
|
this.motZ = (double) f5;
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
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-11-20 09:01:14 +01:00
|
|
|
if (this.positionChanged && this.r()) {
|
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
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aD = this.aE;
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
2011-09-15 02:23:52 +02:00
|
|
|
float f6 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (f6 > 1.0F) {
|
|
|
|
f6 = 1.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aE += (f6 - this.aE) * 0.4F;
|
|
|
|
this.aF += this.aE;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean r() {
|
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-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setShort("Health", (short) this.health);
|
|
|
|
nbttagcompound.setShort("HurtTime", (short) this.hurtTicks);
|
|
|
|
nbttagcompound.setShort("DeathTime", (short) this.deathTicks);
|
|
|
|
nbttagcompound.setShort("AttackTime", (short) this.attackTicks);
|
2011-09-24 23:03:31 +02:00
|
|
|
if (!this.effects.isEmpty()) {
|
2011-09-15 02:23:52 +02:00
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
2011-09-24 23:03:31 +02:00
|
|
|
Iterator iterator = this.effects.values().iterator();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
MobEffect mobeffect = (MobEffect) iterator.next();
|
|
|
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound1.setByte("Id", (byte) mobeffect.getEffectId());
|
|
|
|
nbttagcompound1.setByte("Amplifier", (byte) mobeffect.getAmplifier());
|
|
|
|
nbttagcompound1.setInt("Duration", mobeffect.getDuration());
|
|
|
|
nbttaglist.add(nbttagcompound1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.set("ActiveEffects", nbttaglist);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.health = nbttagcompound.getShort("Health");
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!nbttagcompound.hasKey("Health")) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.health = this.getMaxHealth();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
this.hurtTicks = nbttagcompound.getShort("HurtTime");
|
|
|
|
this.deathTicks = nbttagcompound.getShort("DeathTime");
|
|
|
|
this.attackTicks = nbttagcompound.getShort("AttackTime");
|
2011-09-15 02:23:52 +02:00
|
|
|
if (nbttagcompound.hasKey("ActiveEffects")) {
|
2011-11-30 00:17:43 +01:00
|
|
|
NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects");
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
for (int i = 0; i < nbttaglist.size(); ++i) {
|
|
|
|
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i);
|
|
|
|
byte b0 = nbttagcompound1.getByte("Id");
|
|
|
|
byte b1 = nbttagcompound1.getByte("Amplifier");
|
|
|
|
int j = nbttagcompound1.getInt("Duration");
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
this.effects.put(Integer.valueOf(b0), new MobEffect(b0, j, b1));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public boolean isAlive() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead && this.health > 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean f() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void d(float f) {
|
|
|
|
this.aX = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e(boolean flag) {
|
|
|
|
this.aZ = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float ar() {
|
|
|
|
return this.bb;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void d() {
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.h > 0) {
|
|
|
|
--this.h;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aN > 0) {
|
|
|
|
double d0 = this.locX + (this.aO - this.locX) / (double) this.aN;
|
|
|
|
double d1 = this.locY + (this.aP - this.locY) / (double) this.aN;
|
|
|
|
double d2 = this.locZ + (this.aQ - this.locZ) / (double) this.aN;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
double d3;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
for (d3 = this.aR - (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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.yaw = (float) ((double) this.yaw + d3 / (double) this.aN);
|
|
|
|
this.pitch = (float) ((double) this.pitch + (this.aS - (double) this.pitch) / (double) this.aN);
|
|
|
|
--this.aN;
|
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);
|
2012-01-12 23:10:13 +01:00
|
|
|
List list = this.world.a((Entity) this, this.boundingBox.shrink(0.03125D, 0.0D, 0.03125D));
|
2011-05-28 22:50:08 +02:00
|
|
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
double d4 = 0.0D;
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
AxisAlignedBB axisalignedbb = (AxisAlignedBB) list.get(i);
|
|
|
|
|
|
|
|
if (axisalignedbb.e > d4) {
|
|
|
|
d4 = axisalignedbb.e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d1 += d4 - this.boundingBox.b;
|
|
|
|
this.setPosition(d0, d1, d2);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a("ai"); // CraftBukkit - not in production code
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.M()) {
|
|
|
|
this.aZ = false;
|
|
|
|
this.aW = 0.0F;
|
|
|
|
this.aX = 0.0F;
|
|
|
|
this.aY = 0.0F;
|
|
|
|
} else if (this.at()) {
|
|
|
|
if (this.as()) {
|
|
|
|
this.av();
|
|
|
|
} else {
|
|
|
|
this.m_();
|
|
|
|
this.X = this.yaw;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a(); // CraftBukkit - not in production code
|
2012-01-12 23:10:13 +01:00
|
|
|
boolean flag = this.aK();
|
|
|
|
boolean flag1 = this.aL();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aZ) {
|
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;
|
2012-01-12 23:10:13 +01:00
|
|
|
} else if (this.onGround && this.h == 0) {
|
|
|
|
this.o_();
|
|
|
|
this.h = 10;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.h = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aW *= 0.98F;
|
|
|
|
this.aX *= 0.98F;
|
|
|
|
this.aY *= 0.9F;
|
|
|
|
float f = this.al;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.al *= this.G();
|
|
|
|
this.a(this.aW, this.aX);
|
|
|
|
this.al = f;
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a("push"); // CraftBukkit - not in production code
|
2012-01-12 16:27:39 +01:00
|
|
|
List list1 = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (list1 != null && list1.size() > 0) {
|
|
|
|
for (int j = 0; j < list1.size(); ++j) {
|
|
|
|
Entity entity = (Entity) list1.get(j);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (entity.f_()) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.collide(this);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// MethodProfiler.a(); // CraftBukkit - not in production code
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected boolean as() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean at() {
|
|
|
|
return !this.world.isStatic;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean M() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.health <= 0;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public boolean L() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void o_() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.41999998688697815D;
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.hasEffect(MobEffectList.JUMP)) {
|
|
|
|
this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F);
|
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.isSprinting()) {
|
2011-09-15 02:23:52 +02:00
|
|
|
float f = this.yaw * 0.017453292F;
|
|
|
|
|
|
|
|
this.motX -= (double) (MathHelper.sin(f) * 0.2F);
|
|
|
|
this.motZ += (double) (MathHelper.cos(f) * 0.2F);
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.ce = true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected boolean d_() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void au() {
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (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-11-20 09:01:14 +01:00
|
|
|
if (this.d_() && 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
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.aV > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.d_()) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.die();
|
|
|
|
} else if (d3 < 1024.0D) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aV = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void av() {
|
|
|
|
++this.aV;
|
|
|
|
this.au();
|
|
|
|
if (this.aI != null && !this.aI.isAlive()) {
|
|
|
|
this.aI = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.goalSelector.a();
|
|
|
|
this.navigation.a();
|
|
|
|
this.moveController.a();
|
|
|
|
this.lookController.a();
|
|
|
|
this.jumpController.b();
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected void m_() {
|
2012-01-12 23:10:13 +01:00
|
|
|
++this.aV;
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.au();
|
|
|
|
this.aW = 0.0F;
|
|
|
|
this.aX = 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) {
|
2011-06-27 00:25:01 +02:00
|
|
|
entityhuman = this.world.findNearbyPlayer(this, (double) f);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityhuman != null) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.i = entityhuman;
|
|
|
|
this.bc = 10 + this.random.nextInt(20);
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aY = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.i != null) {
|
|
|
|
this.a(this.i, 10.0F, (float) this.x());
|
|
|
|
if (this.bc-- <= 0 || this.i.dead || this.i.i(this) > (double) (f * f)) {
|
|
|
|
this.i = null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextFloat() < 0.05F) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aY = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
this.yaw += this.aY;
|
|
|
|
this.pitch = this.ba;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
boolean flag = this.aK();
|
|
|
|
boolean flag1 = this.aL();
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
if (flag || flag1) {
|
2012-01-12 23:10:13 +01:00
|
|
|
this.aZ = this.random.nextFloat() < 0.8F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public int x() {
|
2011-04-20 22:47:26 +02:00
|
|
|
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;
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
d2 = this.locY + (double) this.y() - (entityliving.locY + (double) entityliving.y());
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2012-01-12 23:10:13 +01:00
|
|
|
d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.y());
|
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);
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public boolean aw() {
|
|
|
|
return this.i != null;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public Entity ax() {
|
|
|
|
return this.i;
|
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
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void ay() {}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean g() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.world.containsEntity(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void az() {
|
2011-03-17 18:24:36 +01:00
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.VOID, 4);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-03-17 18:24:36 +01:00
|
|
|
|
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-09-15 18:36:27 +02:00
|
|
|
this.damageEntity(DamageSource.OUT_OF_WORLD, event.getDamage());
|
2011-03-17 18:24:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public Vec3D aA() {
|
|
|
|
return this.e(1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public Vec3D e(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-11-20 09:01:14 +01:00
|
|
|
public int p() {
|
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-09-15 02:23:52 +02:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected void aB() {
|
2011-09-24 23:03:31 +02:00
|
|
|
Iterator iterator = this.effects.keySet().iterator();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Integer integer = (Integer) iterator.next();
|
2011-09-24 23:03:31 +02:00
|
|
|
MobEffect mobeffect = (MobEffect) this.effects.get(integer);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (!mobeffect.tick(this) && !this.world.isStatic) {
|
2011-09-15 02:23:52 +02:00
|
|
|
iterator.remove();
|
2011-11-20 09:01:14 +01:00
|
|
|
this.d(mobeffect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (this.b) {
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
if (!this.effects.isEmpty()) {
|
|
|
|
i = PotionBrewer.a(this.effects.values());
|
|
|
|
this.datawatcher.watch(8, Integer.valueOf(i));
|
|
|
|
} else {
|
|
|
|
this.datawatcher.watch(8, Integer.valueOf(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.b = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.random.nextBoolean()) {
|
|
|
|
i = this.datawatcher.getInt(8);
|
|
|
|
if (i > 0) {
|
|
|
|
double d0 = (double) (i >> 16 & 255) / 255.0D;
|
|
|
|
double d1 = (double) (i >> 8 & 255) / 255.0D;
|
|
|
|
double d2 = (double) (i >> 0 & 255) / 255.0D;
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
this.world.a("mobSpell", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public void aC() {
|
2011-11-20 09:01:14 +01:00
|
|
|
Iterator iterator = this.effects.keySet().iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Integer integer = (Integer) iterator.next();
|
|
|
|
MobEffect mobeffect = (MobEffect) this.effects.get(integer);
|
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
iterator.remove();
|
|
|
|
this.d(mobeffect);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public Collection getEffects() {
|
|
|
|
return this.effects.values();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public boolean hasEffect(MobEffectList mobeffectlist) {
|
|
|
|
return this.effects.containsKey(Integer.valueOf(mobeffectlist.id));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public MobEffect getEffect(MobEffectList mobeffectlist) {
|
|
|
|
return (MobEffect) this.effects.get(Integer.valueOf(mobeffectlist.id));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void addEffect(MobEffect mobeffect) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.a(mobeffect)) {
|
|
|
|
if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) {
|
|
|
|
((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect);
|
|
|
|
this.c((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId())));
|
|
|
|
} else {
|
|
|
|
this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
|
|
|
|
this.b(mobeffect);
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public boolean a(MobEffect mobeffect) {
|
2011-11-30 00:17:43 +01:00
|
|
|
if (this.getMonsterType() == MonsterType.UNDEAD) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int i = mobeffect.getEffectId();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (i == MobEffectList.REGENERATION.id || i == MobEffectList.POISON.id) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public boolean aE() {
|
2011-11-30 00:17:43 +01:00
|
|
|
return this.getMonsterType() == MonsterType.UNDEAD;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void b(MobEffect mobeffect) {
|
|
|
|
this.b = true;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected void c(MobEffect mobeffect) {
|
|
|
|
this.b = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void d(MobEffect mobeffect) {
|
|
|
|
this.b = true;
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
protected float G() {
|
2011-09-15 02:23:52 +02:00
|
|
|
float f = 1.0F;
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.hasEffect(MobEffectList.FASTER_MOVEMENT)) {
|
|
|
|
f *= 1.0F + 0.2F * (float) (this.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier() + 1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.hasEffect(MobEffectList.SLOWER_MOVEMENT)) {
|
|
|
|
f *= 1.0F - 0.15F * (float) (this.getEffect(MobEffectList.SLOWER_MOVEMENT).getAmplifier() + 1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
public void a_(double d0, double d1, double d2) {
|
|
|
|
this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean l() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public MonsterType getMonsterType() {
|
|
|
|
return MonsterType.UNDEFINED;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void c(ItemStack itemstack) {
|
|
|
|
this.world.makeSound(this, "random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F);
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
Vec3D vec3d = Vec3D.create(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
|
|
|
|
|
|
|
|
vec3d.a(-this.pitch * 3.1415927F / 180.0F);
|
|
|
|
vec3d.b(-this.yaw * 3.1415927F / 180.0F);
|
|
|
|
Vec3D vec3d1 = Vec3D.create(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D);
|
|
|
|
|
|
|
|
vec3d1.a(-this.pitch * 3.1415927F / 180.0F);
|
|
|
|
vec3d1.b(-this.yaw * 3.1415927F / 180.0F);
|
2012-01-12 23:10:13 +01:00
|
|
|
vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.y(), this.locZ);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.world.a("iconcrack_" + itemstack.getItem().id, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c);
|
|
|
|
}
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|