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-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-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 {
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private static final float[] b = new float[] { 0.0F, 0.0F, 0.1F, 0.2F};
|
|
|
|
private static final float[] c = new float[] { 0.0F, 0.0F, 0.25F, 0.5F};
|
2012-12-20 05:03:52 +01:00
|
|
|
private static final float[] d = new float[] { 0.0F, 0.0F, 0.05F, 0.02F};
|
2013-03-13 23:33:27 +01:00
|
|
|
public static final float[] au = new float[] { 0.0F, 0.1F, 0.15F, 0.45F};
|
2011-01-29 22:50:29 +01:00
|
|
|
public int maxNoDamageTicks = 20;
|
2012-12-20 05:03:52 +01:00
|
|
|
public float aw;
|
2013-03-13 23:33:27 +01:00
|
|
|
public float ax;
|
2012-10-25 05:53:23 +02:00
|
|
|
public float ay = 0.0F;
|
|
|
|
public float az = 0.0F;
|
2012-12-20 05:03:52 +01:00
|
|
|
public float aA = 0.0F;
|
2013-03-13 23:33:27 +01:00
|
|
|
public float aB = 0.0F;
|
2012-10-25 05:53:23 +02:00
|
|
|
protected float aC;
|
|
|
|
protected float aD;
|
2012-12-20 05:03:52 +01:00
|
|
|
protected float aE;
|
2013-03-13 23:33:27 +01:00
|
|
|
protected float aF;
|
|
|
|
protected boolean aG = true;
|
2012-07-29 09:33:13 +02:00
|
|
|
protected String texture = "/mob/char.png";
|
2013-03-13 23:33:27 +01:00
|
|
|
protected boolean aI = true;
|
|
|
|
protected float aJ = 0.0F;
|
|
|
|
protected String aK = null;
|
|
|
|
protected float aL = 1.0F;
|
|
|
|
protected int aM = 0;
|
|
|
|
protected float aN = 0.0F;
|
|
|
|
public float aO = 0.1F;
|
|
|
|
public float aP = 0.02F;
|
2012-12-20 05:03:52 +01:00
|
|
|
public float aQ;
|
2013-03-13 23:33:27 +01:00
|
|
|
public float aR;
|
2011-11-20 09:01:14 +01:00
|
|
|
protected int health = this.getMaxHealth();
|
2013-03-13 23:33:27 +01:00
|
|
|
public int aT;
|
|
|
|
protected int aU;
|
|
|
|
public int aV;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int hurtTicks;
|
2013-03-13 23:33:27 +01:00
|
|
|
public int aX;
|
|
|
|
public float aY = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
public int deathTicks = 0;
|
|
|
|
public int attackTicks = 0;
|
2012-12-20 05:03:52 +01:00
|
|
|
public float bb;
|
2013-03-13 23:33:27 +01:00
|
|
|
public float bc;
|
|
|
|
protected boolean bd = false;
|
|
|
|
protected int be;
|
|
|
|
public int bf = -1;
|
|
|
|
public float bg = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D);
|
2012-10-25 05:53:23 +02:00
|
|
|
public float bh;
|
2012-12-20 05:03:52 +01:00
|
|
|
public float bi;
|
2013-03-13 23:33:27 +01:00
|
|
|
public float bj;
|
2012-07-29 09:33:13 +02:00
|
|
|
public EntityHuman killer = null; // CraftBukkit - protected -> public
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int lastDamageByPlayerTime = 0;
|
2012-07-29 09:33:13 +02:00
|
|
|
public EntityLiving lastDamager = null; // CraftBukkit - private -> public
|
2012-10-25 05:53:23 +02:00
|
|
|
private int f = 0;
|
|
|
|
private EntityLiving g = null;
|
2013-03-13 23:33:27 +01:00
|
|
|
public int bm = 0;
|
2012-01-09 08:51:32 +01:00
|
|
|
public HashMap effects = new HashMap(); // CraftBukkit - protected -> public
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean updateEffects = true; // CraftBukkit - private -> public
|
2012-10-25 05:53:23 +02:00
|
|
|
private int i;
|
2012-01-12 23:10:13 +01:00
|
|
|
private ControllerLook lookController;
|
|
|
|
private ControllerMove moveController;
|
|
|
|
private ControllerJump jumpController;
|
2012-03-01 11:49:23 +01:00
|
|
|
private EntityAIBodyControl senses;
|
2012-01-12 23:10:13 +01:00
|
|
|
private Navigation navigation;
|
2012-07-29 09:33:13 +02:00
|
|
|
protected final PathfinderGoalSelector goalSelector;
|
|
|
|
protected final PathfinderGoalSelector targetSelector;
|
2013-01-17 10:28:44 +01:00
|
|
|
private EntityLiving goalTarget;
|
2013-03-13 23:33:27 +01:00
|
|
|
private EntitySenses bP;
|
|
|
|
private float bQ;
|
|
|
|
private ChunkCoordinates bR = new ChunkCoordinates(0, 0, 0);
|
|
|
|
private float bS = -1.0F;
|
2012-10-25 05:53:23 +02:00
|
|
|
private ItemStack[] equipment = new ItemStack[5];
|
2012-12-09 07:09:48 +01:00
|
|
|
public float[] dropChances = new float[5]; // CraftBukkit - protected -> public
|
2013-03-13 23:33:27 +01:00
|
|
|
private ItemStack[] bU = new ItemStack[5];
|
|
|
|
public boolean br = false;
|
|
|
|
public int bs = 0;
|
2012-12-09 07:09:48 +01:00
|
|
|
public boolean canPickUpLoot = false; // CraftBukkit - protected -> public
|
2013-01-17 10:28:44 +01:00
|
|
|
public boolean persistent = !this.isTypeNotPersistent(); // CraftBukkit - private -> public, change value
|
2013-03-13 23:33:27 +01:00
|
|
|
protected final CombatTracker bt = new CombatTracker(this);
|
|
|
|
protected int bu;
|
2012-10-25 05:53:23 +02:00
|
|
|
protected double bv;
|
|
|
|
protected double bw;
|
|
|
|
protected double bx;
|
2012-12-20 05:03:52 +01:00
|
|
|
protected double by;
|
2013-03-13 23:33:27 +01:00
|
|
|
protected double bz;
|
|
|
|
float bA = 0.0F;
|
2011-05-14 16:29:42 +02:00
|
|
|
public int lastDamage = 0; // CraftBukkit - protected -> public
|
2013-03-13 23:33:27 +01:00
|
|
|
protected int bC = 0;
|
2012-10-25 05:53:23 +02:00
|
|
|
protected float bD;
|
2012-12-20 05:03:52 +01:00
|
|
|
protected float bE;
|
2013-03-13 23:33:27 +01:00
|
|
|
protected float bF;
|
|
|
|
protected boolean bG = false;
|
|
|
|
protected float bH = 0.0F;
|
|
|
|
protected float bI = 0.7F;
|
|
|
|
private int bX = 0;
|
|
|
|
private Entity bY;
|
|
|
|
protected int bJ = 0;
|
2012-12-23 12:49:03 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
public int expToDrop = 0;
|
|
|
|
public int maxAirTicks = 300;
|
|
|
|
public int maxHealth = this.getMaxHealth();
|
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
public EntityLiving(World world) {
|
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.m = true;
|
|
|
|
this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
|
|
|
|
this.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.lookController = new ControllerLook(this);
|
2012-03-01 11:49:23 +01:00
|
|
|
this.moveController = new ControllerMove(this);
|
2012-01-12 23:10:13 +01:00
|
|
|
this.jumpController = new ControllerJump(this);
|
2012-03-01 11:49:23 +01:00
|
|
|
this.senses = new EntityAIBodyControl(this);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.navigation = new Navigation(this, world, (float) this.ay());
|
|
|
|
this.bP = new EntitySenses(this);
|
|
|
|
this.ax = (float) (Math.random() + 1.0D) * 0.01F;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aw = (float) Math.random() * 12398.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aA = this.yaw;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < this.dropChances.length; ++i) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.dropChances[i] = 0.085F;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.Y = 0.5F;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int ay() {
|
|
|
|
return 16;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerLook getControllerLook() {
|
|
|
|
return this.lookController;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerMove getControllerMove() {
|
|
|
|
return this.moveController;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ControllerJump getControllerJump() {
|
|
|
|
return this.jumpController;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public Navigation getNavigation() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.navigation;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public EntitySenses aD() {
|
|
|
|
return this.bP;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public Random aE() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return this.random;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public EntityLiving aF() {
|
2012-01-14 21:03:48 +01:00
|
|
|
return this.lastDamager;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public EntityLiving aG() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.g;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public void l(Entity entity) {
|
2012-03-01 11:49:23 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.g = (EntityLiving) entity;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int aH() {
|
|
|
|
return this.bC;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float ao() {
|
|
|
|
return this.aA;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float aI() {
|
|
|
|
return this.bQ;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void e(float f) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bQ = f;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.f(f);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean m(Entity entity) {
|
|
|
|
this.l(entity);
|
2012-03-01 11:49:23 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-17 10:28:44 +01:00
|
|
|
public EntityLiving getGoalTarget() {
|
|
|
|
return this.goalTarget;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-01-17 10:28:44 +01:00
|
|
|
public void setGoalTarget(EntityLiving entityliving) {
|
|
|
|
this.goalTarget = entityliving;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(Class oclass) {
|
|
|
|
return EntityCreeper.class != oclass && EntityGhast.class != oclass;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void aK() {}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
protected void a(double d0, boolean flag) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!this.G()) {
|
|
|
|
this.H();
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (flag && this.fallDistance > 0.0F) {
|
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
int l = this.world.getTypeId(i, j, k);
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 0) {
|
|
|
|
int i1 = this.world.e(i, j - 1, k);
|
|
|
|
|
|
|
|
if (i1 == 11 || i1 == 32 || i1 == 21) {
|
|
|
|
l = this.world.getTypeId(i, j - 1, k);
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l > 0) {
|
|
|
|
Block.byId[l].a(this.world, i, j, k, this, this.fallDistance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.a(d0, flag);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean aL() {
|
|
|
|
return this.d(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean d(int i, int j, int k) {
|
|
|
|
return this.bS == -1.0F ? true : this.bR.e(i, j, k) < this.bS * this.bS;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(int i, int j, int k, int l) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bR.b(i, j, k);
|
|
|
|
this.bS = (float) l;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public ChunkCoordinates aM() {
|
|
|
|
return this.bR;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float aN() {
|
|
|
|
return this.bS;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void aO() {
|
|
|
|
this.bS = -1.0F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean aP() {
|
|
|
|
return this.bS != -1.0F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void c(EntityLiving entityliving) {
|
2012-03-01 11:49:23 +01:00
|
|
|
this.lastDamager = entityliving;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.f = this.lastDamager != null ? 100 : 0;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.datawatcher.a(8, Integer.valueOf(this.i));
|
|
|
|
this.datawatcher.a(9, Byte.valueOf((byte) 0));
|
2012-11-06 13:05:28 +01:00
|
|
|
this.datawatcher.a(10, Byte.valueOf((byte) 0));
|
2013-03-13 23:33:27 +01:00
|
|
|
this.datawatcher.a(6, Byte.valueOf((byte) 0));
|
|
|
|
this.datawatcher.a(5, "");
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean n(Entity entity) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.world.a(this.world.getVec3DPool().create(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), this.world.getVec3DPool().create(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean K() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean L() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return !this.dead;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public float getHeadHeight() {
|
2011-11-30 00:17:43 +01:00
|
|
|
return this.length * 0.85F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int aQ() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void aR() {
|
|
|
|
String s = this.bb();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
if (s != null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.makeSound(s, this.ba(), this.aY());
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void x() {
|
|
|
|
this.aQ = this.aR;
|
|
|
|
super.x();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("mobBaseTick");
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.isAlive() && this.random.nextInt(1000) < this.aV++) {
|
|
|
|
this.aV = -this.aQ();
|
|
|
|
this.aR();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start
|
2012-02-08 20:26:45 +01:00
|
|
|
if (this.isAlive() && this.inBlock() && !(this instanceof EntityEnderDragon)) { // EnderDragon's don't suffocate.
|
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()) {
|
2012-07-01 12:04:06 +02:00
|
|
|
event.getEntity().setLastDamageCause(event);
|
2011-09-15 18:36:27 +02:00
|
|
|
this.damageEntity(DamageSource.STUCK, event.getDamage());
|
2011-01-20 09:49:35 +01:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
// CraftBukkit end
|
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
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
boolean flag = this instanceof EntityHuman && ((EntityHuman) this).abilities.isInvulnerable;
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.isAlive() && this.a(Material.WATER) && !this.bf() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id)) && !flag) {
|
|
|
|
this.setAirTicks(this.h(this.getAirTicks()));
|
2011-11-20 09:01:14 +01:00
|
|
|
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();
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle("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) {
|
2012-07-01 12:04:06 +02:00
|
|
|
event.getEntity().setLastDamageCause(event);
|
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-02-10 06:43:12 +01:00
|
|
|
// CraftBukkit start - only set if needed to work around a datawatcher inefficiency
|
|
|
|
if (this.getAirTicks() != 300) {
|
2011-12-06 14:52:45 +01:00
|
|
|
this.setAirTicks(maxAirTicks);
|
|
|
|
}
|
2012-02-10 06:43:12 +01:00
|
|
|
// CraftBukkit end
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bb = this.bc;
|
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) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aS();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (this.lastDamageByPlayerTime > 0) {
|
|
|
|
--this.lastDamageByPlayerTime;
|
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-10-25 05:53:23 +02:00
|
|
|
if (this.g != null && !this.g.isAlive()) {
|
|
|
|
this.g = null;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.lastDamager != null) {
|
|
|
|
if (!this.lastDamager.isAlive()) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c((EntityLiving) null);
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.f > 0) {
|
|
|
|
--this.f;
|
2012-03-01 11:49:23 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c((EntityLiving) null);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bA();
|
|
|
|
this.aF = this.aE;
|
|
|
|
this.az = this.ay;
|
|
|
|
this.aB = this.aA;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastYaw = this.yaw;
|
|
|
|
this.lastPitch = this.pitch;
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 16:41:24 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
public int getExpReward() {
|
2012-01-14 21:03:48 +01:00
|
|
|
int exp = this.getExpValue(this.killer);
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (!this.world.isStatic && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && !this.isBaby()) {
|
2011-09-21 16:41:24 +02:00
|
|
|
return exp;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2012-12-23 12:49:03 +01:00
|
|
|
|
|
|
|
public int getScaledHealth() {
|
|
|
|
if (this.maxHealth != this.getMaxHealth() && this.getHealth() > 0) {
|
|
|
|
return this.getHealth() * this.getMaxHealth() / this.maxHealth + 1;
|
|
|
|
} else {
|
|
|
|
return this.getHealth();
|
|
|
|
}
|
|
|
|
}
|
2011-09-21 16:41:24 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void aS() {
|
2011-11-20 09:01:14 +01:00
|
|
|
++this.deathTicks;
|
2012-07-29 09:33:13 +02: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!
|
2012-11-06 13:05:28 +01:00
|
|
|
i = this.expToDrop;
|
2011-11-20 09:01:14 +01:00
|
|
|
while (i > 0) {
|
2012-01-14 21:03:48 +01:00
|
|
|
int j = EntityExperienceOrb.getOrbValue(i);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
i -= j;
|
|
|
|
this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
this.expToDrop = 0;
|
2011-11-20 09:01:14 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle("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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected int h(int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
int j = EnchantmentManager.getOxygenEnchantmentLevel(this);
|
|
|
|
|
|
|
|
return j > 0 && this.random.nextInt(j + 1) > 0 ? i : i - 1;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getExpValue(EntityHuman entityhuman) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.be > 0) {
|
|
|
|
int i = this.be;
|
2012-12-20 05:03:52 +01:00
|
|
|
ItemStack[] aitemstack = this.getEquipment();
|
|
|
|
|
|
|
|
for (int j = 0; j < aitemstack.length; ++j) {
|
|
|
|
if (aitemstack[j] != null && this.dropChances[j] <= 1.0F) {
|
|
|
|
i += 1 + this.random.nextInt(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.be;
|
2012-12-20 05:03:52 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected boolean alwaysGivesExp() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void aU() {
|
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
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle("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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void T() {
|
|
|
|
super.T();
|
|
|
|
this.aC = this.aD;
|
|
|
|
this.aD = 0.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.fallDistance = 0.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void l_() {
|
|
|
|
super.l_();
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!this.world.isStatic) {
|
2012-11-06 13:05:28 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 5; ++i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
ItemStack itemstack = this.getEquipment(i);
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!ItemStack.matches(itemstack, this.bU[i])) {
|
2012-11-06 13:05:28 +01:00
|
|
|
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new Packet5EntityEquipment(this.id, i, itemstack)));
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bU[i] = itemstack == null ? null : itemstack.cloneItemStack();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
i = this.bM();
|
2012-11-06 13:05:28 +01:00
|
|
|
if (i > 0) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bm <= 0) {
|
|
|
|
this.bm = 20 * (30 - i);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
--this.bm;
|
|
|
|
if (this.bm <= 0) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.r(i - 1);
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.c();
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
2012-07-29 09:33:13 +02:00
|
|
|
float f = (float) (d0 * d0 + d1 * d1);
|
2013-03-13 23:33:27 +01:00
|
|
|
float f1 = this.ay;
|
2011-01-29 22:50:29 +01:00
|
|
|
float f2 = 0.0F;
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aC = this.aD;
|
2011-01-17 04:03:19 +01:00
|
|
|
float f3 = 0.0F;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (f > 0.0025000002F) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f3 = 1.0F;
|
2012-07-29 09:33:13 +02:00
|
|
|
f2 = (float) Math.sqrt((double) f) * 3.0F;
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - Math -> TrigMath
|
2012-07-22 08:18:00 +02:00
|
|
|
f1 = (float) org.bukkit.craftbukkit.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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.aR > 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
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aD += (f3 - this.aD) * 0.3F;
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("headTurn");
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bh()) {
|
2012-03-01 11:49:23 +01:00
|
|
|
this.senses.a();
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
float f4 = MathHelper.g(f1 - this.ay);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.ay += f4 * 0.3F;
|
|
|
|
float f5 = MathHelper.g(this.yaw - this.ay);
|
2012-03-01 11:49:23 +01:00
|
|
|
boolean flag = f5 < -90.0F || f5 >= 90.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if (f5 < -75.0F) {
|
|
|
|
f5 = -75.0F;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if (f5 >= 75.0F) {
|
|
|
|
f5 = 75.0F;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.ay = this.yaw - f5;
|
2012-03-01 11:49:23 +01:00
|
|
|
if (f5 * f5 > 2500.0F) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.ay += f5 * 0.2F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if (flag) {
|
|
|
|
f2 *= -1.0F;
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("rangeChecks");
|
2012-07-29 09:33:13 +02: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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
while (this.ay - this.az < -180.0F) {
|
|
|
|
this.az -= 360.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
while (this.ay - this.az >= 180.0F) {
|
|
|
|
this.az += 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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
while (this.aA - this.aB < -180.0F) {
|
|
|
|
this.aB -= 360.0F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
while (this.aA - this.aB >= 180.0F) {
|
|
|
|
this.aB += 360.0F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aE += f2;
|
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
|
2012-01-14 21:03:48 +01:00
|
|
|
public void heal(int i) {
|
2012-07-22 08:18:00 +02:00
|
|
|
heal(i, EntityRegainHealthEvent.RegainReason.CUSTOM);
|
2011-06-29 02:11:23 +02:00
|
|
|
}
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
public void heal(int i, EntityRegainHealthEvent.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()) {
|
2013-03-16 14:57:57 +01:00
|
|
|
this.setHealth(this.getHealth() + event.getAmount());
|
2011-06-17 22:50:56 +02:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-12-23 12:49:03 +01:00
|
|
|
// this.getMaxHealth() -> this.maxHealth
|
|
|
|
if (this.health > this.maxHealth) {
|
2013-03-16 14:57:57 +01:00
|
|
|
this.setHealth(this.maxHealth);
|
2012-12-23 12:49:03 +01:00
|
|
|
// CraftBukkit end
|
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) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isInvulnerable()) {
|
|
|
|
return false;
|
|
|
|
} else if (this.world.isStatic) {
|
2011-01-17 04:03:19 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bC = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health <= 0) {
|
|
|
|
return false;
|
2013-03-13 23:33:27 +01:00
|
|
|
} else if (damagesource.m() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
return false;
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
|
2012-12-20 05:03:52 +01:00
|
|
|
this.getEquipment(4).damage(i * 4 + this.random.nextInt(i * 2), this);
|
|
|
|
i = (int) ((float) i * 0.75F);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bi = 1.5F;
|
2011-01-29 22:50:29 +01:00
|
|
|
boolean flag = true;
|
|
|
|
|
2012-03-12 23:55:02 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (damagesource instanceof EntityDamageSource) {
|
2012-07-22 08:18:00 +02:00
|
|
|
EntityDamageEvent event = CraftEventFactory.handleEntityDamageEvent(this, damagesource, i);
|
2012-03-12 23:55:02 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
i = event.getDamage();
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
|
|
|
|
if (i <= this.lastDamage) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.d(damagesource, i - this.lastDamage);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.lastDamage = i;
|
|
|
|
flag = false;
|
|
|
|
} else {
|
|
|
|
this.lastDamage = i;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aT = this.health;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.noDamageTicks = this.maxNoDamageTicks;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.d(damagesource, i);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.hurtTicks = this.aX = 10;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aY = 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) {
|
2012-03-01 11:49:23 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c((EntityLiving) entity);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (entity instanceof EntityHuman) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.lastDamageByPlayerTime = 100;
|
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()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.lastDamageByPlayerTime = 100;
|
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) {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 2);
|
2013-03-13 23:33:27 +01:00
|
|
|
if (damagesource != DamageSource.DROWN) {
|
|
|
|
this.J();
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aY = (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 {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aY = (float) ((int) (Math.random() * 2.0D) * 180);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.health <= 0) {
|
|
|
|
if (flag) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.makeSound(this.bd(), this.ba(), this.aY());
|
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) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.makeSound(this.bc(), this.ba(), this.aY());
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected float aY() {
|
2012-01-14 21:03:48 +01:00
|
|
|
return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int aZ() {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = 0;
|
|
|
|
ItemStack[] aitemstack = this.getEquipment();
|
|
|
|
int j = aitemstack.length;
|
|
|
|
|
|
|
|
for (int k = 0; k < j; ++k) {
|
|
|
|
ItemStack itemstack = aitemstack[k];
|
|
|
|
|
|
|
|
if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
|
2013-03-13 23:33:27 +01:00
|
|
|
int l = ((ItemArmor) itemstack.getItem()).c;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
i += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void k(int i) {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected int b(DamageSource damagesource, int i) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!damagesource.ignoresArmor()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
int j = 25 - this.aZ();
|
|
|
|
int k = i * j + this.aU;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.k(i);
|
2011-11-20 09:01:14 +01:00
|
|
|
i = k / 25;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aU = k % 25;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected int c(DamageSource damagesource, int i) {
|
2013-03-13 23:33:27 +01:00
|
|
|
int j;
|
|
|
|
int k;
|
|
|
|
int l;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.hasEffect(MobEffectList.RESISTANCE)) {
|
|
|
|
j = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
|
|
|
|
k = 25 - j;
|
|
|
|
l = i * k + this.aU;
|
2011-11-20 09:01:14 +01:00
|
|
|
i = l / 25;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aU = l % 25;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (i <= 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
j = EnchantmentManager.a(this.getEquipment(), damagesource);
|
|
|
|
if (j > 20) {
|
|
|
|
j = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j > 0 && j <= 20) {
|
|
|
|
k = 25 - j;
|
|
|
|
l = i * k + this.aU;
|
|
|
|
i = l / 25;
|
|
|
|
this.aU = l % 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void d(DamageSource damagesource, int i) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!this.isInvulnerable()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
i = this.b(damagesource, i);
|
|
|
|
i = this.c(damagesource, i);
|
2013-03-13 23:33:27 +01:00
|
|
|
int j = this.getHealth();
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.health -= i;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bt.a(damagesource, j, i);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected float ba() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 1.0F;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bb() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bc() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "damage.hit";
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bd() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "damage.hit";
|
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) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.an = true;
|
2012-01-14 21:03:48 +01:00
|
|
|
float f = MathHelper.sqrt(d0 * d0 + d1 * d1);
|
2011-01-29 22:50:29 +01:00
|
|
|
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();
|
2013-03-13 23:33:27 +01:00
|
|
|
EntityLiving entityliving = this.bN();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.aM >= 0 && entityliving != null) {
|
|
|
|
entityliving.c(this, this.aM);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity != null) {
|
2012-07-29 09:33:13 +02:00
|
|
|
entity.a(this);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bd = 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) {
|
2012-10-25 05:53:23 +02:00
|
|
|
i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!this.isBaby() && this.world.getGameRules().getBoolean("doMobLoot")) {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.dropEquipment(this.lastDamageByPlayerTime > 0, i);
|
2012-07-22 08:18:00 +02:00
|
|
|
if (false && this.lastDamageByPlayerTime > 0) { // CraftBukkit - move rare item drop call to dropDeathLoot
|
2012-04-15 16:16:43 +02:00
|
|
|
int j = this.random.nextInt(200) - i;
|
|
|
|
|
|
|
|
if (j < 5) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.l(j <= 0 ? 1 : 0);
|
2012-04-15 16:16:43 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-22 08:18:00 +02:00
|
|
|
} else { // CraftBukkit
|
|
|
|
CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 3);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 02:55:45 +01:00
|
|
|
// CraftBukkit start - change return type to ItemStack
|
2012-07-29 09:33:13 +02:00
|
|
|
protected ItemStack l(int i) {
|
2012-03-21 02:55:45 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start - whole method
|
2011-06-27 00:25:01 +02:00
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2012-07-29 09:33:13 +02:00
|
|
|
int j = this.getLootId();
|
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
|
|
|
|
2012-03-21 02:55:45 +01:00
|
|
|
// Determine rare item drops and add them to the loot
|
|
|
|
if (this.lastDamageByPlayerTime > 0) {
|
|
|
|
int k = this.random.nextInt(200) - i;
|
|
|
|
|
|
|
|
if (k < 5) {
|
2012-07-29 09:33:13 +02:00
|
|
|
ItemStack itemstack = this.l(k <= 0 ? 1 : 0);
|
2012-03-21 02:55:45 +01:00
|
|
|
if (itemstack != null) {
|
2012-12-17 08:31:41 +01:00
|
|
|
loot.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
|
2012-03-21 02:55:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
protected void a(float f) {
|
|
|
|
super.a(f);
|
2012-07-29 09:33:13 +02:00
|
|
|
int i = MathHelper.f(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) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("damage.fallbig", 1.0F, 1.0F);
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("damage.fallsmall", 1.0F, 1.0F);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-07-14 05:57:42 +02:00
|
|
|
this.getBukkitEntity().setLastDamageCause(event);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.damageEntity(DamageSource.FALL, i);
|
2011-01-20 09:10:47 +01:00
|
|
|
}
|
2012-01-12 23:10:13 +01:00
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02: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
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void e(float f, float f1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
double d0;
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.G() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locY;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.a(f, f1, this.bh() ? 0.04F : 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;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.positionChanged && this.c(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
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
} else if (this.I() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) {
|
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;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.positionChanged && this.c(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-03-01 11:49:23 +01:00
|
|
|
float f4;
|
|
|
|
|
|
|
|
if (this.onGround) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bh()) {
|
|
|
|
f4 = this.aI();
|
2012-03-01 11:49:23 +01:00
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
f4 = this.aO;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
f4 *= f3;
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
f4 = this.aP;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
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
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.g_()) {
|
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
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
boolean flag = this.isSneaking() && this instanceof EntityHuman;
|
|
|
|
|
|
|
|
if (flag && 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);
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.positionChanged && this.g_()) {
|
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
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.world.isStatic && (!this.world.isLoaded((int) this.locX, 0, (int) this.locZ) || !this.world.getChunkAtWorldCoords((int) this.locX, (int) this.locZ).d)) {
|
|
|
|
if (this.locY > 0.0D) {
|
|
|
|
this.motY = -0.1D;
|
|
|
|
} else {
|
|
|
|
this.motY = 0.0D;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.motY -= 0.08D;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY *= 0.9800000190734863D;
|
|
|
|
this.motX *= (double) f2;
|
|
|
|
this.motZ *= (double) f2;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bh = this.bi;
|
2011-01-29 22:50:29 +01:00
|
|
|
d0 = this.locX - this.lastX;
|
|
|
|
double d1 = this.locZ - this.lastZ;
|
2012-01-14 21:03:48 +01:00
|
|
|
float f6 = MathHelper.sqrt(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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bi += (f6 - this.bi) * 0.4F;
|
|
|
|
this.bj += this.bi;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean g_() {
|
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);
|
2012-03-01 11:49:23 +01:00
|
|
|
int l = this.world.getTypeId(i, j, k);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
return l == Block.LADDER.id || l == Block.VINE.id;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
2012-10-29 04:55:40 +01:00
|
|
|
if (this.health < -32768) {
|
|
|
|
this.health = -32768;
|
|
|
|
}
|
|
|
|
|
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);
|
2013-03-13 23:33:27 +01:00
|
|
|
nbttagcompound.setBoolean("CanPickUpLoot", this.bS());
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttagcompound.setBoolean("PersistenceRequired", this.persistent);
|
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
|
|
|
|
|
|
for (int i = 0; i < this.equipment.length; ++i) {
|
|
|
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
|
|
|
|
|
|
|
if (this.equipment[i] != null) {
|
|
|
|
this.equipment[i].save(nbttagcompound1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttaglist.add(nbttagcompound1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound.set("Equipment", nbttaglist);
|
|
|
|
NBTTagList nbttaglist1;
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (!this.effects.isEmpty()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttaglist1 = 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();
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttaglist1.add(mobeffect.a(new NBTTagCompound()));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttagcompound.set("ActiveEffects", nbttaglist1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
nbttaglist1 = new NBTTagList();
|
|
|
|
|
|
|
|
for (int j = 0; j < this.dropChances.length; ++j) {
|
|
|
|
nbttaglist1.add(new NBTTagFloat(j + "", this.dropChances[j]));
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound.set("DropChances", nbttaglist1);
|
2013-03-13 23:33:27 +01:00
|
|
|
nbttagcompound.setString("CustomName", this.getCustomName());
|
|
|
|
nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible());
|
2012-12-23 12:49:03 +01:00
|
|
|
nbttagcompound.setInt("Bukkit.MaxHealth", this.maxHealth); // CraftBukkit
|
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");
|
2012-12-23 12:49:03 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
|
|
|
|
this.maxHealth = nbttagcompound.getInt("Bukkit.MaxHealth");
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!nbttagcompound.hasKey("Health")) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.health = this.maxHealth; // CraftBukkit - this.getMaxHealth() -> this.maxHealth
|
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");
|
2012-12-11 12:32:05 +01:00
|
|
|
// CraftBukkit start - if looting or persistence is false only use it if it was set after we started using it
|
|
|
|
boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
|
|
|
|
if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
|
|
|
this.canPickUpLoot = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = nbttagcompound.getBoolean("PersistenceRequired");
|
|
|
|
if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
2012-12-05 06:13:12 +01:00
|
|
|
this.persistent = data;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (nbttagcompound.hasKey("CustomName") && nbttagcompound.getString("CustomName").length() > 0) {
|
|
|
|
this.setCustomName(nbttagcompound.getString("CustomName"));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setCustomNameVisible(nbttagcompound.getBoolean("CustomNameVisible"));
|
2012-10-25 05:53:23 +02:00
|
|
|
NBTTagList nbttaglist;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (nbttagcompound.hasKey("Equipment")) {
|
|
|
|
nbttaglist = nbttagcompound.getList("Equipment");
|
|
|
|
|
|
|
|
for (i = 0; i < this.equipment.length; ++i) {
|
2013-01-17 10:28:44 +01:00
|
|
|
this.equipment[i] = ItemStack.createStack((NBTTagCompound) nbttaglist.get(i));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (nbttagcompound.hasKey("ActiveEffects")) {
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttaglist = nbttagcompound.getList("ActiveEffects");
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
for (i = 0; i < nbttaglist.size(); ++i) {
|
2011-11-30 00:17:43 +01:00
|
|
|
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i);
|
2012-10-25 05:53:23 +02:00
|
|
|
MobEffect mobeffect = MobEffect.b(nbttagcompound1);
|
|
|
|
|
|
|
|
this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbttagcompound.hasKey("DropChances")) {
|
|
|
|
nbttaglist = nbttagcompound.getList("DropChances");
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
for (i = 0; i < nbttaglist.size(); ++i) {
|
|
|
|
this.dropChances[i] = ((NBTTagFloat) nbttaglist.get(i)).data;
|
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
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bf() {
|
2011-01-17 04:03:19 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void f(float f) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bE = f;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void f(boolean flag) {
|
|
|
|
this.bG = flag;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bX > 0) {
|
|
|
|
--this.bX;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bu > 0) {
|
|
|
|
double d0 = this.locX + (this.bv - this.locX) / (double) this.bu;
|
|
|
|
double d1 = this.locY + (this.bw - this.locY) / (double) this.bu;
|
|
|
|
double d2 = this.locZ + (this.bx - this.locZ) / (double) this.bu;
|
|
|
|
double d3 = MathHelper.g(this.by - (double) this.yaw);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.yaw = (float) ((double) this.yaw + d3 / (double) this.bu);
|
|
|
|
this.pitch = (float) ((double) this.pitch + (this.bz - (double) this.pitch) / (double) this.bu);
|
|
|
|
--this.bu;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(d0, d1, d2);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(this.yaw, this.pitch);
|
2013-03-13 23:33:27 +01:00
|
|
|
} else if (!this.bi()) {
|
2012-12-20 05:03:52 +01:00
|
|
|
this.motX *= 0.98D;
|
|
|
|
this.motY *= 0.98D;
|
|
|
|
this.motZ *= 0.98D;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Math.abs(this.motX) < 0.005D) {
|
|
|
|
this.motX = 0.0D;
|
|
|
|
}
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Math.abs(this.motY) < 0.005D) {
|
|
|
|
this.motY = 0.0D;
|
|
|
|
}
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (Math.abs(this.motZ) < 0.005D) {
|
|
|
|
this.motZ = 0.0D;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("ai");
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bj()) {
|
|
|
|
this.bG = false;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.bD = 0.0F;
|
2012-12-20 05:03:52 +01:00
|
|
|
this.bE = 0.0F;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bF = 0.0F;
|
|
|
|
} else if (this.bi()) {
|
|
|
|
if (this.bh()) {
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("newAi");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bo();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
2012-01-12 23:10:13 +01:00
|
|
|
} else {
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("oldAi");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bq();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aA = this.yaw;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("jump");
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bG) {
|
|
|
|
if (!this.G() && !this.I()) {
|
|
|
|
if (this.onGround && this.bX == 0) {
|
|
|
|
this.bl();
|
|
|
|
this.bX = 10;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY += 0.03999999910593033D;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bX = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("travel");
|
2012-12-20 05:03:52 +01:00
|
|
|
this.bD *= 0.98F;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bE *= 0.98F;
|
|
|
|
this.bF *= 0.9F;
|
|
|
|
float f = this.aO;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aO *= this.bE();
|
|
|
|
this.e(this.bD, this.bE);
|
|
|
|
this.aO = f;
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("push");
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!this.world.isStatic) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bg();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("looting");
|
2012-12-12 10:03:01 +01:00
|
|
|
// CraftBukkit - Don't run mob pickup code on players
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!this.world.isStatic && !(this instanceof EntityPlayer) && this.bS() && !this.bd && this.world.getGameRules().getBoolean("mobGriefing")) {
|
2012-11-06 13:05:28 +01:00
|
|
|
List list = this.world.a(EntityItem.class, this.boundingBox.grow(1.0D, 0.0D, 1.0D));
|
|
|
|
Iterator iterator = list.iterator();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityItem entityitem = (EntityItem) iterator.next();
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
if (!entityitem.dead && entityitem.getItemStack() != null) {
|
|
|
|
ItemStack itemstack = entityitem.getItemStack();
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = b(itemstack);
|
|
|
|
|
|
|
|
if (i > -1) {
|
|
|
|
boolean flag = true;
|
|
|
|
ItemStack itemstack1 = this.getEquipment(i);
|
|
|
|
|
|
|
|
if (itemstack1 != null) {
|
|
|
|
if (i == 0) {
|
|
|
|
if (itemstack.getItem() instanceof ItemSword && !(itemstack1.getItem() instanceof ItemSword)) {
|
|
|
|
flag = true;
|
|
|
|
} else if (itemstack.getItem() instanceof ItemSword && itemstack1.getItem() instanceof ItemSword) {
|
|
|
|
ItemSword itemsword = (ItemSword) itemstack.getItem();
|
|
|
|
ItemSword itemsword1 = (ItemSword) itemstack1.getItem();
|
|
|
|
|
|
|
|
if (itemsword.g() == itemsword1.g()) {
|
|
|
|
flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag();
|
|
|
|
} else {
|
|
|
|
flag = itemsword.g() > itemsword1.g();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
} else if (itemstack.getItem() instanceof ItemArmor && !(itemstack1.getItem() instanceof ItemArmor)) {
|
|
|
|
flag = true;
|
|
|
|
} else if (itemstack.getItem() instanceof ItemArmor && itemstack1.getItem() instanceof ItemArmor) {
|
|
|
|
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
|
|
|
ItemArmor itemarmor1 = (ItemArmor) itemstack1.getItem();
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemarmor.c == itemarmor1.c) {
|
2012-10-25 05:53:23 +02:00
|
|
|
flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag();
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
flag = itemarmor.c > itemarmor1.c;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
if (itemstack1 != null && this.random.nextFloat() - 0.1F < this.dropChances[i]) {
|
|
|
|
this.a(itemstack1, 0.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setEquipment(i, itemstack);
|
|
|
|
this.dropChances[i] = 2.0F;
|
|
|
|
this.persistent = true;
|
|
|
|
this.receive(entityitem, 1);
|
|
|
|
entityitem.die();
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bg() {
|
2012-11-06 13:05:28 +01:00
|
|
|
List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
|
|
|
|
|
|
|
if (list != null && !list.isEmpty()) {
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity = (Entity) list.get(i);
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (entity.L()) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.o(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void o(Entity entity) {
|
2012-10-25 05:53:23 +02:00
|
|
|
entity.collide(this);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected boolean bh() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected boolean bi() {
|
2012-01-12 23:10:13 +01:00
|
|
|
return !this.world.isStatic;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected boolean bj() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.health <= 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bk() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bl() {
|
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);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.an = true;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-01-17 10:28:44 +01:00
|
|
|
protected boolean isTypeNotPersistent() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bn() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!this.persistent) {
|
|
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
2011-01-17 04:03:19 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (entityhuman != null) {
|
|
|
|
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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (d3 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check
|
2012-10-25 05:53:23 +02:00
|
|
|
this.die();
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bC > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check
|
2012-10-25 05:53:23 +02:00
|
|
|
this.die();
|
|
|
|
} else if (d3 < 1024.0D) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bC = 0;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2012-12-08 04:18:51 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bC = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2012-12-08 04:18:51 +01:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bo() {
|
|
|
|
++this.bC;
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.a("checkDespawn");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bn();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("sensing");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bP.a();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("targetSelector");
|
2012-04-23 16:47:05 +02:00
|
|
|
this.targetSelector.a();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("goalSelector");
|
2012-04-23 16:47:05 +02:00
|
|
|
this.goalSelector.a();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("navigation");
|
2012-07-29 09:33:13 +02:00
|
|
|
this.navigation.e();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("mob tick");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bp();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.a("controls");
|
|
|
|
this.world.methodProfiler.a("move");
|
2012-03-01 11:49:23 +01:00
|
|
|
this.moveController.c();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.c("look");
|
2012-01-12 23:10:13 +01:00
|
|
|
this.lookController.a();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.c("jump");
|
2012-01-12 23:10:13 +01:00
|
|
|
this.jumpController.b();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.world.methodProfiler.b();
|
|
|
|
this.world.methodProfiler.b();
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bp() {}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bq() {
|
|
|
|
++this.bC;
|
|
|
|
this.bn();
|
2012-12-20 05:03:52 +01:00
|
|
|
this.bD = 0.0F;
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bE = 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) {
|
2012-03-22 21:39:39 +01:00
|
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, (double) f);
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityhuman != null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bY = entityhuman;
|
|
|
|
this.bJ = 10 + this.random.nextInt(20);
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bF = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.bY != null) {
|
|
|
|
this.a(this.bY, 10.0F, (float) this.bs());
|
|
|
|
if (this.bJ-- <= 0 || this.bY.dead || this.bY.e((Entity) this) > (double) (f * f)) {
|
|
|
|
this.bY = null;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.random.nextFloat() < 0.05F) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bF = (this.random.nextFloat() - 0.5F) * 20.0F;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.yaw += this.bF;
|
|
|
|
this.pitch = this.bH;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
boolean flag = this.G();
|
|
|
|
boolean flag1 = this.I();
|
2011-01-17 04:03:19 +01:00
|
|
|
|
|
|
|
if (flag || flag1) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bG = this.random.nextFloat() < 0.8F;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void br() {
|
2012-11-06 13:05:28 +01:00
|
|
|
int i = this.h();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.br) {
|
|
|
|
++this.bs;
|
|
|
|
if (this.bs >= i) {
|
|
|
|
this.bs = 0;
|
|
|
|
this.br = false;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
} else {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bs = 0;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aR = (float) this.bs / (float) i;
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int bs() {
|
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;
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
d2 = entityliving.locY + (double) entityliving.getHeadHeight() - (this.locY + (double) this.getHeadHeight());
|
2011-01-17 04:03:19 +01:00
|
|
|
} else {
|
2012-02-29 22:31:04 +01:00
|
|
|
d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.getHeadHeight());
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
double d3 = (double) MathHelper.sqrt(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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.pitch = this.b(this.pitch, f3, f1);
|
2011-03-31 22:40:00 +02:00
|
|
|
this.yaw = this.b(this.yaw, f2, f);
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private float b(float f, float f1, float f2) {
|
2012-07-29 09:33:13 +02:00
|
|
|
float f3 = MathHelper.g(f1 - f);
|
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-14 21:03:48 +01:00
|
|
|
public boolean canSpawn() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void B() {
|
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
|
|
|
|
2012-07-01 12:04:06 +02:00
|
|
|
event.getEntity().setLastDamageCause(event);
|
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
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public Vec3D Y() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.i(1.0F);
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public Vec3D i(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);
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.world.getVec3DPool().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
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.world.getVec3DPool().create((double) (f4 * f5), (double) f6, (double) (f3 * f5));
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int by() {
|
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
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bA() {
|
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
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!mobeffect.tick(this)) {
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
iterator.remove();
|
|
|
|
this.c(mobeffect);
|
|
|
|
}
|
|
|
|
} else if (mobeffect.getDuration() % 600 == 0) {
|
|
|
|
this.b(mobeffect);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.updateEffects) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!this.world.isStatic) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.effects.isEmpty()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.datawatcher.watch(9, Byte.valueOf((byte) 0));
|
2012-07-29 09:33:13 +02:00
|
|
|
this.datawatcher.watch(8, Integer.valueOf(0));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.setInvisible(false);
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
2011-11-20 09:01:14 +01:00
|
|
|
i = PotionBrewer.a(this.effects.values());
|
2012-10-25 05:53:23 +02:00
|
|
|
this.datawatcher.watch(9, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0)));
|
2011-11-20 09:01:14 +01:00
|
|
|
this.datawatcher.watch(8, Integer.valueOf(i));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id));
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.updateEffects = false;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
i = this.datawatcher.getInt(8);
|
|
|
|
boolean flag = this.datawatcher.getByte(9) > 0;
|
|
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
boolean flag1 = false;
|
|
|
|
|
|
|
|
if (!this.isInvisible()) {
|
|
|
|
flag1 = this.random.nextBoolean();
|
|
|
|
} else {
|
|
|
|
flag1 = this.random.nextInt(15) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
flag1 &= this.random.nextInt(5) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag1 && i > 0) {
|
2011-11-20 09:01:14 +01:00
|
|
|
double d0 = (double) (i >> 16 & 255) / 255.0D;
|
|
|
|
double d1 = (double) (i >> 8 & 255) / 255.0D;
|
|
|
|
double d2 = (double) (i >> 0 & 255) / 255.0D;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle(flag ? "mobSpellAmbient" : "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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void bB() {
|
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();
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(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
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean hasEffect(int i) {
|
|
|
|
return this.effects.containsKey(Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
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) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.e(mobeffect)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) {
|
|
|
|
((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId())));
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
|
|
|
this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(mobeffect);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean e(MobEffect mobeffect) {
|
|
|
|
if (this.getMonsterType() == EnumMonsterType.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;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bD() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.getMonsterType() == EnumMonsterType.UNDEAD;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void o(int i) {
|
|
|
|
MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i));
|
|
|
|
|
|
|
|
if (mobeffect != null) {
|
|
|
|
this.c(mobeffect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a(MobEffect mobeffect) {
|
|
|
|
this.updateEffects = true;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void b(MobEffect mobeffect) {
|
|
|
|
this.updateEffects = true;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void c(MobEffect mobeffect) {
|
|
|
|
this.updateEffects = true;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float bE() {
|
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
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (f < 0.0F) {
|
|
|
|
f = 0.0F;
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
return f;
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch);
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public boolean isBaby() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumMonsterType getMonsterType() {
|
|
|
|
return EnumMonsterType.UNDEFINED;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void a(ItemStack itemstack) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
Vec3D vec3d = this.world.getVec3DPool().create(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
vec3d.a(-this.pitch * 3.1415927F / 180.0F);
|
|
|
|
vec3d.b(-this.yaw * 3.1415927F / 180.0F);
|
2012-10-25 05:53:23 +02:00
|
|
|
Vec3D vec3d1 = this.world.getVec3DPool().create(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
vec3d1.a(-this.pitch * 3.1415927F / 180.0F);
|
|
|
|
vec3d1.b(-this.yaw * 3.1415927F / 180.0F);
|
2012-02-29 22:31:04 +01:00
|
|
|
vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addParticle("iconcrack_" + itemstack.getItem().id, vec3d1.c, vec3d1.d, vec3d1.e, vec3d.c, vec3d.d + 0.05D, vec3d.e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int ar() {
|
2013-01-17 10:28:44 +01:00
|
|
|
if (this.getGoalTarget() == null) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return 3;
|
|
|
|
} else {
|
2012-12-23 12:49:03 +01:00
|
|
|
int i = (int) ((float) this.health - (float) this.maxHealth * 0.33F); // this.getMaxHealth() -> this.maxHealth
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
i -= (3 - this.world.difficulty) * 4;
|
|
|
|
if (i < 0) {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i + 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public ItemStack bG() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.equipment[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack getEquipment(int i) {
|
|
|
|
return this.equipment[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack q(int i) {
|
|
|
|
return this.equipment[i + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEquipment(int i, ItemStack itemstack) {
|
|
|
|
this.equipment[i] = itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack[] getEquipment() {
|
|
|
|
return this.equipment;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void dropEquipment(boolean flag, int i) {
|
|
|
|
for (int j = 0; j < this.getEquipment().length; ++j) {
|
|
|
|
ItemStack itemstack = this.getEquipment(j);
|
|
|
|
boolean flag1 = this.dropChances[j] > 1.0F;
|
|
|
|
|
|
|
|
if (itemstack != null && (flag || flag1) && this.random.nextFloat() - (float) i * 0.01F < this.dropChances[j]) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!flag1 && itemstack.g()) {
|
|
|
|
int k = Math.max(itemstack.l() - 25, 1);
|
|
|
|
int l = itemstack.l() - this.random.nextInt(this.random.nextInt(k) + 1);
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (l > k) {
|
|
|
|
l = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l < 1) {
|
|
|
|
l = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
itemstack.setData(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.a(itemstack, 0.0F);
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bH() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.random.nextFloat() < d[this.world.difficulty]) {
|
|
|
|
int i = this.random.nextInt(2);
|
|
|
|
float f = this.world.difficulty == 3 ? 0.1F : 0.25F;
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.random.nextFloat() < 0.095F) {
|
2012-10-25 05:53:23 +02:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.random.nextFloat() < 0.095F) {
|
2012-10-25 05:53:23 +02:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.random.nextFloat() < 0.095F) {
|
2012-10-25 05:53:23 +02:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 3; j >= 0; --j) {
|
|
|
|
ItemStack itemstack = this.q(j);
|
|
|
|
|
|
|
|
if (j < 3 && this.random.nextFloat() < f) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemstack == null) {
|
|
|
|
Item item = a(j + 1, i);
|
|
|
|
|
|
|
|
if (item != null) {
|
|
|
|
this.setEquipment(j + 1, new ItemStack(item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void receive(Entity entity, int i) {
|
|
|
|
if (!entity.dead && !this.world.isStatic) {
|
|
|
|
EntityTracker entitytracker = ((WorldServer) this.world).getTracker();
|
|
|
|
|
|
|
|
if (entity instanceof EntityItem) {
|
2012-11-06 13:05:28 +01:00
|
|
|
entitytracker.a(entity, (Packet) (new Packet22Collect(entity.id, this.id)));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity instanceof EntityArrow) {
|
2012-11-06 13:05:28 +01:00
|
|
|
entitytracker.a(entity, (Packet) (new Packet22Collect(entity.id, this.id)));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity instanceof EntityExperienceOrb) {
|
2012-11-06 13:05:28 +01:00
|
|
|
entitytracker.a(entity, (Packet) (new Packet22Collect(entity.id, this.id)));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int b(ItemStack itemstack) {
|
|
|
|
if (itemstack.id != Block.PUMPKIN.id && itemstack.id != Item.SKULL.id) {
|
|
|
|
if (itemstack.getItem() instanceof ItemArmor) {
|
2013-03-13 23:33:27 +01:00
|
|
|
switch (((ItemArmor) itemstack.getItem()).b) {
|
2012-10-25 05:53:23 +02:00
|
|
|
case 0:
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Item a(int i, int j) {
|
|
|
|
switch (i) {
|
|
|
|
case 4:
|
|
|
|
if (j == 0) {
|
|
|
|
return Item.LEATHER_HELMET;
|
|
|
|
} else if (j == 1) {
|
|
|
|
return Item.GOLD_HELMET;
|
|
|
|
} else if (j == 2) {
|
|
|
|
return Item.CHAINMAIL_HELMET;
|
|
|
|
} else if (j == 3) {
|
|
|
|
return Item.IRON_HELMET;
|
|
|
|
} else if (j == 4) {
|
|
|
|
return Item.DIAMOND_HELMET;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
if (j == 0) {
|
|
|
|
return Item.LEATHER_CHESTPLATE;
|
|
|
|
} else if (j == 1) {
|
|
|
|
return Item.GOLD_CHESTPLATE;
|
|
|
|
} else if (j == 2) {
|
|
|
|
return Item.CHAINMAIL_CHESTPLATE;
|
|
|
|
} else if (j == 3) {
|
|
|
|
return Item.IRON_CHESTPLATE;
|
|
|
|
} else if (j == 4) {
|
|
|
|
return Item.DIAMOND_CHESTPLATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (j == 0) {
|
|
|
|
return Item.LEATHER_LEGGINGS;
|
|
|
|
} else if (j == 1) {
|
|
|
|
return Item.GOLD_LEGGINGS;
|
|
|
|
} else if (j == 2) {
|
|
|
|
return Item.CHAINMAIL_LEGGINGS;
|
|
|
|
} else if (j == 3) {
|
|
|
|
return Item.IRON_LEGGINGS;
|
|
|
|
} else if (j == 4) {
|
|
|
|
return Item.DIAMOND_LEGGINGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (j == 0) {
|
|
|
|
return Item.LEATHER_BOOTS;
|
|
|
|
} else if (j == 1) {
|
|
|
|
return Item.GOLD_BOOTS;
|
|
|
|
} else if (j == 2) {
|
|
|
|
return Item.CHAINMAIL_BOOTS;
|
|
|
|
} else if (j == 3) {
|
|
|
|
return Item.IRON_BOOTS;
|
|
|
|
} else if (j == 4) {
|
|
|
|
return Item.DIAMOND_BOOTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bI() {
|
|
|
|
if (this.bG() != null && this.random.nextFloat() < b[this.world.difficulty]) {
|
|
|
|
EnchantmentManager.a(this.random, this.bG(), 5 + this.world.difficulty * this.random.nextInt(6));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
ItemStack itemstack = this.q(i);
|
|
|
|
|
|
|
|
if (itemstack != null && this.random.nextFloat() < c[this.world.difficulty]) {
|
2012-12-20 05:03:52 +01:00
|
|
|
EnchantmentManager.a(this.random, itemstack, 5 + this.world.difficulty * this.random.nextInt(6));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void bJ() {}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
private int h() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.hasEffect(MobEffectList.FASTER_DIG) ? 6 - (1 + this.getEffect(MobEffectList.FASTER_DIG).getAmplifier()) * 1 : (this.hasEffect(MobEffectList.SLOWER_DIG) ? 6 + (1 + this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier()) * 2 : 6);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void bK() {
|
|
|
|
if (!this.br || this.bs >= this.h() / 2 || this.bs < 0) {
|
|
|
|
this.bs = -1;
|
|
|
|
this.br = true;
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.world instanceof WorldServer) {
|
2012-11-06 13:05:28 +01:00
|
|
|
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new Packet18ArmAnimation(this, 1)));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bL() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public final int bM() {
|
2012-11-06 13:05:28 +01:00
|
|
|
return this.datawatcher.getByte(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void r(int i) {
|
|
|
|
this.datawatcher.watch(10, Byte.valueOf((byte) i));
|
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
public EntityLiving bN() {
|
|
|
|
return (EntityLiving) (this.bt.c() != null ? this.bt.c() : (this.killer != null ? this.killer : (this.lastDamager != null ? this.lastDamager : null)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getLocalizedName() {
|
|
|
|
return this.hasCustomName() ? this.getCustomName() : super.getLocalizedName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCustomName(String s) {
|
|
|
|
this.datawatcher.watch(5, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCustomName() {
|
|
|
|
return this.datawatcher.getString(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasCustomName() {
|
|
|
|
return this.datawatcher.getString(5).length() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCustomNameVisible(boolean flag) {
|
|
|
|
this.datawatcher.watch(6, Byte.valueOf((byte) (flag ? 1 : 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getCustomNameVisible() {
|
|
|
|
return this.datawatcher.getByte(6) == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(int i, float f) {
|
|
|
|
this.dropChances[i] = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean bS() {
|
|
|
|
return this.canPickUpLoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void h(boolean flag) {
|
|
|
|
this.canPickUpLoot = flag;
|
|
|
|
}
|
2011-01-17 04:03:19 +01:00
|
|
|
}
|