2011-01-09 18:27:46 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
2011-01-17 00:03:15 +01:00
|
|
|
//CraftBukkit start
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
//CraftBukkit end
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public class EntityPlayerMP extends EntityPlayer implements ICrafting {
|
2011-01-09 18:27:46 +01:00
|
|
|
|
|
|
|
public NetServerHandler a;
|
|
|
|
public MinecraftServer b;
|
|
|
|
public ItemInWorldManager c;
|
|
|
|
public double d;
|
|
|
|
public double e;
|
|
|
|
public List f;
|
2011-01-14 14:31:10 +01:00
|
|
|
public Set ak;
|
|
|
|
public double al;
|
|
|
|
private int bD;
|
2011-01-09 18:27:46 +01:00
|
|
|
private int bE;
|
2011-01-14 14:31:10 +01:00
|
|
|
private ItemStack bF[] = {
|
|
|
|
null, null, null, null, null
|
2011-01-09 18:27:46 +01:00
|
|
|
};
|
2011-01-14 14:31:10 +01:00
|
|
|
private int bG;
|
2011-01-09 18:27:46 +01:00
|
|
|
public boolean am;
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public EntityPlayerMP(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
|
2011-01-09 18:27:46 +01:00
|
|
|
super(world);
|
2011-01-11 09:25:13 +01:00
|
|
|
f = ((List) (new LinkedList()));
|
2011-01-14 14:31:10 +01:00
|
|
|
ak = ((Set) (new HashSet()));
|
|
|
|
bD = 0xfa0a1f01;
|
|
|
|
bE = 60;
|
|
|
|
bG = 0;
|
2011-01-09 18:27:46 +01:00
|
|
|
int i = world.m;
|
|
|
|
int j = world.o;
|
2011-01-14 14:31:10 +01:00
|
|
|
int k = world.n;
|
2011-01-09 18:27:46 +01:00
|
|
|
|
|
|
|
if (!world.q.e) {
|
|
|
|
i += W.nextInt(20) - 10;
|
2011-01-14 14:31:10 +01:00
|
|
|
k = world.e(i, j);
|
2011-01-09 18:27:46 +01:00
|
|
|
j += W.nextInt(20) - 10;
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
c((double) i + 0.5D, k, (double) j + 0.5D, 0.0F, 0.0F);
|
2011-01-09 18:27:46 +01:00
|
|
|
b = minecraftserver;
|
|
|
|
S = 0.0F;
|
2011-01-11 09:25:13 +01:00
|
|
|
iteminworldmanager.a = ((EntityPlayer) (this));
|
2011-01-14 14:31:10 +01:00
|
|
|
aw = s;
|
2011-01-09 18:27:46 +01:00
|
|
|
c = iteminworldmanager;
|
|
|
|
H = 0.0F;
|
2011-01-17 00:03:15 +01:00
|
|
|
//CraftBukkit start
|
|
|
|
CraftServer server = ((WorldServer) this.l).getServer();
|
|
|
|
this.bukkitEntity = new CraftPlayer(server, this);
|
|
|
|
//CraftBukkit end
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void l() {
|
2011-01-11 09:25:13 +01:00
|
|
|
ap.a(((ICrafting) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public ItemStack[] I() {
|
|
|
|
return bF;
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b_() {
|
2011-01-14 14:31:10 +01:00
|
|
|
bE--;
|
2011-01-09 18:27:46 +01:00
|
|
|
ap.a();
|
|
|
|
for (int i = 0; i < 5; i++) {
|
2011-01-14 14:31:10 +01:00
|
|
|
ItemStack itemstack = a(i);
|
2011-01-09 18:27:46 +01:00
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
if (itemstack != bF[i]) {
|
|
|
|
b.k.a(((Entity) (this)), ((Packet) (new Packet5PlayerInventory(g, i, itemstack))));
|
|
|
|
bF[i] = itemstack;
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public ItemStack a(int i) {
|
2011-01-09 18:27:46 +01:00
|
|
|
if (i == 0) {
|
2011-01-14 14:31:10 +01:00
|
|
|
return an.e();
|
2011-01-09 18:27:46 +01:00
|
|
|
} else {
|
2011-01-14 14:31:10 +01:00
|
|
|
return an.b[i - 1];
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void f(Entity entity) {
|
|
|
|
an.h();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(Entity entity, int i) {
|
2011-01-14 14:31:10 +01:00
|
|
|
if (bE > 0) {
|
2011-01-09 18:27:46 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!b.n) {
|
|
|
|
if (entity instanceof EntityPlayer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (entity instanceof EntityArrow) {
|
|
|
|
EntityArrow entityarrow = (EntityArrow) entity;
|
|
|
|
|
|
|
|
if (entityarrow.b instanceof EntityPlayer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.a(entity, i);
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void d(int i) {
|
|
|
|
super.d(i);
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void n() {
|
2011-01-09 18:27:46 +01:00
|
|
|
super.b_();
|
|
|
|
ChunkCoordIntPair chunkcoordintpair = null;
|
|
|
|
double d1 = 0.0D;
|
|
|
|
|
|
|
|
for (int i = 0; i < f.size(); i++) {
|
|
|
|
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) f.get(i);
|
2011-01-11 09:25:13 +01:00
|
|
|
double d2 = chunkcoordintpair1.a(((Entity) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
|
|
|
|
if (i == 0 || d2 < d1) {
|
|
|
|
chunkcoordintpair = chunkcoordintpair1;
|
2011-01-11 09:25:13 +01:00
|
|
|
d1 = chunkcoordintpair1.a(((Entity) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chunkcoordintpair != null) {
|
|
|
|
boolean flag = false;
|
|
|
|
|
|
|
|
if (d1 < 1024D) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
if (a.b() < 2) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
if (flag) {
|
2011-01-11 09:25:13 +01:00
|
|
|
f.remove(((chunkcoordintpair)));
|
|
|
|
a.b(((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, ((World) (b.e))))));
|
2011-01-09 18:27:46 +01:00
|
|
|
List list = 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++) {
|
|
|
|
a((TileEntity) list.get(j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
if (aZ != bD) {
|
|
|
|
a.b(((Packet) (new Packet8(aZ))));
|
|
|
|
bD = aZ;
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void a(TileEntity tileentity) {
|
|
|
|
if (tileentity != null) {
|
2011-01-14 14:31:10 +01:00
|
|
|
Packet packet = tileentity.g();
|
2011-01-09 18:27:46 +01:00
|
|
|
|
|
|
|
if (packet != null) {
|
|
|
|
a.b(packet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void o() {
|
2011-01-09 18:27:46 +01:00
|
|
|
s = t = u = 0.0D;
|
2011-01-14 14:31:10 +01:00
|
|
|
bA = false;
|
|
|
|
super.o();
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void c(Entity entity, int i) {
|
|
|
|
if (!entity.G) {
|
|
|
|
if (entity instanceof EntityItem) {
|
2011-01-11 09:25:13 +01:00
|
|
|
b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
if (entity instanceof EntityArrow) {
|
2011-01-11 09:25:13 +01:00
|
|
|
b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
super.c(entity, i);
|
|
|
|
ap.a();
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void K() {
|
2011-01-09 18:27:46 +01:00
|
|
|
if (!au) {
|
|
|
|
av = -1;
|
|
|
|
au = true;
|
2011-01-11 09:25:13 +01:00
|
|
|
b.k.a(((Entity) (this)), ((Packet) (new Packet18ArmAnimation(((Entity) (this)), 1))));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public float w() {
|
2011-01-09 18:27:46 +01:00
|
|
|
return 1.62F;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e(Entity entity) {
|
2011-01-13 07:39:15 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
setPassengerOf(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPassengerOf(Entity entity) {
|
|
|
|
// e(null) doesn't really fly for overloaded methods,
|
|
|
|
// so this method is needed
|
|
|
|
|
|
|
|
//CraftBukkit end
|
|
|
|
super.setPassengerOf(entity);
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet39(((Entity) (this)), k))));
|
2011-01-09 18:27:46 +01:00
|
|
|
a.a(p, q, r, v, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(double d1, boolean flag) {}
|
|
|
|
|
|
|
|
public void b(double d1, boolean flag) {
|
|
|
|
super.a(d1, flag);
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
private void U() {
|
|
|
|
bG = bG % 100 + 1;
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void a(int i, int j, int k) {
|
|
|
|
U();
|
|
|
|
a.b(((Packet) (new Packet100(bG, 1, "Crafting", 9))));
|
|
|
|
ap = ((CraftingInventoryCB) (new CraftingInventoryWorkbenchCB(an, l, i, j, k)));
|
|
|
|
ap.f = bG;
|
2011-01-11 09:25:13 +01:00
|
|
|
ap.a(((ICrafting) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(IInventory iinventory) {
|
2011-01-14 14:31:10 +01:00
|
|
|
U();
|
|
|
|
a.b(((Packet) (new Packet100(bG, 0, iinventory.b(), iinventory.h_()))));
|
2011-01-11 09:25:13 +01:00
|
|
|
ap = ((CraftingInventoryCB) (new CraftingInventoryChestCB(((IInventory) (an)), iinventory)));
|
2011-01-14 14:31:10 +01:00
|
|
|
ap.f = bG;
|
2011-01-11 09:25:13 +01:00
|
|
|
ap.a(((ICrafting) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(TileEntityFurnace tileentityfurnace) {
|
2011-01-14 14:31:10 +01:00
|
|
|
U();
|
|
|
|
a.b(((Packet) (new Packet100(bG, 2, tileentityfurnace.b(), tileentityfurnace.h_()))));
|
2011-01-11 09:25:13 +01:00
|
|
|
ap = ((CraftingInventoryCB) (new CraftingInventoryFurnaceCB(((IInventory) (an)), tileentityfurnace)));
|
2011-01-14 14:31:10 +01:00
|
|
|
ap.f = bG;
|
|
|
|
ap.a(((ICrafting) (this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(TileEntityDispenser tileentitydispenser) {
|
|
|
|
U();
|
|
|
|
a.b(((Packet) (new Packet100(bG, 3, tileentitydispenser.b(), tileentitydispenser.h_()))));
|
|
|
|
ap = ((CraftingInventoryCB) (new CraftingInventoryDispenserCB(((IInventory) (an)), tileentitydispenser)));
|
|
|
|
ap.f = bG;
|
2011-01-11 09:25:13 +01:00
|
|
|
ap.a(((ICrafting) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(CraftingInventoryCB craftinginventorycb, int i, ItemStack itemstack) {
|
|
|
|
if (craftinginventorycb.a(i) instanceof SlotCrafting) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (am) {
|
|
|
|
return;
|
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet103(craftinginventorycb.f, i, itemstack))));
|
2011-01-09 18:27:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(CraftingInventoryCB craftinginventorycb, List list) {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet104(craftinginventorycb.f, list))));
|
|
|
|
a.b(((Packet) (new Packet103(-1, -1, an.i()))));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(CraftingInventoryCB craftinginventorycb, int i, int j) {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet105(craftinginventorycb.f, i, j))));
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ItemStack itemstack) {}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void L() {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet101(ap.f))));
|
2011-01-14 14:31:10 +01:00
|
|
|
N();
|
2011-01-09 18:27:46 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void M() {
|
2011-01-09 18:27:46 +01:00
|
|
|
if (am) {
|
|
|
|
return;
|
|
|
|
} else {
|
2011-01-11 09:25:13 +01:00
|
|
|
a.b(((Packet) (new Packet103(-1, -1, an.i()))));
|
2011-01-09 18:27:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
public void N() {
|
2011-01-11 09:25:13 +01:00
|
|
|
ap.a(((EntityPlayer) (this)));
|
2011-01-09 18:27:46 +01:00
|
|
|
ap = ao;
|
|
|
|
}
|
2011-01-15 22:13:24 +01:00
|
|
|
}
|