2011-01-29 22:50:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
import java.util.Collection;
|
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
|
2012-12-22 19:46:24 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
2011-02-22 01:43:12 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftItem;
|
2013-03-02 07:15:22 +01:00
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2011-02-11 22:49:51 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2011-11-29 08:10:05 +01:00
|
|
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
2011-04-07 20:26:51 +02:00
|
|
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
|
|
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
2011-02-11 22:49:51 +01:00
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
2013-03-02 07:15:22 +01:00
|
|
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public abstract class EntityHuman extends EntityLiving implements ICommandListener {
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public PlayerInventory inventory = new PlayerInventory(this);
|
2012-07-29 09:33:13 +02:00
|
|
|
private InventoryEnderChest enderChest = new InventoryEnderChest();
|
2011-01-29 22:50:29 +01:00
|
|
|
public Container defaultContainer;
|
|
|
|
public Container activeContainer;
|
2011-09-15 18:36:27 +02:00
|
|
|
protected FoodMetaData foodData = new FoodMetaData();
|
2013-07-01 13:03:00 +02:00
|
|
|
protected int br;
|
|
|
|
public float bs;
|
|
|
|
public float bt;
|
|
|
|
protected final String name;
|
|
|
|
public int bv;
|
|
|
|
public double bw;
|
|
|
|
public double bx;
|
|
|
|
public double by;
|
|
|
|
public double bz;
|
|
|
|
public double bA;
|
|
|
|
public double bB;
|
2011-04-07 20:26:51 +02:00
|
|
|
// CraftBukkit start
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean sleeping; // protected -> public
|
2011-04-11 20:48:31 +02:00
|
|
|
public boolean fauxSleeping;
|
2011-06-09 15:44:25 +02:00
|
|
|
public String spawnWorld = "";
|
2012-02-29 22:31:04 +01:00
|
|
|
|
2012-12-22 19:46:24 +01:00
|
|
|
@Override
|
|
|
|
public CraftHumanEntity getBukkitEntity() {
|
|
|
|
return (CraftHumanEntity) super.getBukkitEntity();
|
2012-02-29 22:31:04 +01:00
|
|
|
}
|
2011-04-07 20:26:51 +02:00
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public ChunkCoordinates bD;
|
2012-01-12 12:02:39 +01:00
|
|
|
public int sleepTicks; // CraftBukkit - private -> public
|
2013-07-01 13:03:00 +02:00
|
|
|
public float bE;
|
|
|
|
public float bF;
|
2011-04-20 22:47:26 +02:00
|
|
|
private ChunkCoordinates c;
|
2012-10-25 05:53:23 +02:00
|
|
|
private boolean d;
|
|
|
|
private ChunkCoordinates e;
|
2011-09-15 18:36:27 +02:00
|
|
|
public PlayerAbilities abilities = new PlayerAbilities();
|
2012-01-19 17:06:27 +01:00
|
|
|
public int oldLevel = -1; // CraftBukkit
|
2011-11-30 00:17:43 +01:00
|
|
|
public int expLevel;
|
2011-09-15 02:23:52 +02:00
|
|
|
public int expTotal;
|
2011-11-30 00:17:43 +01:00
|
|
|
public float exp;
|
2012-10-25 05:53:23 +02:00
|
|
|
private ItemStack f;
|
|
|
|
private int g;
|
2013-07-01 13:03:00 +02:00
|
|
|
protected float bK = 0.1F;
|
|
|
|
protected float bL = 0.02F;
|
|
|
|
private int h;
|
|
|
|
public EntityFishingHook hookedFish;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public EntityHuman(World world, String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
super(world);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.name = s;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic, this);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
this.height = 1.62F;
|
2011-04-20 19:05:14 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.ba = 180.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.maxFireTicks = 20;
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected void ay() {
|
|
|
|
super.ay();
|
|
|
|
this.aW().b(GenericAttributes.e).setValue(1.0D);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.datawatcher.a(16, Byte.valueOf((byte) 0));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.datawatcher.a(17, Float.valueOf(0.0F));
|
2012-11-06 13:05:28 +01:00
|
|
|
this.datawatcher.a(18, Integer.valueOf(0));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public boolean bq() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.f != null;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void bs() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.f != null) {
|
|
|
|
this.f.b(this.world, this, this.g);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
this.bt();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void bt() {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.f = null;
|
|
|
|
this.g = 0;
|
2011-09-15 02:23:52 +02:00
|
|
|
if (!this.world.isStatic) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.e(false);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-27 11:40:05 +02:00
|
|
|
public boolean isBlocking() {
|
2013-07-09 01:43:37 +02:00
|
|
|
return this.bq() && Item.byId[this.f.id].c_(this.f) == EnumAnimation.BLOCK;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void l_() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.f != null) {
|
2011-09-15 02:23:52 +02:00
|
|
|
ItemStack itemstack = this.inventory.getItemInHand();
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (itemstack == this.f) {
|
|
|
|
if (this.g <= 25 && this.g % 4 == 0) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(itemstack, 5);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (--this.g == 0 && !this.world.isStatic) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.n();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.bt();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (this.bv > 0) {
|
|
|
|
--this.bv;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isSleeping()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
++this.sleepTicks;
|
|
|
|
if (this.sleepTicks > 100) {
|
|
|
|
this.sleepTicks = 100;
|
|
|
|
}
|
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
if (!this.world.isStatic) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.h()) {
|
2011-05-31 15:55:45 +02:00
|
|
|
this.a(true, true, false);
|
2013-04-27 11:40:05 +02:00
|
|
|
} else if (this.world.v()) {
|
2011-05-31 15:55:45 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
super.l_();
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.a(this)) {
|
2011-09-24 23:03:31 +02:00
|
|
|
this.closeInventory();
|
2011-01-29 22:50:29 +01:00
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
if (this.isBurning() && this.abilities.isInvulnerable) {
|
2011-11-30 00:17:43 +01:00
|
|
|
this.extinguish();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bw = this.bz;
|
|
|
|
this.bx = this.bA;
|
|
|
|
this.by = this.bB;
|
|
|
|
double d0 = this.locX - this.bz;
|
|
|
|
double d1 = this.locY - this.bA;
|
|
|
|
double d2 = this.locZ - this.bB;
|
2011-01-29 22:50:29 +01:00
|
|
|
double d3 = 10.0D;
|
|
|
|
|
|
|
|
if (d0 > d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bw = this.bz = this.locX;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d2 > d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.by = this.bB = this.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d1 > d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bx = this.bA = this.locY;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d0 < -d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bw = this.bz = this.locX;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d2 < -d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.by = this.bB = this.locZ;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d1 < -d3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bx = this.bA = this.locY;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bz += d0 * 0.25D;
|
|
|
|
this.bB += d2 * 0.25D;
|
|
|
|
this.bA += d1 * 0.25D;
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.k, 1);
|
|
|
|
if (this.vehicle == null) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.e = null;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
2011-09-15 18:36:27 +02:00
|
|
|
this.foodData.a(this);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int y() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.abilities.isInvulnerable ? 0 : 80;
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public int ab() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
public void makeSound(String s, float f, float f1) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.world.a(this, s, f, f1);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void c(ItemStack itemstack, int i) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemstack.o() == EnumAnimation.DRINK) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemstack.o() == EnumAnimation.EAT) {
|
2011-09-15 02:23:52 +02:00
|
|
|
for (int j = 0; j < i; ++j) {
|
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-09-15 02:23:52 +02: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-09-15 02:23:52 +02: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);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("random.eat", 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void n() {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.f != null) {
|
|
|
|
this.c(this.f, 16);
|
|
|
|
int i = this.f.count;
|
2013-03-02 07:15:22 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f);
|
|
|
|
PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
// Update client
|
|
|
|
if (this instanceof EntityPlayer) {
|
|
|
|
((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Plugin modified the item, process it but don't remove it
|
|
|
|
if (!craftItem.equals(event.getItem())) {
|
|
|
|
CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);
|
|
|
|
|
|
|
|
// Update client
|
|
|
|
if (this instanceof EntityPlayer) {
|
|
|
|
((EntityPlayer) this).playerConnection.sendPacket(new Packet103SetSlot((byte) 0, activeContainer.a((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
ItemStack itemstack = this.f.b(this.world, this);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (itemstack != this.f || itemstack != null && itemstack.count != i) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.inventory.items[this.inventory.itemInHandIndex] = itemstack;
|
|
|
|
if (itemstack.count == 0) {
|
|
|
|
this.inventory.items[this.inventory.itemInHandIndex] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
this.bt();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected boolean bb() {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.getHealth() <= 0.0F || this.isSleeping();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
// CraftBukkit - protected -> public
|
|
|
|
public void closeInventory() {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.activeContainer = this.defaultContainer;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void mount(Entity entity) {
|
|
|
|
// CraftBukkit start - mirror Entity mount changes
|
|
|
|
this.setPassengerOf(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPassengerOf(Entity entity) {
|
|
|
|
// CraftBukkit end
|
2013-07-01 13:03:00 +02:00
|
|
|
if (this.vehicle != null && entity == null) {
|
2013-07-13 00:45:42 +02:00
|
|
|
// CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent
|
|
|
|
Entity originalVehicle = this.vehicle;
|
|
|
|
// First statement moved down, second statement handled in parent method.
|
|
|
|
/*
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
this.l(this.vehicle);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.vehicle != null) {
|
|
|
|
this.vehicle.passenger = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.vehicle = null;
|
2013-07-13 00:45:42 +02:00
|
|
|
*/
|
|
|
|
super.setPassengerOf(entity);
|
|
|
|
if (!this.world.isStatic && this.vehicle == null) {
|
|
|
|
this.l(originalVehicle);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2013-03-13 23:33:27 +01:00
|
|
|
} else {
|
|
|
|
super.setPassengerOf(entity); // CraftBukkit - call new parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void U() {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.world.isStatic && this.isSneaking()) {
|
|
|
|
this.mount((Entity) null);
|
|
|
|
this.setSneaking(false);
|
|
|
|
} else {
|
|
|
|
double d0 = this.locX;
|
|
|
|
double d1 = this.locY;
|
|
|
|
double d2 = this.locZ;
|
|
|
|
float f = this.yaw;
|
|
|
|
float f1 = this.pitch;
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
super.U();
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bs = this.bt;
|
|
|
|
this.bt = 0.0F;
|
|
|
|
this.k(this.locX - d0, this.locY - d1, this.locZ - d2);
|
|
|
|
if (this.vehicle instanceof EntityPig) {
|
|
|
|
this.pitch = f1;
|
|
|
|
this.yaw = f;
|
|
|
|
this.aN = ((EntityPig) this.vehicle).aN;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected void bk() {
|
|
|
|
super.bk();
|
|
|
|
this.aV();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (this.br > 0) {
|
|
|
|
--this.br;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 19:34:40 +02:00
|
|
|
if (this.world.difficulty == 0 && this.getHealth() < this.getMaxHealth() && this.world.getGameRules().getBoolean("naturalRegeneration") && this.ticksLived % 20 * 12 == 0) {
|
2011-09-20 22:31:43 +02:00
|
|
|
// CraftBukkit - added regain reason of "REGEN" for filtering purposes.
|
2013-07-01 13:03:00 +02:00
|
|
|
this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.inventory.k();
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bs = this.bt;
|
2012-10-25 05:53:23 +02:00
|
|
|
super.c();
|
2013-07-09 01:43:37 +02:00
|
|
|
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d);
|
2013-07-01 13:03:00 +02:00
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
2013-07-09 01:43:37 +02:00
|
|
|
attributeinstance.setValue((double) this.abilities.b());
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.aR = this.bL;
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.isSprinting()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.aR = (float) ((double) this.aR + (double) this.bL * 0.3D);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
this.i((float) attributeinstance.getValue());
|
2012-01-14 21:03:48 +01:00
|
|
|
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - Math -> TrigMath
|
2012-07-22 08:18:00 +02:00
|
|
|
float f1 = (float) org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f > 0.1F) {
|
|
|
|
f = 0.1F;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.onGround || this.getHealth() <= 0.0F) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f = 0.0F;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (this.onGround || this.getHealth() <= 0.0F) {
|
2011-01-29 22:50:29 +01:00
|
|
|
f1 = 0.0F;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bt += (f - this.bt) * 0.4F;
|
|
|
|
this.aK += (f1 - this.aK) * 0.8F;
|
|
|
|
if (this.getHealth() > 0.0F) {
|
|
|
|
AxisAlignedBB axisalignedbb = null;
|
|
|
|
|
|
|
|
if (this.vehicle != null && !this.vehicle.dead) {
|
|
|
|
axisalignedbb = this.boundingBox.a(this.vehicle.boundingBox).grow(1.0D, 0.0D, 1.0D);
|
|
|
|
} else {
|
|
|
|
axisalignedbb = this.boundingBox.grow(1.0D, 0.5D, 1.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
List list = this.world.getEntities(this, axisalignedbb);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (list != null) {
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity = (Entity) list.get(i);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (!entity.dead) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.r(entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
private void r(Entity entity) {
|
2013-03-13 23:33:27 +01:00
|
|
|
entity.b_(this);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getScore() {
|
|
|
|
return this.datawatcher.getInt(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setScore(int i) {
|
|
|
|
this.datawatcher.watch(18, Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addScore(int i) {
|
|
|
|
int j = this.getScore();
|
|
|
|
|
|
|
|
this.datawatcher.watch(18, Integer.valueOf(j + i));
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public void die(DamageSource damagesource) {
|
|
|
|
super.die(damagesource);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.2F, 0.2F);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition(this.locX, this.locY, this.locZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.motY = 0.10000000149011612D;
|
|
|
|
if (this.name.equals("Notch")) {
|
|
|
|
this.a(new ItemStack(Item.APPLE, 1), true);
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!this.world.getGameRules().getBoolean("keepInventory")) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.inventory.m();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (damagesource != null) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.motX = (double) (-MathHelper.cos((this.aA + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
|
|
|
|
this.motZ = (double) (-MathHelper.sin((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-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.y, 1);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void b(Entity entity, int i) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.addScore(i);
|
2013-03-22 22:21:33 +01:00
|
|
|
// CraftBukkit - Get our scores instead
|
|
|
|
Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getLocalizedName(), new java.util.ArrayList<ScoreboardScore>());
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (entity instanceof EntityHuman) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.A, 1);
|
2013-03-22 22:21:33 +01:00
|
|
|
// CraftBukkit - Get our scores instead
|
|
|
|
this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getLocalizedName(), collection);
|
2011-03-31 22:40:00 +02:00
|
|
|
} else {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.z, 1);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
Iterator iterator = collection.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
2013-03-22 22:21:33 +01:00
|
|
|
ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2013-03-20 21:09:23 +01:00
|
|
|
scoreboardscore.incrementScore();
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public EntityItem a(boolean flag) {
|
2012-12-20 05:03:52 +01:00
|
|
|
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public EntityItem drop(ItemStack itemstack) {
|
|
|
|
return this.a(itemstack, false);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public EntityItem a(ItemStack itemstack, boolean flag) {
|
|
|
|
if (itemstack == null) {
|
|
|
|
return null;
|
2013-07-01 13:03:00 +02:00
|
|
|
} else if (itemstack.count == 0) {
|
|
|
|
return null;
|
2012-03-01 11:49:23 +01:00
|
|
|
} else {
|
2012-02-29 22:31:04 +01:00
|
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entityitem.pickupDelay = 40;
|
2011-01-29 22:50:29 +01:00
|
|
|
float f = 0.1F;
|
|
|
|
float f1;
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
f1 = this.random.nextFloat() * 0.5F;
|
|
|
|
float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
|
|
|
|
entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
|
2011-01-29 22:50:29 +01:00
|
|
|
entityitem.motY = 0.20000000298023224D;
|
|
|
|
} else {
|
|
|
|
f = 0.3F;
|
2011-04-20 19:05:14 +02:00
|
|
|
entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
|
|
|
|
entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
|
2011-01-29 22:50:29 +01:00
|
|
|
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();
|
2011-06-27 00:25:01 +02:00
|
|
|
CraftItem drop = new CraftItem(this.world.getServer(), entityitem);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-11 22:49:51 +01:00
|
|
|
PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-11 22:49:51 +01:00
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
2011-08-23 20:38:49 +02:00
|
|
|
player.getInventory().addItem(drop.getItemStack());
|
2012-03-01 11:49:23 +01:00
|
|
|
return null;
|
2011-02-11 22:49:51 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.a(entityitem);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.v, 1);
|
2012-03-01 11:49:23 +01:00
|
|
|
return entityitem;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(EntityItem entityitem) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.world.addEntity(entityitem);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float a(Block block, boolean flag) {
|
2011-01-29 22:50:29 +01:00
|
|
|
float f = this.inventory.a(block);
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (f > 1.0F) {
|
|
|
|
int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this);
|
|
|
|
ItemStack itemstack = this.inventory.getItemInHand();
|
2012-12-20 05:03:52 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (i > 0 && itemstack != null) {
|
|
|
|
float f1 = (float) (i * i + 1);
|
|
|
|
|
|
|
|
if (!itemstack.b(block) && f <= 1.0F) {
|
|
|
|
f += f1 * 0.08F;
|
|
|
|
} else {
|
|
|
|
f += f1;
|
|
|
|
}
|
2012-12-20 05:03:52 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.hasEffect(MobEffectList.FASTER_DIG)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
f *= 1.0F + (float) (this.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.hasEffect(MobEffectList.SLOWER_DIG)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
f *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.a(Material.WATER) && !EnchantmentManager.hasWaterWorkerEnchantment(this)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
f /= 5.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.onGround) {
|
2012-07-29 09:33:13 +02:00
|
|
|
f /= 5.0F;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
return f;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean a(Block block) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.inventory.b(block);
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
NBTTagList nbttaglist = nbttagcompound.getList("Inventory");
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.inventory.b(nbttaglist);
|
2012-12-20 05:03:52 +01:00
|
|
|
this.inventory.itemInHandIndex = nbttagcompound.getInt("SelectedItemSlot");
|
2011-11-30 00:17:43 +01:00
|
|
|
this.sleeping = nbttagcompound.getBoolean("Sleeping");
|
|
|
|
this.sleepTicks = nbttagcompound.getShort("SleepTimer");
|
|
|
|
this.exp = nbttagcompound.getFloat("XpP");
|
|
|
|
this.expLevel = nbttagcompound.getInt("XpLevel");
|
|
|
|
this.expTotal = nbttagcompound.getInt("XpTotal");
|
2012-11-06 13:05:28 +01:00
|
|
|
this.setScore(nbttagcompound.getInt("Score"));
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.sleeping) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bD = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
|
2011-03-31 22:40:00 +02:00
|
|
|
this.a(true, true, false);
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
// CraftBukkit start
|
2011-06-16 05:24:31 +02:00
|
|
|
this.spawnWorld = nbttagcompound.getString("SpawnWorld");
|
2011-09-25 02:36:05 +02:00
|
|
|
if ("".equals(spawnWorld)) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.spawnWorld = this.world.getServer().getWorlds().get(0).getName();
|
2011-06-16 05:24:31 +02:00
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
// CraftBukkit end
|
2011-06-08 19:40:40 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c = new ChunkCoordinates(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.d = nbttagcompound.getBoolean("SpawnForced");
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-15 18:36:27 +02:00
|
|
|
this.foodData.a(nbttagcompound);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.abilities.b(nbttagcompound);
|
2012-07-29 09:33:13 +02:00
|
|
|
if (nbttagcompound.hasKey("EnderItems")) {
|
|
|
|
NBTTagList nbttaglist1 = nbttagcompound.getList("EnderItems");
|
|
|
|
|
|
|
|
this.enderChest.a(nbttaglist1);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.set("Inventory", this.inventory.a(new NBTTagList()));
|
2012-12-20 05:03:52 +01:00
|
|
|
nbttagcompound.setInt("SelectedItemSlot", this.inventory.itemInHandIndex);
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setBoolean("Sleeping", this.sleeping);
|
|
|
|
nbttagcompound.setShort("SleepTimer", (short) this.sleepTicks);
|
|
|
|
nbttagcompound.setFloat("XpP", this.exp);
|
|
|
|
nbttagcompound.setInt("XpLevel", this.expLevel);
|
|
|
|
nbttagcompound.setInt("XpTotal", this.expTotal);
|
2012-11-06 13:05:28 +01:00
|
|
|
nbttagcompound.setInt("Score", this.getScore());
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.c != null) {
|
|
|
|
nbttagcompound.setInt("SpawnX", this.c.x);
|
|
|
|
nbttagcompound.setInt("SpawnY", this.c.y);
|
|
|
|
nbttagcompound.setInt("SpawnZ", this.c.z);
|
2012-10-25 05:53:23 +02:00
|
|
|
nbttagcompound.setBoolean("SpawnForced", this.d);
|
2011-10-01 19:37:20 +02:00
|
|
|
nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-15 18:36:27 +02:00
|
|
|
this.foodData.b(nbttagcompound);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.abilities.a(nbttagcompound);
|
2013-03-13 23:33:27 +01:00
|
|
|
nbttagcompound.set("EnderItems", this.enderChest.h());
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void openContainer(IInventory iinventory) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void openHopper(TileEntityHopper tileentityhopper) {}
|
|
|
|
|
|
|
|
public void openMinecartHopper(EntityMinecartHopper entityminecarthopper) {}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void startEnchanting(int i, int j, int k, String s) {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void openAnvil(int i, int j, int k) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void startCrafting(int i, int j, int k) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public float getHeadHeight() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return 0.12F;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void d_() {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.height = 1.62F;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isInvulnerable()) {
|
|
|
|
return false;
|
|
|
|
} else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.aV = 0;
|
|
|
|
if (this.getHealth() <= 0.0F) {
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (this.isSleeping() && !this.world.isStatic) {
|
|
|
|
this.a(true, true, false);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (damagesource.p()) {
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.world.difficulty == 0) {
|
2013-07-01 13:03:00 +02:00
|
|
|
return false; // CraftBukkit - f = 0 -> return false
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.world.difficulty == 1) {
|
2013-07-01 13:03:00 +02:00
|
|
|
f = f / 2.0F + 1.0F;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-02-24 13:49:48 +01:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.world.difficulty == 3) {
|
2013-07-01 13:03:00 +02:00
|
|
|
f = f * 3.0F / 2.0F;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (false && f == 0.0F) { // CraftBukkit - Don't filter out 0 damage
|
2011-09-15 02:23:52 +02:00
|
|
|
return false;
|
2012-07-22 08:18:00 +02:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
Entity entity = damagesource.getEntity();
|
2011-06-27 00:25:01 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) {
|
|
|
|
entity = ((EntityArrow) entity).shooter;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(StatisticList.x, Math.round(f * 10.0F));
|
|
|
|
return super.damageEntity(damagesource, f);
|
2012-07-22 08:18:00 +02:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2013-04-12 06:12:45 +02:00
|
|
|
// CraftBukkit start - Change to check OTHER player's scoreboard team according to API
|
|
|
|
// To summarize this method's logic, it's "Can parameter hurt this"
|
2013-03-22 22:21:33 +01:00
|
|
|
org.bukkit.scoreboard.Team team;
|
2013-04-12 06:12:45 +02:00
|
|
|
if (entityhuman instanceof EntityPlayer) {
|
|
|
|
EntityPlayer thatPlayer = (EntityPlayer) entityhuman;
|
|
|
|
team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
|
2013-03-22 22:21:33 +01:00
|
|
|
if (team == null || team.allowFriendlyFire()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// This should never be called, but is implemented anyway
|
2013-04-12 06:12:45 +02:00
|
|
|
org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.name);
|
|
|
|
team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
|
2013-03-22 22:21:33 +01:00
|
|
|
if (team == null || team.allowFriendlyFire()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-04-12 06:12:45 +02:00
|
|
|
if (this instanceof EntityPlayer) {
|
|
|
|
return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity());
|
2013-03-22 22:21:33 +01:00
|
|
|
}
|
2013-04-12 06:12:45 +02:00
|
|
|
return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.name));
|
2013-03-22 22:21:33 +01:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void h(float f) {
|
|
|
|
this.inventory.a(f);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public int aP() {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.inventory.l();
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public float bw() {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = 0;
|
|
|
|
ItemStack[] aitemstack = this.inventory.armor;
|
|
|
|
int j = aitemstack.length;
|
|
|
|
|
|
|
|
for (int k = 0; k < j; ++k) {
|
|
|
|
ItemStack itemstack = aitemstack[k];
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
|
|
|
++i;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
return (float) i / (float) this.inventory.armor.length;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void d(DamageSource damagesource, float f) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!this.isInvulnerable()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) {
|
|
|
|
f = (1.0F + f) * 0.5F;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
f = this.b(damagesource, f);
|
|
|
|
f = this.c(damagesource, f);
|
|
|
|
float f1 = f;
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
f = Math.max(f - this.bm(), 0.0F);
|
|
|
|
this.m(this.bm() - (f1 - f));
|
2013-07-01 13:03:00 +02:00
|
|
|
if (f != 0.0F) {
|
|
|
|
this.a(damagesource.f());
|
|
|
|
float f2 = this.getHealth();
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.setHealth(this.getHealth() - f);
|
2013-07-09 01:43:37 +02:00
|
|
|
this.aQ().a(damagesource, f2, f);
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void openFurnace(TileEntityFurnace tileentityfurnace) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void openDispenser(TileEntityDispenser tileentitydispenser) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void a(TileEntity tileentity) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void openBeacon(TileEntityBeacon tileentitybeacon) {}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void openTrade(IMerchant imerchant, String s) {}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void c(ItemStack itemstack) {}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean p(Entity entity) {
|
2013-07-09 01:43:37 +02:00
|
|
|
ItemStack itemstack = this.bx();
|
2013-07-01 13:03:00 +02:00
|
|
|
ItemStack itemstack1 = itemstack != null ? itemstack.cloneItemStack() : null;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!entity.c(this)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (itemstack != null && entity instanceof EntityLiving) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.abilities.canInstantlyBuild) {
|
2013-07-01 13:03:00 +02:00
|
|
|
itemstack = itemstack1;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (itemstack.a(this, (EntityLiving) entity)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit - bypass infinite items; <= 0 -> == 0
|
|
|
|
if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.by();
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
return false;
|
2013-07-01 13:03:00 +02:00
|
|
|
} else {
|
2013-07-09 01:43:37 +02:00
|
|
|
if (itemstack != null && itemstack == this.bx()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (itemstack.count <= 0 && !this.abilities.canInstantlyBuild) {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.by();
|
2013-07-01 13:03:00 +02:00
|
|
|
} else if (itemstack.count < itemstack1.count && this.abilities.canInstantlyBuild) {
|
|
|
|
itemstack.count = itemstack1.count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public ItemStack bx() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.inventory.getItemInHand();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void by() {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public double W() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return (double) (this.height - 0.5F);
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void attack(Entity entity) {
|
2013-07-09 01:43:37 +02:00
|
|
|
if (entity.ap()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!entity.i(this)) {
|
2013-07-09 01:43:37 +02:00
|
|
|
float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue();
|
2013-07-01 13:03:00 +02:00
|
|
|
int i = 0;
|
|
|
|
float f1 = 0.0F;
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
2013-07-01 13:03:00 +02:00
|
|
|
f1 = EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity);
|
|
|
|
i += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isSprinting()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
++i;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (f > 0.0F || f1 > 0.0F) {
|
|
|
|
boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.e() && !this.G() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (flag && f > 0.0F) {
|
|
|
|
f *= 1.5F;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
f += f1;
|
2012-11-06 13:05:28 +01:00
|
|
|
boolean flag1 = false;
|
2013-07-01 13:03:00 +02:00
|
|
|
int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (entity instanceof EntityLiving && j > 0 && !entity.isBurning()) {
|
2012-11-06 13:05:28 +01:00
|
|
|
flag1 = true;
|
|
|
|
entity.setOnFire(1);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
boolean flag2 = entity.damageEntity(DamageSource.playerAttack(this), f);
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
// CraftBukkit start - Return when the damage fails so that the item will not lose durability
|
|
|
|
if (!flag2) {
|
2012-11-16 02:20:45 +01:00
|
|
|
if (flag1) {
|
|
|
|
entity.extinguish();
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
return;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
if (flag2) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (i > 0) {
|
|
|
|
entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F));
|
2012-11-06 13:05:28 +01:00
|
|
|
this.motX *= 0.6D;
|
|
|
|
this.motZ *= 0.6D;
|
|
|
|
this.setSprinting(false);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (flag) {
|
|
|
|
this.b(entity);
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (f1 > 0.0F) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.c(entity);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (f >= 18.0F) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.a((Statistic) AchievementList.E);
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.k(entity);
|
2012-12-20 05:03:52 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
EnchantmentThorns.a(this, (EntityLiving) entity, this.random);
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
ItemStack itemstack = this.bx();
|
2013-03-13 23:33:27 +01:00
|
|
|
Object object = entity;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (entity instanceof EntityComplexPart) {
|
|
|
|
IComplex icomplex = ((EntityComplexPart) entity).owner;
|
|
|
|
|
|
|
|
if (icomplex != null && icomplex instanceof EntityLiving) {
|
|
|
|
object = (EntityLiving) icomplex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemstack != null && object instanceof EntityLiving) {
|
|
|
|
itemstack.a((EntityLiving) object, this);
|
2012-11-06 13:05:28 +01:00
|
|
|
// CraftBukkit - bypass infinite items; <= 0 -> == 0
|
|
|
|
if (itemstack.count == 0) {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.by();
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-09 00:46:07 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(StatisticList.w, Math.round(f * 10.0F));
|
|
|
|
if (j > 0 && flag2) {
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
2013-07-01 13:03:00 +02:00
|
|
|
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
|
2012-11-06 13:05:28 +01:00
|
|
|
org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
|
|
|
|
|
|
|
if (!combustEvent.isCancelled()) {
|
|
|
|
entity.setOnFire(combustEvent.getDuration());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
} else if (flag1) {
|
|
|
|
entity.extinguish();
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-11-29 08:10:05 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.3F);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(Entity entity) {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void c(Entity entity) {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void die() {
|
|
|
|
super.die();
|
2012-11-06 13:05:28 +01:00
|
|
|
this.defaultContainer.b(this);
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.activeContainer != null) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.activeContainer.b(this);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public boolean inBlock() {
|
|
|
|
return !this.sleeping && super.inBlock();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public EnumBedResult a(int i, int j, int k) {
|
2011-05-31 15:55:45 +02:00
|
|
|
if (!this.world.isStatic) {
|
2011-11-30 00:17:43 +01:00
|
|
|
if (this.isSleeping() || !this.isAlive()) {
|
|
|
|
return EnumBedResult.OTHER_PROBLEM;
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
if (!this.world.worldProvider.d()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.NOT_POSSIBLE_HERE;
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
|
|
|
|
2013-04-27 11:40:05 +02:00
|
|
|
if (this.world.v()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.NOT_POSSIBLE_NOW;
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
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-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.TOO_FAR_AWAY;
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
double d0 = 8.0D;
|
|
|
|
double d1 = 5.0D;
|
2012-07-29 09:33:13 +02:00
|
|
|
List list = this.world.a(EntityMonster.class, AxisAlignedBB.a().a((double) i - d0, (double) j - d1, (double) k - d0, (double) i + d0, (double) j + d1, (double) k + d0));
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
if (!list.isEmpty()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.NOT_SAFE;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
if (this.af()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.mount((Entity) null);
|
|
|
|
}
|
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (this.getBukkitEntity() instanceof Player) {
|
|
|
|
Player player = (Player) this.getBukkitEntity();
|
2011-06-27 00:25:01 +02:00
|
|
|
org.bukkit.block.Block bed = this.world.getWorld().getBlockAt(i, j, k);
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
if (event.isCancelled()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.OTHER_PROBLEM;
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.2F, 0.2F);
|
2011-05-31 15:55:45 +02:00
|
|
|
this.height = 0.2F;
|
|
|
|
if (this.world.isLoaded(i, j, k)) {
|
|
|
|
int l = this.world.getData(i, j, k);
|
2013-03-13 23:33:27 +01:00
|
|
|
int i1 = BlockBed.j(l);
|
2011-05-31 15:55:45 +02:00
|
|
|
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;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-05-31 15:55:45 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.t(i1);
|
2011-05-31 15:55:45 +02:00
|
|
|
this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1));
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2011-05-31 15:55:45 +02:00
|
|
|
this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F));
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-05-31 15:55:45 +02:00
|
|
|
|
|
|
|
this.sleeping = true;
|
|
|
|
this.sleepTicks = 0;
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bD = new ChunkCoordinates(i, j, k);
|
2011-05-31 15:55:45 +02:00
|
|
|
this.motX = this.motZ = this.motY = 0.0D;
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
this.world.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
return EnumBedResult.OK;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
private void t(int i) {
|
|
|
|
this.bE = 0.0F;
|
|
|
|
this.bF = 0.0F;
|
2011-02-23 03:37:56 +01:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bF = -1.8F;
|
2011-02-23 03:37:56 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bE = 1.8F;
|
2011-02-23 03:37:56 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bF = 1.8F;
|
2011-02-23 03:37:56 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bE = -1.8F;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void a(boolean flag, boolean flag1, boolean flag2) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.6F, 1.8F);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.d_();
|
|
|
|
ChunkCoordinates chunkcoordinates = this.bD;
|
|
|
|
ChunkCoordinates chunkcoordinates1 = this.bD;
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) {
|
|
|
|
BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false);
|
2012-07-29 09:33:13 +02:00
|
|
|
chunkcoordinates1 = BlockBed.b(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0);
|
2011-03-31 22:40:00 +02:00
|
|
|
if (chunkcoordinates1 == null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.setPosition((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F));
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.sleeping = false;
|
|
|
|
if (!this.world.isStatic && flag1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.world.everyoneSleeping();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-07 20:26:51 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (this.getBukkitEntity() instanceof Player) {
|
|
|
|
Player player = (Player) this.getBukkitEntity();
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-04-12 02:07:20 +02:00
|
|
|
org.bukkit.block.Block bed;
|
|
|
|
if (chunkcoordinates != null) {
|
2011-06-27 00:25:01 +02:00
|
|
|
bed = this.world.getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
|
2011-04-12 02:07:20 +02:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
bed = this.world.getWorld().getBlockAt(player.getLocation());
|
2011-04-12 02:07:20 +02:00
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-04-07 20:26:51 +02:00
|
|
|
PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-04-07 20:26:51 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
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) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.setRespawnPosition(this.bD, false);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
private boolean h() {
|
|
|
|
return this.world.getTypeId(this.bD.x, this.bD.y, this.bD.z) == Block.BED.id;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates, boolean flag) {
|
2013-07-01 13:03:00 +02:00
|
|
|
IChunkProvider ichunkprovider = world.L();
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4);
|
|
|
|
ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4);
|
|
|
|
ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4);
|
|
|
|
ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4);
|
2012-11-06 13:05:28 +01:00
|
|
|
if (world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) {
|
2012-07-29 09:33:13 +02:00
|
|
|
ChunkCoordinates chunkcoordinates1 = BlockBed.b(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0);
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
return chunkcoordinates1;
|
2012-11-06 13:05:28 +01:00
|
|
|
} else {
|
|
|
|
Material material = world.getMaterial(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
|
|
|
|
Material material1 = world.getMaterial(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z);
|
|
|
|
boolean flag1 = !material.isBuildable() && !material.isLiquid();
|
|
|
|
boolean flag2 = !material1.isBuildable() && !material1.isLiquid();
|
|
|
|
|
|
|
|
return flag && flag1 && flag2 ? chunkcoordinates : null;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isSleeping() {
|
2011-03-31 22:40:00 +02:00
|
|
|
return this.sleeping;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isDeeplySleeping() {
|
2011-02-23 03:37:56 +01:00
|
|
|
return this.sleeping && this.sleepTicks >= 100;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected void b(int i, boolean flag) {
|
|
|
|
byte b0 = this.datawatcher.getByte(16);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1 << i)));
|
|
|
|
} else {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & ~(1 << i))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void a(String s) {}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public ChunkCoordinates getBed() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.c;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean isRespawnForced() {
|
|
|
|
return this.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRespawnPosition(ChunkCoordinates chunkcoordinates, boolean flag) {
|
2011-03-31 22:40:00 +02:00
|
|
|
if (chunkcoordinates != null) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c = new ChunkCoordinates(chunkcoordinates);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.d = flag;
|
|
|
|
this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
|
2011-03-31 22:40:00 +02:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c = null;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.d = false;
|
2012-12-10 00:37:37 +01:00
|
|
|
this.spawnWorld = ""; // CraftBukkit
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(Statistic statistic) {
|
|
|
|
this.a(statistic, 1);
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void a(Statistic statistic, int i) {}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected void bd() {
|
|
|
|
super.bd();
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.u, 1);
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.isSprinting()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.8F);
|
2011-09-15 02:23:52 +02:00
|
|
|
} else {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.2F);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void e(float f, float f1) {
|
2011-03-31 22:40:00 +02:00
|
|
|
double d0 = this.locX;
|
|
|
|
double d1 = this.locY;
|
|
|
|
double d2 = this.locZ;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.abilities.isFlying && this.vehicle == null) {
|
2011-09-15 02:23:52 +02:00
|
|
|
double d3 = this.motY;
|
2013-07-01 13:03:00 +02:00
|
|
|
float f2 = this.aR;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.aR = this.abilities.a();
|
2012-07-29 09:33:13 +02:00
|
|
|
super.e(f, f1);
|
2011-09-15 02:23:52 +02:00
|
|
|
this.motY = d3 * 0.6D;
|
2013-07-01 13:03:00 +02:00
|
|
|
this.aR = f2;
|
2011-09-15 02:23:52 +02:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
super.e(f, f1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
this.checkMovement(this.locX - d0, this.locY - d1, this.locZ - d2);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public float bf() {
|
|
|
|
return (float) this.getAttributeInstance(GenericAttributes.d).getValue();
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void checkMovement(double d0, double d1, double d2) {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.vehicle == null) {
|
|
|
|
int i;
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.a(Material.WATER)) {
|
2012-01-14 21:03:48 +01:00
|
|
|
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.q, i);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.015F * (float) i * 0.01F);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
} else if (this.G()) {
|
2012-01-14 21:03:48 +01:00
|
|
|
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.m, i);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.015F * (float) i * 0.01F);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2013-07-01 13:03:00 +02:00
|
|
|
} else if (this.e()) {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (d1 > 0.0D) {
|
|
|
|
this.a(StatisticList.o, (int) Math.round(d1 * 100.0D));
|
|
|
|
}
|
|
|
|
} else if (this.onGround) {
|
2012-01-14 21:03:48 +01:00
|
|
|
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
if (i > 0) {
|
|
|
|
this.a(StatisticList.l, i);
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.isSprinting()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.099999994F * (float) i * 0.01F);
|
2011-09-15 02:23:52 +02:00
|
|
|
} else {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.a(0.01F * (float) i * 0.01F);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
} else {
|
2012-01-14 21:03:48 +01:00
|
|
|
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
if (i > 25) {
|
|
|
|
this.a(StatisticList.p, i);
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void k(double d0, double d1, double d2) {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.vehicle != null) {
|
2012-01-14 21:03:48 +01:00
|
|
|
int i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
if (i > 0) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.vehicle instanceof EntityMinecartAbstract) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a(StatisticList.r, i);
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.e == null) {
|
|
|
|
this.e = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
|
|
|
|
} else if ((double) this.e.e(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) >= 1000000.0D) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.a((Statistic) AchievementList.q, 1);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
} else if (this.vehicle instanceof EntityBoat) {
|
|
|
|
this.a(StatisticList.s, i);
|
|
|
|
} else if (this.vehicle instanceof EntityPig) {
|
|
|
|
this.a(StatisticList.t, i);
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void b(float f) {
|
2011-09-15 18:36:27 +02:00
|
|
|
if (!this.abilities.canFly) {
|
2011-09-15 02:23:52 +02:00
|
|
|
if (f >= 2.0F) {
|
|
|
|
this.a(StatisticList.n, (int) Math.round((double) f * 100.0D));
|
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
super.b(f);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void a(EntityLiving entityliving) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (entityliving instanceof IMonster) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a((Statistic) AchievementList.s);
|
|
|
|
}
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void al() {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (!this.abilities.isFlying) {
|
2013-07-09 01:43:37 +02:00
|
|
|
super.al();
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public ItemStack o(int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.inventory.f(i);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void giveExp(int i) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.addScore(i);
|
2012-01-12 23:10:13 +01:00
|
|
|
int j = Integer.MAX_VALUE - this.expTotal;
|
|
|
|
|
|
|
|
if (i > j) {
|
|
|
|
i = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.exp += (float) i / (float) this.getExpToLevel();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
for (this.expTotal += i; this.exp >= 1.0F; this.exp /= (float) this.getExpToLevel()) {
|
|
|
|
this.exp = (this.exp - 1.0F) * (float) this.getExpToLevel();
|
2012-10-25 05:53:23 +02:00
|
|
|
this.levelDown(1);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void levelDown(int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.expLevel += i;
|
2011-11-30 00:17:43 +01:00
|
|
|
if (this.expLevel < 0) {
|
|
|
|
this.expLevel = 0;
|
2012-12-20 05:03:52 +01:00
|
|
|
this.exp = 0.0F;
|
|
|
|
this.expTotal = 0;
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (i > 0 && this.expLevel % 5 == 0 && (float) this.h < (float) this.ticksLived - 100.0F) {
|
|
|
|
float f = this.expLevel > 30 ? 1.0F : (float) this.expLevel / 30.0F;
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
this.world.makeSound(this, "random.levelup", f * 0.75F, 1.0F);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.h = this.ticksLived;
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public int getExpToLevel() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.expLevel >= 30 ? 62 + (this.expLevel - 30) * 7 : (this.expLevel >= 15 ? 17 + (this.expLevel - 15) * 3 : 17);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void a(float f) {
|
2011-09-15 18:36:27 +02:00
|
|
|
if (!this.abilities.isInvulnerable) {
|
2011-09-15 02:23:52 +02:00
|
|
|
if (!this.world.isStatic) {
|
2011-09-15 18:36:27 +02:00
|
|
|
this.foodData.a(f);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 18:36:27 +02:00
|
|
|
public FoodMetaData getFoodData() {
|
|
|
|
return this.foodData;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean g(boolean flag) {
|
2012-07-29 09:33:13 +02:00
|
|
|
return (flag || this.foodData.c()) && !this.abilities.isInvulnerable;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public boolean bI() {
|
2013-07-02 19:34:40 +02:00
|
|
|
return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ItemStack itemstack, int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (itemstack != this.f) {
|
|
|
|
this.f = itemstack;
|
|
|
|
this.g = i;
|
2011-09-15 02:23:52 +02:00
|
|
|
if (!this.world.isStatic) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.e(true);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean d(int i, int j, int k) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.abilities.mayBuild) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
int l = this.world.getTypeId(i, j, k);
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l > 0) {
|
2012-10-25 05:53:23 +02:00
|
|
|
Block block = Block.byId[l];
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (block.material.q()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
if (this.bx() != null) {
|
|
|
|
ItemStack itemstack = this.bx();
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
if (itemstack.b(block) || itemstack.a(block) > 1.0F) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
return false;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean a(int i, int j, int k, int l, ItemStack itemstack) {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.abilities.mayBuild ? true : (itemstack != null ? itemstack.z() : false);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getExpValue(EntityHuman entityhuman) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.world.getGameRules().getBoolean("keepInventory")) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
int i = this.expLevel * 7;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
return i > 100 ? 100 : i;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected boolean alwaysGivesExp() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public String getLocalizedName() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return this.name;
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void copyTo(EntityHuman entityhuman, boolean flag) {
|
|
|
|
if (flag) {
|
|
|
|
this.inventory.b(entityhuman.inventory);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.setHealth(entityhuman.getHealth());
|
2012-07-29 09:33:13 +02:00
|
|
|
this.foodData = entityhuman.foodData;
|
|
|
|
this.expLevel = entityhuman.expLevel;
|
|
|
|
this.expTotal = entityhuman.expTotal;
|
|
|
|
this.exp = entityhuman.exp;
|
2012-11-06 13:05:28 +01:00
|
|
|
this.setScore(entityhuman.getScore());
|
2013-03-13 23:33:27 +01:00
|
|
|
this.as = entityhuman.as;
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.world.getGameRules().getBoolean("keepInventory")) {
|
|
|
|
this.inventory.b(entityhuman.inventory);
|
|
|
|
this.expLevel = entityhuman.expLevel;
|
|
|
|
this.expTotal = entityhuman.expTotal;
|
|
|
|
this.exp = entityhuman.exp;
|
2012-11-06 13:05:28 +01:00
|
|
|
this.setScore(entityhuman.getScore());
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.enderChest = entityhuman.enderChest;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected boolean e_() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return !this.abilities.isFlying;
|
|
|
|
}
|
2012-03-22 21:39:39 +01:00
|
|
|
|
|
|
|
public void updateAbilities() {}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
public void a(EnumGamemode enumgamemode) {}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public World f_() {
|
|
|
|
return this.world;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public InventoryEnderChest getEnderChest() {
|
|
|
|
return this.enderChest;
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public ItemStack getEquipment(int i) {
|
|
|
|
return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1];
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public ItemStack aY() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.inventory.getItemInHand();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEquipment(int i, ItemStack itemstack) {
|
|
|
|
this.inventory.armor[i] = itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack[] getEquipment() {
|
|
|
|
return this.inventory.armor;
|
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public boolean aw() {
|
2013-03-13 23:33:27 +01:00
|
|
|
return !this.abilities.isFlying;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Scoreboard getScoreboard() {
|
|
|
|
return this.world.getScoreboard();
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public ScoreboardTeamBase getScoreboardTeam() {
|
2013-03-20 21:09:23 +01:00
|
|
|
return this.getScoreboard().getPlayerTeam(this.name);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getScoreboardDisplayName() {
|
2013-07-01 13:03:00 +02:00
|
|
|
// CraftBukkit todo: fun
|
2013-03-20 21:09:23 +01:00
|
|
|
return ScoreboardTeam.getPlayerDisplayName(this.getScoreboardTeam(), this.name);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
2013-07-01 13:03:00 +02:00
|
|
|
|
|
|
|
public void m(float f) {
|
|
|
|
if (f < 0.0F) {
|
|
|
|
f = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getDataWatcher().watch(17, Float.valueOf(f));
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public float bm() {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.getDataWatcher().getFloat(17);
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|