2011-01-29 22:50:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
import java.util.Iterator;
|
2011-01-29 22:50:29 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-02-22 01:43:12 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftItem;
|
2011-02-20 23:22:28 +01:00
|
|
|
import org.bukkit.craftbukkit.TrigMath;
|
2011-02-11 22:49:51 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2011-01-29 22:50:29 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
2011-02-11 22:49:51 +01:00
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public abstract class EntityHuman extends EntityLiving {
|
|
|
|
|
|
|
|
public InventoryPlayer inventory = new InventoryPlayer(this);
|
|
|
|
public Container defaultContainer;
|
|
|
|
public Container activeContainer;
|
2011-02-23 03:37:56 +01:00
|
|
|
public byte l = 0;
|
|
|
|
public int m = 0;
|
|
|
|
public float n;
|
|
|
|
public float o;
|
|
|
|
public boolean p = false;
|
|
|
|
public int q = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
public String name;
|
|
|
|
public int dimension;
|
2011-02-23 03:37:56 +01:00
|
|
|
public double t;
|
|
|
|
public double u;
|
|
|
|
public double v;
|
|
|
|
public double w;
|
|
|
|
public double x;
|
|
|
|
public double y;
|
|
|
|
private boolean sleeping;
|
|
|
|
private ChunkCoordinates b;
|
|
|
|
private int sleepTicks;
|
|
|
|
public float z;
|
|
|
|
public float A;
|
2011-03-31 22:40:00 +02:00
|
|
|
private ChunkCoordinates d;
|
|
|
|
private int e = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
public EntityFish hookedFish = null;
|
|
|
|
|
|
|
|
public EntityHuman(World world) {
|
|
|
|
super(world);
|
|
|
|
this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic);
|
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
this.height = 1.62F;
|
2011-03-31 22:40:00 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = world.m();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
this.c((double) chunkcoordinates.a + 0.5D, (double) (chunkcoordinates.b + 1), (double) chunkcoordinates.c + 0.5D, 0.0F, 0.0F);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.health = 20;
|
2011-02-23 03:37:56 +01:00
|
|
|
this.P = "humanoid";
|
|
|
|
this.O = 180.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.maxFireTicks = 20;
|
|
|
|
this.texture = "/mob/char.png";
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
|
|
|
this.datawatcher.a(16, Byte.valueOf((byte) 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void f_() {
|
2011-03-31 22:40:00 +02:00
|
|
|
if (this.F()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
++this.sleepTicks;
|
|
|
|
if (this.sleepTicks > 100) {
|
|
|
|
this.sleepTicks = 100;
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (!this.m()) {
|
|
|
|
this.a(true, true, false);
|
|
|
|
} else if (!this.world.isStatic && this.world.d()) {
|
|
|
|
this.a(false, true, true);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
} else if (this.sleepTicks > 0) {
|
|
|
|
++this.sleepTicks;
|
|
|
|
if (this.sleepTicks >= 110) {
|
|
|
|
this.sleepTicks = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.f_();
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.b(this)) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.u();
|
2011-01-29 22:50:29 +01:00
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.t = this.w;
|
|
|
|
this.u = this.x;
|
|
|
|
this.v = this.y;
|
|
|
|
double d0 = this.locX - this.w;
|
|
|
|
double d1 = this.locY - this.x;
|
|
|
|
double d2 = this.locZ - this.y;
|
2011-01-29 22:50:29 +01:00
|
|
|
double d3 = 10.0D;
|
|
|
|
|
|
|
|
if (d0 > d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.t = this.w = this.locX;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d2 > d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.v = this.y = this.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d1 > d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.u = this.x = this.locY;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d0 < -d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.t = this.w = this.locX;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d2 < -d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.v = this.y = this.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d1 < -d3) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.u = this.x = this.locY;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.w += d0 * 0.25D;
|
|
|
|
this.y += d2 * 0.25D;
|
|
|
|
this.x += d1 * 0.25D;
|
2011-03-31 22:40:00 +02:00
|
|
|
this.a(StatisticList.j, 1);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected boolean p_() {
|
|
|
|
return this.health <= 0 || this.F();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected void u() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void o_() {
|
|
|
|
super.o_();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.n = this.o;
|
|
|
|
this.o = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected void c_() {
|
|
|
|
if (this.p) {
|
|
|
|
++this.q;
|
|
|
|
if (this.q == 8) {
|
|
|
|
this.q = 0;
|
|
|
|
this.p = false;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.q = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.V = (float) this.q / 8.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void r() {
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.world.j == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) {
|
|
|
|
this.b(1);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
this.inventory.f();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.n = this.o;
|
2011-03-31 22:40:00 +02:00
|
|
|
super.r();
|
2011-01-29 22:50:29 +01:00
|
|
|
float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit -- Math -> TrigMath
|
|
|
|
float f1 = (float) TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f > 0.1F) {
|
|
|
|
f = 0.1F;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.onGround || this.health <= 0) {
|
|
|
|
f = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.onGround || this.health <= 0) {
|
|
|
|
f1 = 0.0F;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
this.o += (f - this.o) * 0.4F;
|
|
|
|
this.ae += (f1 - this.ae) * 0.8F;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health > 0) {
|
|
|
|
List list = this.world.b((Entity) this, this.boundingBox.b(1.0D, 0.0D, 1.0D));
|
|
|
|
|
|
|
|
if (list != null) {
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity = (Entity) list.get(i);
|
|
|
|
|
|
|
|
if (!entity.dead) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.i(entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void i(Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
entity.b(this);
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void a(Entity entity) {
|
|
|
|
super.a(entity);
|
2011-03-31 22:40:00 +02:00
|
|
|
this.b(0.2F, 0.2F);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(this.locX, this.locY, this.locZ);
|
|
|
|
this.motY = 0.10000000149011612D;
|
|
|
|
if (this.name.equals("Notch")) {
|
|
|
|
this.a(new ItemStack(Item.APPLE, 1), true);
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
this.inventory.h();
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entity != null) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.motX = (double) (-MathHelper.b((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
|
|
|
|
this.motZ = (double) (-MathHelper.a((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
this.motX = this.motZ = 0.0D;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.height = 0.1F;
|
2011-03-31 22:40:00 +02:00
|
|
|
this.a(StatisticList.u, 1);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void c(Entity entity, int i) {
|
|
|
|
this.m += i;
|
2011-03-31 22:40:00 +02:00
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.a(StatisticList.w, 1);
|
|
|
|
} else {
|
|
|
|
this.a(StatisticList.v, 1);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void z() {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.a(this.inventory.a(this.inventory.c, 1), false);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(ItemStack itemstack) {
|
|
|
|
this.a(itemstack, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ItemStack itemstack, boolean flag) {
|
|
|
|
if (itemstack != null) {
|
2011-03-31 22:40:00 +02:00
|
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.q(), this.locZ, itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
entityitem.c = 40;
|
|
|
|
float f = 0.1F;
|
|
|
|
float f1;
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
f1 = this.random.nextFloat() * 0.5F;
|
|
|
|
float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;
|
|
|
|
|
|
|
|
entityitem.motX = (double) (-MathHelper.a(f2) * f1);
|
|
|
|
entityitem.motZ = (double) (MathHelper.b(f2) * f1);
|
|
|
|
entityitem.motY = 0.20000000298023224D;
|
|
|
|
} else {
|
|
|
|
f = 0.3F;
|
|
|
|
entityitem.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
entityitem.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
entityitem.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
|
|
|
|
f = 0.02F;
|
|
|
|
f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
|
|
|
|
f *= this.random.nextFloat();
|
|
|
|
entityitem.motX += Math.cos((double) f1) * (double) f;
|
|
|
|
entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
|
|
|
|
entityitem.motZ += Math.sin((double) f1) * (double) f;
|
|
|
|
}
|
|
|
|
|
2011-02-11 22:49:51 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 13:56:36 +01:00
|
|
|
Player player = (Player) this.getBukkitEntity();
|
|
|
|
CraftServer server = ((WorldServer) world).getServer();
|
2011-02-22 01:43:12 +01:00
|
|
|
CraftItem drop = new CraftItem(server, entityitem);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-11 22:49:51 +01:00
|
|
|
PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
org.bukkit.inventory.ItemStack stack = drop.getItemStack();
|
|
|
|
stack.setAmount(1);
|
|
|
|
player.getInventory().addItem(stack);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(entityitem);
|
2011-03-31 22:40:00 +02:00
|
|
|
this.a(StatisticList.r, 1);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(EntityItem entityitem) {
|
|
|
|
this.world.a((Entity) entityitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float a(Block block) {
|
|
|
|
float f = this.inventory.a(block);
|
|
|
|
|
|
|
|
if (this.a(Material.WATER)) {
|
|
|
|
f /= 5.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.onGround) {
|
|
|
|
f /= 5.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(Block block) {
|
|
|
|
return this.inventory.b(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-02-23 03:37:56 +01:00
|
|
|
NBTTagList nbttaglist = nbttagcompound.l("Inventory");
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.inventory.b(nbttaglist);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.dimension = nbttagcompound.e("Dimension");
|
|
|
|
this.sleeping = nbttagcompound.m("Sleeping");
|
|
|
|
this.sleepTicks = nbttagcompound.d("SleepTimer");
|
|
|
|
if (this.sleeping) {
|
|
|
|
this.b = new ChunkCoordinates(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ));
|
2011-03-31 22:40:00 +02:00
|
|
|
this.a(true, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbttagcompound.b("SpawnX") && nbttagcompound.b("SpawnY") && nbttagcompound.b("SpawnZ")) {
|
|
|
|
this.d = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ"));
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
nbttagcompound.a("Inventory", (NBTBase) this.inventory.a(new NBTTagList()));
|
|
|
|
nbttagcompound.a("Dimension", this.dimension);
|
2011-02-23 03:37:56 +01:00
|
|
|
nbttagcompound.a("Sleeping", this.sleeping);
|
|
|
|
nbttagcompound.a("SleepTimer", (short) this.sleepTicks);
|
2011-03-31 22:40:00 +02:00
|
|
|
if (this.d != null) {
|
|
|
|
nbttagcompound.a("SpawnX", this.d.a);
|
|
|
|
nbttagcompound.a("SpawnY", this.d.b);
|
|
|
|
nbttagcompound.a("SpawnZ", this.d.c);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(IInventory iinventory) {}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void b(int i, int j, int k) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void b(Entity entity, int i) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public float q() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return 0.12F;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected void l_() {
|
|
|
|
this.height = 1.62F;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public boolean a(Entity entity, int i) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.at = 0;
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.health <= 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-03-31 22:40:00 +02:00
|
|
|
if (this.F()) {
|
|
|
|
this.a(true, true, false);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entity instanceof EntityMonster || entity instanceof EntityArrow) {
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.world.j == 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.world.j == 1) {
|
2011-01-29 22:50:29 +01:00
|
|
|
i = i / 3 + 1;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.world.j == 3) {
|
2011-01-29 22:50:29 +01:00
|
|
|
i = i * 3 / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (i == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
Object object = entity;
|
2011-02-24 13:49:48 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (entity instanceof EntityArrow && ((EntityArrow) entity).b != null) {
|
|
|
|
object = ((EntityArrow) entity).b;
|
2011-02-24 13:49:48 +01:00
|
|
|
}
|
2011-02-28 07:43:56 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
// CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters
|
|
|
|
// also damage the player in this way. For example, EntitySlime.
|
|
|
|
if (object instanceof EntityLiving) {
|
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
|
|
|
org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity();
|
|
|
|
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
|
|
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, i);
|
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled() || event.getDamage() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = event.getDamage();
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
this.a((EntityLiving) object, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.a(StatisticList.t, i);
|
|
|
|
return super.a(entity, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(EntityLiving entityliving, boolean flag) {
|
|
|
|
if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
|
|
|
|
if (entityliving instanceof EntityWolf) {
|
|
|
|
EntityWolf entitywolf = (EntityWolf) entityliving;
|
|
|
|
|
|
|
|
if (entitywolf.y() && this.name.equals(entitywolf.v())) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-24 13:49:48 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
List list = this.world.a(EntityWolf.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D));
|
|
|
|
Iterator iterator = list.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
Entity entity = (Entity) iterator.next();
|
|
|
|
EntityWolf entitywolf1 = (EntityWolf) entity;
|
|
|
|
|
|
|
|
if (entitywolf1.y() && entitywolf1.A() == null && this.name.equals(entitywolf1.v()) && (!flag || !entitywolf1.w())) {
|
|
|
|
entitywolf1.b(false);
|
|
|
|
entitywolf1.c(entityliving);
|
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected void c(int i) {
|
2011-03-31 22:40:00 +02:00
|
|
|
int j = 25 - this.inventory.g();
|
|
|
|
int k = i * j + this.e;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.inventory.c(i);
|
|
|
|
i = k / 25;
|
2011-03-31 22:40:00 +02:00
|
|
|
this.e = k % 25;
|
2011-02-23 03:37:56 +01:00
|
|
|
super.c(i);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(TileEntityFurnace tileentityfurnace) {}
|
|
|
|
|
|
|
|
public void a(TileEntityDispenser tileentitydispenser) {}
|
|
|
|
|
|
|
|
public void a(TileEntitySign tileentitysign) {}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void c(Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (!entity.a(this)) {
|
2011-03-31 22:40:00 +02:00
|
|
|
ItemStack itemstack = this.A();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (itemstack != null && entity instanceof EntityLiving) {
|
2011-03-31 22:40:00 +02:00
|
|
|
itemstack.a((EntityLiving) entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
itemstack.a(this);
|
2011-03-31 22:40:00 +02:00
|
|
|
this.B();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public ItemStack A() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.inventory.b();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void B() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.inventory.a(this.inventory.c, (ItemStack) null);
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public double C() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return (double) (this.height - 0.5F);
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void m_() {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.q = -1;
|
|
|
|
this.p = true;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void d(Entity entity) {
|
2011-01-29 22:50:29 +01:00
|
|
|
int i = this.inventory.a(entity);
|
|
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
// CraftBukkit start
|
2011-02-23 03:37:56 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
2011-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
|
|
|
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
|
|
|
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
|
|
|
|
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, i);
|
2011-01-29 22:50:29 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (event.isCancelled() || event.getDamage() == 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
i = event.getDamage();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
entity.a(this, i);
|
2011-03-31 22:40:00 +02:00
|
|
|
ItemStack itemstack = this.A();
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (itemstack != null && entity instanceof EntityLiving) {
|
2011-03-31 22:40:00 +02:00
|
|
|
itemstack.a((EntityLiving) entity, this);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
itemstack.a(this);
|
2011-03-31 22:40:00 +02:00
|
|
|
this.B();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
if (entity.N()) {
|
|
|
|
this.a((EntityLiving) entity, true);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
this.a(StatisticList.s, i);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ItemStack itemstack) {}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void D() {
|
|
|
|
super.D();
|
2011-01-29 22:50:29 +01:00
|
|
|
this.defaultContainer.a(this);
|
|
|
|
if (this.activeContainer != null) {
|
|
|
|
this.activeContainer.a(this);
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public boolean E() {
|
|
|
|
return !this.sleeping && super.E();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public EnumBedError a(int i, int j, int k) {
|
|
|
|
if (!this.F() && this.N()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.world.m.c) {
|
2011-03-31 22:40:00 +02:00
|
|
|
return EnumBedError.NOT_POSSIBLE_HERE;
|
|
|
|
} else if (this.world.d()) {
|
|
|
|
return EnumBedError.NOT_POSSIBLE_NOW;
|
2011-02-23 03:37:56 +01:00
|
|
|
} else if (Math.abs(this.locX - (double) i) <= 3.0D && Math.abs(this.locY - (double) j) <= 2.0D && Math.abs(this.locZ - (double) k) <= 3.0D) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.b(0.2F, 0.2F);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.height = 0.2F;
|
|
|
|
if (this.world.f(i, j, k)) {
|
|
|
|
int l = this.world.getData(i, j, k);
|
|
|
|
int i1 = BlockBed.c(l);
|
|
|
|
float f = 0.5F;
|
|
|
|
float f1 = 0.5F;
|
|
|
|
|
|
|
|
switch (i1) {
|
|
|
|
case 0:
|
|
|
|
f1 = 0.9F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
f = 0.1F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
f1 = 0.1F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
f = 0.9F;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.e(i1);
|
|
|
|
this.a((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1));
|
|
|
|
} else {
|
|
|
|
this.a((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.sleeping = true;
|
|
|
|
this.sleepTicks = 0;
|
|
|
|
this.b = new ChunkCoordinates(i, j, k);
|
|
|
|
this.motX = this.motZ = this.motY = 0.0D;
|
|
|
|
if (!this.world.isStatic) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.world.q();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
return EnumBedError.OK;
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2011-03-31 22:40:00 +02:00
|
|
|
return EnumBedError.TOO_FAR_AWAY;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-03-31 22:40:00 +02:00
|
|
|
return EnumBedError.OTHER_PROBLEM;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void e(int i) {
|
|
|
|
this.z = 0.0F;
|
|
|
|
this.A = 0.0F;
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
this.A = -1.8F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
this.z = 1.8F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
this.A = 1.8F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
this.z = -1.8F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void a(boolean flag, boolean flag1, boolean flag2) {
|
|
|
|
this.b(0.6F, 1.8F);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l_();
|
|
|
|
ChunkCoordinates chunkcoordinates = this.b;
|
2011-03-31 22:40:00 +02:00
|
|
|
ChunkCoordinates chunkcoordinates1 = this.b;
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) == Block.BED.id) {
|
|
|
|
BlockBed.a(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, false);
|
2011-03-31 22:40:00 +02:00
|
|
|
chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0);
|
|
|
|
if (chunkcoordinates1 == null) {
|
|
|
|
chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.a, chunkcoordinates.b + 1, chunkcoordinates.c);
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
this.a((double) ((float) chunkcoordinates1.a + 0.5F), (double) ((float) chunkcoordinates1.b + this.height + 0.1F), (double) ((float) chunkcoordinates1.c + 0.5F));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.sleeping = false;
|
|
|
|
if (!this.world.isStatic && flag1) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.world.q();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
this.sleepTicks = 0;
|
|
|
|
} else {
|
|
|
|
this.sleepTicks = 100;
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
if (flag2) {
|
|
|
|
this.a(this.b);
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
private boolean m() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.world.getTypeId(this.b.a, this.b.b, this.b.c) == Block.BED.id;
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public static ChunkCoordinates a(World world, ChunkCoordinates chunkcoordinates) {
|
|
|
|
IChunkProvider ichunkprovider = world.n();
|
|
|
|
|
|
|
|
ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c - 3 >> 4);
|
|
|
|
ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c - 3 >> 4);
|
|
|
|
ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c + 3 >> 4);
|
|
|
|
ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c + 3 >> 4);
|
|
|
|
if (world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) != Block.BED.id) {
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0);
|
|
|
|
|
|
|
|
return chunkcoordinates1;
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean F() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return this.sleeping;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean G() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.sleeping && this.sleepTicks >= 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s) {}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
public ChunkCoordinates H() {
|
|
|
|
return this.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ChunkCoordinates chunkcoordinates) {
|
|
|
|
if (chunkcoordinates != null) {
|
|
|
|
this.d = new ChunkCoordinates(chunkcoordinates);
|
|
|
|
} else {
|
|
|
|
this.d = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Statistic statistic, int i) {}
|
|
|
|
|
|
|
|
protected void I() {
|
|
|
|
super.I();
|
|
|
|
this.a(StatisticList.q, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(float f, float f1) {
|
|
|
|
double d0 = this.locX;
|
|
|
|
double d1 = this.locY;
|
|
|
|
double d2 = this.locZ;
|
|
|
|
|
|
|
|
super.a(f, f1);
|
|
|
|
this.g(this.locX - d0, this.locY - d1, this.locZ - d2);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void g(double d0, double d1, double d2) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (this.a(Material.WATER)) {
|
|
|
|
i = Math.round(MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.p, i);
|
|
|
|
}
|
|
|
|
} else if (this.g_()) {
|
|
|
|
i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F);
|
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.l, i);
|
|
|
|
}
|
|
|
|
} else if (this.n()) {
|
|
|
|
if (d1 > 0.0D) {
|
|
|
|
this.a(StatisticList.n, (int) Math.round(d1 * 100.0D));
|
|
|
|
}
|
|
|
|
} else if (this.onGround) {
|
|
|
|
i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F);
|
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.k, i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F);
|
|
|
|
if (i > 25) {
|
|
|
|
this.a(StatisticList.o, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(float f) {
|
|
|
|
if (f >= 2.0F) {
|
|
|
|
this.a(StatisticList.m, (int) Math.round((double) f * 100.0D));
|
|
|
|
}
|
|
|
|
|
|
|
|
super.a(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void J() {}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|