Port to new mc-dev format.
This commit is contained in:
@@ -1,383 +1,288 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class EntityPlayer extends EntityLiving {
|
||||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
public InventoryPlayer an;
|
||||
public CraftingInventoryCB ao;
|
||||
public CraftingInventoryCB ap;
|
||||
public byte aq;
|
||||
public int ar;
|
||||
public float as;
|
||||
public float at;
|
||||
public boolean au;
|
||||
public int av;
|
||||
public String aw;
|
||||
public int ax;
|
||||
public double ay;
|
||||
public double az;
|
||||
public double aA;
|
||||
public double aB;
|
||||
public double aC;
|
||||
public double aD;
|
||||
private int a;
|
||||
public EntityFish aE;
|
||||
public NetServerHandler a;
|
||||
public MinecraftServer b;
|
||||
public ItemInWorldManager c;
|
||||
public double d;
|
||||
public double e;
|
||||
public List f = new LinkedList();
|
||||
public Set ak = new HashSet();
|
||||
public double al;
|
||||
private int bD = -99999999;
|
||||
private int bE = 60;
|
||||
private ItemStack[] bF = new ItemStack[] { null, null, null, null, null};
|
||||
private int bG = 0;
|
||||
public boolean am;
|
||||
|
||||
public EntityPlayer(World world) {
|
||||
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
|
||||
super(world);
|
||||
an = new InventoryPlayer(this);
|
||||
aq = 0;
|
||||
ar = 0;
|
||||
au = false;
|
||||
av = 0;
|
||||
a = 0;
|
||||
aE = null;
|
||||
ao = ((CraftingInventoryCB) (new CraftingInventoryPlayerCB(an, !world.z)));
|
||||
ap = ao;
|
||||
H = 1.62F;
|
||||
c((double) world.m + 0.5D, world.n + 1, (double) world.o + 0.5D, 0.0F, 0.0F);
|
||||
aZ = 20;
|
||||
aS = "humanoid";
|
||||
aR = 180F;
|
||||
Y = 20;
|
||||
aP = "/mob/char.png";
|
||||
int i = world.spawnX;
|
||||
int j = world.spawnZ;
|
||||
int k = world.spawnY;
|
||||
|
||||
if (!world.q.e) {
|
||||
i += this.random.nextInt(20) - 10;
|
||||
k = world.e(i, j);
|
||||
j += this.random.nextInt(20) - 10;
|
||||
}
|
||||
|
||||
this.c((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
|
||||
this.b = minecraftserver;
|
||||
this.S = 0.0F;
|
||||
iteminworldmanager.a = this;
|
||||
this.name = s;
|
||||
this.c = iteminworldmanager;
|
||||
this.height = 0.0F;
|
||||
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.l).getServer();
|
||||
this.bukkitEntity = new CraftHumanEntity(server, this);
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
this.bukkitEntity = new CraftPlayer(server, this);
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public void l() {
|
||||
this.activeContainer.a((ICrafting) this);
|
||||
}
|
||||
|
||||
public ItemStack[] I() {
|
||||
return this.bF;
|
||||
}
|
||||
|
||||
public void b_() {
|
||||
super.b_();
|
||||
if (!l.z && ap != null && !ap.b(this)) {
|
||||
L();
|
||||
ap = ao;
|
||||
}
|
||||
ay = aB;
|
||||
az = aC;
|
||||
aA = aD;
|
||||
double d1 = p - aB;
|
||||
double d2 = q - aC;
|
||||
double d3 = r - aD;
|
||||
double d4 = 10D;
|
||||
--this.bE;
|
||||
this.activeContainer.a();
|
||||
|
||||
if (d1 > d4) {
|
||||
ay = aB = p;
|
||||
}
|
||||
if (d3 > d4) {
|
||||
aA = aD = r;
|
||||
}
|
||||
if (d2 > d4) {
|
||||
az = aC = q;
|
||||
}
|
||||
if (d1 < -d4) {
|
||||
ay = aB = p;
|
||||
}
|
||||
if (d3 < -d4) {
|
||||
aA = aD = r;
|
||||
}
|
||||
if (d2 < -d4) {
|
||||
az = aC = q;
|
||||
}
|
||||
aB += d1 * 0.25D;
|
||||
aD += d3 * 0.25D;
|
||||
aC += d2 * 0.25D;
|
||||
}
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
ItemStack itemstack = this.a(i);
|
||||
|
||||
protected void L() {
|
||||
ap = ao;
|
||||
}
|
||||
|
||||
public void D() {
|
||||
super.D();
|
||||
as = at;
|
||||
at = 0.0F;
|
||||
}
|
||||
|
||||
protected void d() {
|
||||
if (au) {
|
||||
av++;
|
||||
if (av == 8) {
|
||||
av = 0;
|
||||
au = false;
|
||||
}
|
||||
} else {
|
||||
av = 0;
|
||||
}
|
||||
aY = (float) av / 8F;
|
||||
}
|
||||
|
||||
public void o() {
|
||||
if (l.k == 0 && aZ < 20 && (X % 20) * 12 == 0) {
|
||||
d(1);
|
||||
}
|
||||
an.f();
|
||||
as = at;
|
||||
super.o();
|
||||
float f1 = MathHelper.a(s * s + u * u);
|
||||
float f2 = (float) Math.atan(-t * 0.20000000298023224D) * 15F;
|
||||
|
||||
if (f1 > 0.1F) {
|
||||
f1 = 0.1F;
|
||||
}
|
||||
if (!A || aZ <= 0) {
|
||||
f1 = 0.0F;
|
||||
}
|
||||
if (A || aZ <= 0) {
|
||||
f2 = 0.0F;
|
||||
}
|
||||
at += (f1 - at) * 0.4F;
|
||||
bh += (f2 - bh) * 0.8F;
|
||||
if (aZ > 0) {
|
||||
List list = l.b(((Entity) (this)), z.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.G) {
|
||||
j(entity);
|
||||
}
|
||||
}
|
||||
if (itemstack != this.bF[i]) {
|
||||
this.b.k.a(this, new Packet5EntityEquipment(this.id, i, itemstack));
|
||||
this.bF[i] = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void j(Entity entity) {
|
||||
entity.b(this);
|
||||
public ItemStack a(int i) {
|
||||
return i == 0 ? this.inventory.e() : this.inventory.b[i - 1];
|
||||
}
|
||||
|
||||
public void f(Entity entity) {
|
||||
super.f(entity);
|
||||
a(0.2F, 0.2F);
|
||||
a(p, q, r);
|
||||
t = 0.10000000149011612D;
|
||||
if (aw.equals("Notch")) {
|
||||
a(new ItemStack(Item.h, 1), true);
|
||||
}
|
||||
an.h();
|
||||
if (entity != null) {
|
||||
s = -MathHelper.b(((bd + v) * 3.141593F) / 180F) * 0.1F;
|
||||
u = -MathHelper.a(((bd + v) * 3.141593F) / 180F) * 0.1F;
|
||||
} else {
|
||||
s = u = 0.0D;
|
||||
}
|
||||
H = 0.1F;
|
||||
}
|
||||
|
||||
public void b(Entity entity, int i) {
|
||||
ar += i;
|
||||
}
|
||||
|
||||
public void O() {
|
||||
a(an.b(an.c, 1), false);
|
||||
}
|
||||
|
||||
public void b(ItemStack itemstack) {
|
||||
a(itemstack, false);
|
||||
}
|
||||
|
||||
public void a(ItemStack itemstack, boolean flag) {
|
||||
if (itemstack == null) {
|
||||
return;
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(l, p, (q - 0.30000001192092896D) + (double) w(), r, itemstack);
|
||||
|
||||
entityitem.c = 40;
|
||||
float f1 = 0.1F;
|
||||
|
||||
if (flag) {
|
||||
float f3 = W.nextFloat() * 0.5F;
|
||||
float f5 = W.nextFloat() * 3.141593F * 2.0F;
|
||||
|
||||
entityitem.s = -MathHelper.a(f5) * f3;
|
||||
entityitem.u = MathHelper.b(f5) * f3;
|
||||
entityitem.t = 0.20000000298023224D;
|
||||
} else {
|
||||
float f2 = 0.3F;
|
||||
|
||||
entityitem.s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
|
||||
entityitem.u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
|
||||
entityitem.t = -MathHelper.a((w / 180F) * 3.141593F) * f2 + 0.1F;
|
||||
f2 = 0.02F;
|
||||
float f4 = W.nextFloat() * 3.141593F * 2.0F;
|
||||
|
||||
f2 *= W.nextFloat();
|
||||
entityitem.s += Math.cos(f4) * (double) f2;
|
||||
entityitem.t += (W.nextFloat() - W.nextFloat()) * 0.1F;
|
||||
entityitem.u += Math.sin(f4) * (double) f2;
|
||||
}
|
||||
a(entityitem);
|
||||
}
|
||||
|
||||
protected void a(EntityItem entityitem) {
|
||||
l.a(((Entity) (entityitem)));
|
||||
}
|
||||
|
||||
public float a(Block block) {
|
||||
float f1 = an.a(block);
|
||||
|
||||
if (a(Material.f)) {
|
||||
f1 /= 5F;
|
||||
}
|
||||
if (!A) {
|
||||
f1 /= 5F;
|
||||
}
|
||||
return f1;
|
||||
}
|
||||
|
||||
public boolean b(Block block) {
|
||||
return an.b(block);
|
||||
}
|
||||
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
super.b(nbttagcompound);
|
||||
NBTTagList nbttaglist = nbttagcompound.k("Inventory");
|
||||
|
||||
an.b(nbttaglist);
|
||||
ax = nbttagcompound.d("Dimension");
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
nbttagcompound.a("Inventory", ((NBTBase) (an.a(new NBTTagList()))));
|
||||
nbttagcompound.a("Dimension", ax);
|
||||
}
|
||||
|
||||
public void a(IInventory iinventory) {}
|
||||
|
||||
public void a(int i, int k, int l) {}
|
||||
|
||||
public void c(Entity entity, int i) {}
|
||||
|
||||
public float w() {
|
||||
return 0.12F;
|
||||
this.inventory.h();
|
||||
}
|
||||
|
||||
public boolean a(Entity entity, int i) {
|
||||
bw = 0;
|
||||
if (aZ <= 0) {
|
||||
return false;
|
||||
}
|
||||
if ((entity instanceof EntityMobs) || (entity instanceof EntityArrow)) {
|
||||
if (l.k == 0) {
|
||||
i = 0;
|
||||
}
|
||||
if (l.k == 1) {
|
||||
i = i / 3 + 1;
|
||||
}
|
||||
if (l.k == 3) {
|
||||
i = (i * 3) / 2;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
if (this.bE > 0) {
|
||||
return false;
|
||||
} else {
|
||||
if (!this.b.n) {
|
||||
if (entity instanceof EntityHuman) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityArrow) {
|
||||
EntityArrow entityarrow = (EntityArrow) entity;
|
||||
|
||||
if (entityarrow.b instanceof EntityHuman) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.a(entity, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected void e(int i) {
|
||||
int k = 25 - an.g();
|
||||
int l = i * k + a;
|
||||
|
||||
an.c(i);
|
||||
i = l / 25;
|
||||
a = l % 25;
|
||||
super.e(i);
|
||||
public void d(int i) {
|
||||
super.d(i);
|
||||
}
|
||||
|
||||
public void a(TileEntityFurnace tileentityfurnace) {}
|
||||
public void n() {
|
||||
super.b_();
|
||||
ChunkCoordIntPair chunkcoordintpair = null;
|
||||
double d0 = 0.0D;
|
||||
|
||||
public void a(TileEntityDispenser tileentitydispenser) {}
|
||||
for (int i = 0; i < this.f.size(); ++i) {
|
||||
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) this.f.get(i);
|
||||
double d1 = chunkcoordintpair1.a(this);
|
||||
|
||||
public void a(TileEntitySign tileentitysign) {}
|
||||
|
||||
public void g(Entity entity) {
|
||||
if (entity.a(this)) {
|
||||
return;
|
||||
if (i == 0 || d1 < d0) {
|
||||
chunkcoordintpair = chunkcoordintpair1;
|
||||
d0 = chunkcoordintpair1.a(this);
|
||||
}
|
||||
}
|
||||
ItemStack itemstack = P();
|
||||
|
||||
if (itemstack != null && (entity instanceof EntityLiving)) {
|
||||
itemstack.b((EntityLiving) entity);
|
||||
if (itemstack.a <= 0) {
|
||||
itemstack.a(this);
|
||||
Q();
|
||||
if (chunkcoordintpair != null) {
|
||||
boolean flag = false;
|
||||
|
||||
if (d0 < 1024.0D) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (this.a.b() < 2) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
this.f.remove(chunkcoordintpair);
|
||||
this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.b.e)));
|
||||
List list = this.b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
|
||||
|
||||
for (int j = 0; j < list.size(); ++j) {
|
||||
this.a((TileEntity) list.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.health != this.bD) {
|
||||
this.a.b((Packet) (new Packet8UpdateHealth(this.health)));
|
||||
this.bD = this.health;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(TileEntity tileentity) {
|
||||
if (tileentity != null) {
|
||||
Packet packet = tileentity.g();
|
||||
|
||||
if (packet != null) {
|
||||
this.a.b(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack P() {
|
||||
return an.e();
|
||||
public void o() {
|
||||
this.motX = this.motY = this.motZ = 0.0D;
|
||||
this.bA = false;
|
||||
super.o();
|
||||
}
|
||||
|
||||
public void Q() {
|
||||
an.a(an.c, ((ItemStack) (null)));
|
||||
}
|
||||
public void c(Entity entity, int i) {
|
||||
if (!entity.dead) {
|
||||
if (entity instanceof EntityItem) {
|
||||
this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
|
||||
}
|
||||
|
||||
public double F() {
|
||||
return (double) (H - 0.5F);
|
||||
if (entity instanceof EntityArrow) {
|
||||
this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
|
||||
}
|
||||
}
|
||||
|
||||
super.c(entity, i);
|
||||
this.activeContainer.a();
|
||||
}
|
||||
|
||||
public void K() {
|
||||
av = -1;
|
||||
au = true;
|
||||
if (!this.au) {
|
||||
this.av = -1;
|
||||
this.au = true;
|
||||
this.b.k.a(this, new Packet18ArmAnimation(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void h(Entity entity) {
|
||||
int i = an.a(entity);
|
||||
public float w() {
|
||||
return 1.62F;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
// CraftBukkit start
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damageDone = i;
|
||||
|
||||
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
|
||||
server.getPluginManager().callEvent(edbee);
|
||||
public void e(Entity entity) {
|
||||
// CraftBukkit start
|
||||
setPassengerOf(entity);
|
||||
}
|
||||
|
||||
if (!edbee.isCancelled()){
|
||||
entity.a(((Entity) this), edbee.getDamage());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
entity.a(((Entity) (this)), i);
|
||||
}
|
||||
// CraftBukkit end
|
||||
ItemStack itemstack = P();
|
||||
public void setPassengerOf(Entity entity) {
|
||||
// e(null) doesn't really fly for overloaded methods,
|
||||
// so this method is needed
|
||||
|
||||
if (itemstack != null && (entity instanceof EntityLiving)) {
|
||||
itemstack.a((EntityLiving) entity);
|
||||
if (itemstack.a <= 0) {
|
||||
itemstack.a(this);
|
||||
Q();
|
||||
}
|
||||
super.setPassengerOf(entity);
|
||||
// CraftBukkit end
|
||||
this.a.b((Packet) (new Packet39AttachEntity(this, this.vehicle)));
|
||||
this.a.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
||||
}
|
||||
|
||||
protected void a(double d0, boolean flag) {}
|
||||
|
||||
public void b(double d0, boolean flag) {
|
||||
super.a(d0, flag);
|
||||
}
|
||||
|
||||
private void U() {
|
||||
this.bG = this.bG % 100 + 1;
|
||||
}
|
||||
|
||||
public void a(int i, int j, int k) {
|
||||
this.U();
|
||||
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 1, "Crafting", 9)));
|
||||
this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k);
|
||||
this.activeContainer.f = this.bG;
|
||||
this.activeContainer.a((ICrafting) this);
|
||||
}
|
||||
|
||||
public void a(IInventory iinventory) {
|
||||
this.U();
|
||||
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 0, iinventory.b(), iinventory.h_())));
|
||||
this.activeContainer = new ContainerChest(this.inventory, iinventory);
|
||||
this.activeContainer.f = this.bG;
|
||||
this.activeContainer.a((ICrafting) this);
|
||||
}
|
||||
|
||||
public void a(TileEntityFurnace tileentityfurnace) {
|
||||
this.U();
|
||||
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 2, tileentityfurnace.b(), tileentityfurnace.h_())));
|
||||
this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace);
|
||||
this.activeContainer.f = this.bG;
|
||||
this.activeContainer.a((ICrafting) this);
|
||||
}
|
||||
|
||||
public void a(TileEntityDispenser tileentitydispenser) {
|
||||
this.U();
|
||||
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 3, tileentitydispenser.b(), tileentitydispenser.h_())));
|
||||
this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser);
|
||||
this.activeContainer.f = this.bG;
|
||||
this.activeContainer.a((ICrafting) this);
|
||||
}
|
||||
|
||||
public void a(Container container, int i, ItemStack itemstack) {
|
||||
if (!(container.a(i) instanceof SlotResult)) {
|
||||
if (!this.am) {
|
||||
this.a.b((Packet) (new Packet103SetSlot(container.f, i, itemstack)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Container container, List list) {
|
||||
this.a.b((Packet) (new Packet104WindowItems(container.f, list)));
|
||||
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
|
||||
}
|
||||
|
||||
public void a(Container container, int i, int j) {
|
||||
this.a.b((Packet) (new Packet105CraftProgressBar(container.f, i, j)));
|
||||
}
|
||||
|
||||
public void a(ItemStack itemstack) {}
|
||||
|
||||
public void q() {
|
||||
super.q();
|
||||
ao.a(this);
|
||||
if (ap != null) {
|
||||
ap.a(this);
|
||||
public void L() {
|
||||
this.a.b((Packet) (new Packet101CloseWindow(this.activeContainer.f)));
|
||||
this.N();
|
||||
}
|
||||
|
||||
public void M() {
|
||||
if (!this.am) {
|
||||
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
|
||||
}
|
||||
}
|
||||
|
||||
public void N() {
|
||||
this.activeContainer.a((EntityHuman) this);
|
||||
this.activeContainer = this.defaultContainer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user