2011-02-06 00:37:33 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-06 00:37:33 +01:00
|
|
|
public class EntityTrackerEntry {
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public Entity tracker;
|
2011-02-06 00:37:33 +01:00
|
|
|
public int b;
|
|
|
|
public int c;
|
2012-02-29 22:31:04 +01:00
|
|
|
public int xLoc;
|
|
|
|
public int yLoc;
|
|
|
|
public int zLoc;
|
|
|
|
public int yRot;
|
|
|
|
public int xRot;
|
2012-03-01 11:49:23 +01:00
|
|
|
public int i;
|
2011-02-06 00:37:33 +01:00
|
|
|
public double j;
|
|
|
|
public double k;
|
2012-03-01 11:49:23 +01:00
|
|
|
public double l;
|
|
|
|
public int m = 0;
|
2011-02-06 00:37:33 +01:00
|
|
|
private double p;
|
|
|
|
private double q;
|
2012-03-01 11:49:23 +01:00
|
|
|
private double r;
|
|
|
|
private boolean s = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
private boolean isMoving;
|
2012-03-01 11:49:23 +01:00
|
|
|
private int u = 0;
|
2012-07-29 09:33:13 +02:00
|
|
|
private Entity v;
|
2012-11-06 13:05:28 +01:00
|
|
|
private boolean w = false;
|
2012-03-01 11:49:23 +01:00
|
|
|
public boolean n = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
public Set trackedPlayers = new HashSet();
|
2011-02-06 00:37:33 +01:00
|
|
|
|
|
|
|
public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.tracker = entity;
|
2011-02-06 00:37:33 +01:00
|
|
|
this.b = i;
|
|
|
|
this.c = j;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.isMoving = flag;
|
2012-02-29 22:31:04 +01:00
|
|
|
this.xLoc = MathHelper.floor(entity.locX * 32.0D);
|
|
|
|
this.yLoc = MathHelper.floor(entity.locY * 32.0D);
|
|
|
|
this.zLoc = MathHelper.floor(entity.locZ * 32.0D);
|
|
|
|
this.yRot = MathHelper.d(entity.yaw * 256.0F / 360.0F);
|
|
|
|
this.xRot = MathHelper.d(entity.pitch * 256.0F / 360.0F);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i = MathHelper.d(entity.ap() * 256.0F / 360.0F);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object object) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return object instanceof EntityTrackerEntry ? ((EntityTrackerEntry) object).tracker.id == this.tracker.id : false;
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.tracker.id;
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void track(List list) {
|
2012-03-01 11:49:23 +01:00
|
|
|
this.n = false;
|
|
|
|
if (!this.s || this.tracker.e(this.p, this.q, this.r) > 16.0D) {
|
|
|
|
this.p = this.tracker.locX;
|
|
|
|
this.q = this.tracker.locY;
|
|
|
|
this.r = this.tracker.locZ;
|
|
|
|
this.s = true;
|
|
|
|
this.n = true;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.scanPlayers(list);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.v != this.tracker.vehicle) {
|
|
|
|
this.v = this.tracker.vehicle;
|
|
|
|
this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
|
|
|
|
}
|
2012-01-30 21:28:04 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) {
|
|
|
|
EntityItemFrame i4 = (EntityItemFrame) this.tracker;
|
|
|
|
ItemStack i5 = i4.i();
|
|
|
|
|
|
|
|
if (i5 != null && i5.getItem() instanceof ItemWorldMap) {
|
|
|
|
WorldMap i7 = Item.MAP.getSavedMap(i5, this.tracker.world);
|
2012-11-06 13:05:28 +01:00
|
|
|
Iterator j0 = list.iterator();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
while (j0.hasNext()) {
|
|
|
|
EntityHuman j1 = (EntityHuman) j0.next();
|
|
|
|
EntityPlayer j2 = (EntityPlayer) j1;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
i7.a(j2, i5);
|
|
|
|
if (j2.netServerHandler.lowPriorityCount() <= 5) {
|
|
|
|
Packet j3 = Item.MAP.c(i5, this.tracker.world, j2);
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (j3 != null) {
|
|
|
|
j2.netServerHandler.sendPacket(j3);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DataWatcher i9 = this.tracker.getDataWatcher();
|
|
|
|
|
|
|
|
if (i9.a()) {
|
|
|
|
this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, i9, false));
|
|
|
|
}
|
|
|
|
} else if (this.m++ % this.c == 0 || this.tracker.am) {
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
if (this.tracker.vehicle == null) {
|
|
|
|
++this.u;
|
|
|
|
i = this.tracker.ar.a(this.tracker.locX);
|
|
|
|
j = MathHelper.floor(this.tracker.locY * 32.0D);
|
|
|
|
int k = this.tracker.ar.a(this.tracker.locZ);
|
2012-07-29 09:33:13 +02:00
|
|
|
int l = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
|
|
|
|
int i1 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
|
|
|
|
int j1 = i - this.xLoc;
|
|
|
|
int k1 = j - this.yLoc;
|
|
|
|
int l1 = k - this.zLoc;
|
|
|
|
Object object = null;
|
2012-10-25 05:53:23 +02:00
|
|
|
boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0;
|
2012-07-29 09:33:13 +02:00
|
|
|
boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4;
|
|
|
|
|
|
|
|
// CraftBukkit start - code moved from below
|
|
|
|
if (flag) {
|
|
|
|
this.xLoc = i;
|
|
|
|
this.yLoc = j;
|
|
|
|
this.zLoc = k;
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
if (flag1) {
|
|
|
|
this.yRot = l;
|
|
|
|
this.xRot = i1;
|
2012-01-30 21:28:04 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.u <= 400 && !this.w) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (flag && flag1) {
|
|
|
|
object = new Packet33RelEntityMoveLook(this.tracker.id, (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1);
|
|
|
|
} else if (flag) {
|
|
|
|
object = new Packet31RelEntityMove(this.tracker.id, (byte) j1, (byte) k1, (byte) l1);
|
|
|
|
} else if (flag1) {
|
|
|
|
object = new Packet32EntityLook(this.tracker.id, (byte) l, (byte) i1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.u = 0;
|
|
|
|
// CraftBukkit start - refresh list of who can see a player before sending teleport packet
|
|
|
|
if (this.tracker instanceof EntityPlayer) {
|
|
|
|
this.scanPlayers(new java.util.ArrayList(this.trackedPlayers));
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
object = new Packet34EntityTeleport(this.tracker.id, i, j, k, (byte) l, (byte) i1);
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.isMoving) {
|
|
|
|
double d0 = this.tracker.motX - this.j;
|
|
|
|
double d1 = this.tracker.motY - this.k;
|
|
|
|
double d2 = this.tracker.motZ - this.l;
|
|
|
|
double d3 = 0.02D;
|
|
|
|
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
|
|
|
|
|
|
|
|
if (d4 > d3 * d3 || d4 > 0.0D && this.tracker.motX == 0.0D && this.tracker.motY == 0.0D && this.tracker.motZ == 0.0D) {
|
|
|
|
this.j = this.tracker.motX;
|
|
|
|
this.k = this.tracker.motY;
|
|
|
|
this.l = this.tracker.motZ;
|
|
|
|
this.broadcast(new Packet28EntityVelocity(this.tracker.id, this.j, this.k, this.l));
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (object != null) {
|
|
|
|
this.broadcast((Packet) object);
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
DataWatcher datawatcher1 = this.tracker.getDataWatcher();
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (datawatcher1.a()) {
|
|
|
|
this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher1, false));
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
/* CraftBukkit start - code moved up
|
|
|
|
if (flag) {
|
|
|
|
this.xLoc = i;
|
|
|
|
this.yLoc = j;
|
|
|
|
this.zLoc = k;
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (flag1) {
|
|
|
|
this.yRot = l;
|
|
|
|
this.xRot = i1;
|
|
|
|
}
|
|
|
|
// CraftBukkit end */
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
this.w = false;
|
2012-10-25 05:53:23 +02:00
|
|
|
} else {
|
|
|
|
i = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
|
|
|
|
j = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
|
|
|
|
boolean flag2 = Math.abs(i - this.yRot) >= 4 || Math.abs(j - this.xRot) >= 4;
|
|
|
|
|
|
|
|
if (flag2) {
|
|
|
|
this.broadcast(new Packet32EntityLook(this.tracker.id, (byte) i, (byte) j));
|
|
|
|
this.yRot = i;
|
|
|
|
this.xRot = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.xLoc = this.tracker.ar.a(this.tracker.locX);
|
|
|
|
this.yLoc = MathHelper.floor(this.tracker.locY * 32.0D);
|
|
|
|
this.zLoc = this.tracker.ar.a(this.tracker.locZ);
|
2012-11-06 13:05:28 +01:00
|
|
|
DataWatcher datawatcher2 = this.tracker.getDataWatcher();
|
|
|
|
|
|
|
|
if (datawatcher2.a()) {
|
|
|
|
this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher2, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.w = true;
|
2012-02-29 22:31:04 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F);
|
|
|
|
if (Math.abs(i - this.i) >= 4) {
|
|
|
|
this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i));
|
|
|
|
this.i = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.tracker.am = false;
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.tracker.velocityChanged) {
|
2011-07-28 07:17:31 +02:00
|
|
|
// CraftBukkit start - create PlayerVelocity event
|
|
|
|
boolean cancelled = false;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.tracker instanceof EntityPlayer) {
|
2012-07-22 08:18:00 +02:00
|
|
|
Player player = (Player) this.tracker.getBukkitEntity();
|
2011-07-28 07:17:31 +02:00
|
|
|
org.bukkit.util.Vector velocity = player.getVelocity();
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity);
|
2011-07-28 07:17:31 +02:00
|
|
|
this.tracker.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (event.isCancelled()) {
|
2011-07-28 07:17:31 +02:00
|
|
|
cancelled = true;
|
2011-11-20 09:01:14 +01:00
|
|
|
} else if (!velocity.equals(event.getVelocity())) {
|
2011-07-28 07:17:31 +02:00
|
|
|
player.setVelocity(velocity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!cancelled) {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.broadcastIncludingSelf((Packet) (new Packet28EntityVelocity(this.tracker)));
|
2011-07-28 07:17:31 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.tracker.velocityChanged = false;
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void broadcast(Packet packet) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Iterator iterator = this.trackedPlayers.iterator();
|
2011-02-06 00:37:33 +01:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entityplayer.netServerHandler.sendPacket(packet);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void broadcastIncludingSelf(Packet packet) {
|
|
|
|
this.broadcast(packet);
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.tracker instanceof EntityPlayer) {
|
|
|
|
((EntityPlayer) this.tracker).netServerHandler.sendPacket(packet);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
2012-07-29 09:33:13 +02:00
|
|
|
Iterator iterator = this.trackedPlayers.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EntityPlayer entityplayer) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.trackedPlayers.contains(entityplayer)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
|
2011-04-20 19:05:14 +02:00
|
|
|
this.trackedPlayers.remove(entityplayer);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void updatePlayer(EntityPlayer entityplayer) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityplayer != this.tracker) {
|
2012-02-29 22:31:04 +01:00
|
|
|
double d0 = entityplayer.locX - (double) (this.xLoc / 32);
|
|
|
|
double d1 = entityplayer.locZ - (double) (this.zLoc / 32);
|
2011-02-06 00:37:33 +01:00
|
|
|
|
|
|
|
if (d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.trackedPlayers.contains(entityplayer) && this.d(entityplayer)) {
|
2012-01-31 20:54:15 +01:00
|
|
|
// CraftBukkit start
|
2012-10-13 22:27:45 +02:00
|
|
|
if (this.tracker instanceof EntityPlayer) {
|
|
|
|
Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
2012-01-31 20:54:15 +01:00
|
|
|
if (!entityplayer.getBukkitEntity().canSee(player)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-10-13 22:27:45 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.id));
|
2012-01-31 20:54:15 +01:00
|
|
|
// CraftBukkit end
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.trackedPlayers.add(entityplayer);
|
2012-07-29 09:33:13 +02:00
|
|
|
Packet packet = this.b();
|
|
|
|
|
|
|
|
entityplayer.netServerHandler.sendPacket(packet);
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.tracker instanceof EntityItemFrame) {
|
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet40EntityMetadata(this.tracker.id, this.tracker.getDataWatcher(), true));
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.j = this.tracker.motX;
|
|
|
|
this.k = this.tracker.motY;
|
|
|
|
this.l = this.tracker.motZ;
|
|
|
|
if (this.isMoving && !(packet instanceof Packet24MobSpawn)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet28EntityVelocity(this.tracker.id, this.tracker.motX, this.tracker.motY, this.tracker.motZ));
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.tracker.vehicle != null) {
|
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.tracker instanceof EntityLiving) {
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
ItemStack itemstack = ((EntityLiving) this.tracker).getEquipment(i);
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (itemstack != null) {
|
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet5EntityEquipment(this.tracker.id, i, itemstack));
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
2011-05-31 15:55:45 +02:00
|
|
|
|
|
|
|
if (this.tracker instanceof EntityHuman) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.tracker;
|
|
|
|
|
|
|
|
if (entityhuman.isSleeping()) {
|
2011-11-30 00:17:43 +01:00
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet17EntityLocationAction(this.tracker, 0, MathHelper.floor(this.tracker.locX), MathHelper.floor(this.tracker.locY), MathHelper.floor(this.tracker.locZ)));
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-05-13 04:31:17 +02:00
|
|
|
// CraftBukkit start - Fix for nonsensical head yaw
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F); // tracker.am() should be getHeadRotation
|
2012-05-13 04:31:17 +02:00
|
|
|
this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i));
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
if (this.tracker instanceof EntityLiving) {
|
|
|
|
EntityLiving entityliving = (EntityLiving) this.tracker;
|
2011-09-24 23:03:31 +02:00
|
|
|
Iterator iterator = entityliving.getEffects().iterator();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
MobEffect mobeffect = (MobEffect) iterator.next();
|
|
|
|
|
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet41MobEffect(this.tracker.id, mobeffect));
|
|
|
|
}
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
} else if (this.trackedPlayers.contains(entityplayer)) {
|
|
|
|
this.trackedPlayers.remove(entityplayer);
|
2012-10-25 05:53:23 +02:00
|
|
|
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private boolean d(EntityPlayer entityplayer) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return entityplayer.p().getPlayerManager().a(entityplayer, this.tracker.ai, this.tracker.ak);
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void scanPlayers(List list) {
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
this.updatePlayer((EntityPlayer) list.get(i));
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Packet b() {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.tracker.dead) {
|
2012-04-24 19:42:53 +02:00
|
|
|
// CraftBukkit start - remove useless error spam, just return
|
|
|
|
// System.out.println("Fetching addPacket for removed entity");
|
|
|
|
return null;
|
|
|
|
// CraftBukkit end
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.tracker instanceof EntityItem) {
|
|
|
|
EntityItem entityitem = (EntityItem) this.tracker;
|
2012-10-25 05:53:23 +02:00
|
|
|
Packet21PickupSpawn entityminecart0 = new Packet21PickupSpawn(entityitem);
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
entityitem.locX = (double) entityminecart0.b / 32.0D;
|
|
|
|
entityitem.locY = (double) entityminecart0.c / 32.0D;
|
|
|
|
entityitem.locZ = (double) entityminecart0.d / 32.0D;
|
|
|
|
return entityminecart0;
|
2011-04-20 19:05:14 +02:00
|
|
|
} else if (this.tracker instanceof EntityPlayer) {
|
|
|
|
return new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
|
2011-02-06 00:37:33 +01:00
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.tracker instanceof EntityMinecart) {
|
|
|
|
EntityMinecart entityminecart = (EntityMinecart) this.tracker;
|
2011-02-06 00:37:33 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityminecart.type == 0) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 10);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityminecart.type == 1) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 11);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityminecart.type == 2) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 12);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.tracker instanceof EntityBoat) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 1);
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if (!(this.tracker instanceof IAnimal) && !(this.tracker instanceof EntityEnderDragon)) {
|
|
|
|
if (this.tracker instanceof EntityFishingHook) {
|
|
|
|
EntityHuman entityhuman = ((EntityFishingHook) this.tracker).owner;
|
|
|
|
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 90, entityhuman != null ? entityhuman.id : this.tracker.id);
|
|
|
|
} else if (this.tracker instanceof EntityArrow) {
|
|
|
|
Entity entity = ((EntityArrow) this.tracker).shooter;
|
|
|
|
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 60, entity != null ? entity.id : this.tracker.id);
|
|
|
|
} else if (this.tracker instanceof EntitySnowball) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 61);
|
|
|
|
} else if (this.tracker instanceof EntityPotion) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 73, ((EntityPotion) this.tracker).getPotionValue());
|
|
|
|
} else if (this.tracker instanceof EntityThrownExpBottle) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 75);
|
|
|
|
} else if (this.tracker instanceof EntityEnderPearl) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 65);
|
|
|
|
} else if (this.tracker instanceof EntityEnderSignal) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 72);
|
2011-02-06 00:37:33 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
Packet23VehicleSpawn packet23vehiclespawn;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.tracker instanceof EntityFireball) {
|
|
|
|
EntityFireball entityfireball = (EntityFireball) this.tracker;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
packet23vehiclespawn = null;
|
2012-10-25 05:53:23 +02:00
|
|
|
byte b0 = 63;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.tracker instanceof EntitySmallFireball) {
|
|
|
|
b0 = 64;
|
|
|
|
} else if (this.tracker instanceof EntityWitherSkull) {
|
|
|
|
b0 = 66;
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
if (entityfireball.shooter != null) {
|
2012-10-25 05:53:23 +02:00
|
|
|
packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, b0, ((EntityFireball) this.tracker).shooter.id);
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, b0, 0);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
packet23vehiclespawn.e = (int) (entityfireball.dirX * 8000.0D);
|
|
|
|
packet23vehiclespawn.f = (int) (entityfireball.dirY * 8000.0D);
|
|
|
|
packet23vehiclespawn.g = (int) (entityfireball.dirZ * 8000.0D);
|
|
|
|
return packet23vehiclespawn;
|
|
|
|
} else if (this.tracker instanceof EntityEgg) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 62);
|
|
|
|
} else if (this.tracker instanceof EntityTNTPrimed) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 50);
|
|
|
|
} else if (this.tracker instanceof EntityEnderCrystal) {
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 51);
|
|
|
|
} else if (this.tracker instanceof EntityFallingBlock) {
|
|
|
|
EntityFallingBlock entityfallingblock = (EntityFallingBlock) this.tracker;
|
|
|
|
|
|
|
|
return new Packet23VehicleSpawn(this.tracker, 70, entityfallingblock.id | entityfallingblock.data << 16);
|
|
|
|
} else if (this.tracker instanceof EntityPainting) {
|
2011-11-20 09:01:14 +01:00
|
|
|
return new Packet25EntityPainting((EntityPainting) this.tracker);
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.tracker instanceof EntityItemFrame) {
|
|
|
|
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
|
|
|
|
|
|
|
|
packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 71, entityitemframe.direction);
|
|
|
|
packet23vehiclespawn.b = MathHelper.d((float) (entityitemframe.x * 32));
|
|
|
|
packet23vehiclespawn.c = MathHelper.d((float) (entityitemframe.y * 32));
|
|
|
|
packet23vehiclespawn.d = MathHelper.d((float) (entityitemframe.z * 32));
|
|
|
|
return packet23vehiclespawn;
|
2011-11-20 09:01:14 +01:00
|
|
|
} else if (this.tracker instanceof EntityExperienceOrb) {
|
|
|
|
return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker);
|
|
|
|
} else {
|
|
|
|
throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!");
|
|
|
|
}
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F);
|
2012-07-29 09:33:13 +02:00
|
|
|
return new Packet24MobSpawn((EntityLiving) this.tracker);
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
public void clear(EntityPlayer entityplayer) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.trackedPlayers.contains(entityplayer)) {
|
|
|
|
this.trackedPlayers.remove(entityplayer);
|
2012-10-25 05:53:23 +02:00
|
|
|
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
|
2011-02-06 00:37:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|