diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityTrackerEntry.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityTrackerEntry.java | 109 |
1 files changed, 68 insertions, 41 deletions
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index 5c037329..e58af635 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -24,16 +25,16 @@ public class EntityTrackerEntry { public double j; public double k; public double l; - public int m = 0; + public int m; private double p; private double q; private double r; - private boolean s = false; + private boolean s; private boolean isMoving; - private int u = 0; + private int u; private Entity v; - private boolean w = false; - public boolean n = false; + private boolean w; + public boolean n; public Set trackedPlayers = new HashSet(); public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) { @@ -70,37 +71,33 @@ public class EntityTrackerEntry { if (this.v != this.tracker.vehicle /* || this.tracker.vehicle != null && this.m % 60 == 0 */) { // CraftBukkit - Revert to 1.4 logic, this packet is a toggle this.v = this.tracker.vehicle; - this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); + this.broadcast(new Packet39AttachEntity(0, this.tracker, this.tracker.vehicle)); } if (this.tracker instanceof EntityItemFrame /*&& this.m % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block - EntityItemFrame i4 = (EntityItemFrame) this.tracker; - ItemStack i5 = i4.i(); + EntityItemFrame i3 = (EntityItemFrame) this.tracker; + ItemStack i4 = i3.h(); - if (this.m % 10 == 0 && i5 != null && i5.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks - WorldMap i7 = Item.MAP.getSavedMap(i5, this.tracker.world); - Iterator j0 = this.trackedPlayers.iterator(); // CraftBukkit + if (this.m % 10 == 0 && i4 != null && i4.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks + WorldMap i6 = Item.MAP.getSavedMap(i4, this.tracker.world); + Iterator i7 = this.trackedPlayers.iterator(); // CraftBukkit - while (j0.hasNext()) { - EntityHuman j1 = (EntityHuman) j0.next(); - EntityPlayer j2 = (EntityPlayer) j1; + while (i7.hasNext()) { + EntityHuman i8 = (EntityHuman) i7.next(); + EntityPlayer i9 = (EntityPlayer) i8; - i7.a(j2, i5); - if (j2.playerConnection.lowPriorityCount() <= 5) { - Packet j3 = Item.MAP.c(i5, this.tracker.world, j2); + i6.a(i9, i4); + if (i9.playerConnection.lowPriorityCount() <= 5) { + Packet j0 = Item.MAP.c(i4, this.tracker.world, i9); - if (j3 != null) { - j2.playerConnection.sendPacket(j3); + if (j0 != null) { + i9.playerConnection.sendPacket(j0); } } } } - DataWatcher i9 = this.tracker.getDataWatcher(); - - if (i9.a()) { - this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, i9, false)); - } + this.b(); } else if (this.m % this.c == 0 || this.tracker.an || this.tracker.getDataWatcher().a()) { int i; int j; @@ -171,12 +168,7 @@ public class EntityTrackerEntry { this.broadcast((Packet) object); } - DataWatcher datawatcher1 = this.tracker.getDataWatcher(); - - if (datawatcher1.a()) { - this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher1, false)); - } - + this.b(); /* CraftBukkit start - Code moved up if (flag) { this.xLoc = i; @@ -205,12 +197,7 @@ public class EntityTrackerEntry { this.xLoc = this.tracker.at.a(this.tracker.locX); this.yLoc = MathHelper.floor(this.tracker.locY * 32.0D); this.zLoc = this.tracker.at.a(this.tracker.locZ); - DataWatcher datawatcher2 = this.tracker.getDataWatcher(); - - if (datawatcher2.a()) { - this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher2, false)); - } - + this.b(); this.w = true; } @@ -251,6 +238,25 @@ public class EntityTrackerEntry { } } + private void b() { + DataWatcher datawatcher = this.tracker.getDataWatcher(); + + if (datawatcher.a()) { + this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher, false)); + } + + if (this.tracker instanceof EntityLiving) { + AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).aT(); + Set set = attributemapserver.b(); + + if (!set.isEmpty()) { + this.broadcastIncludingSelf(new Packet44UpdateAttributes(this.tracker.id, set)); + } + + set.clear(); + } + } + public void broadcast(Packet packet) { Iterator iterator = this.trackedPlayers.iterator(); @@ -304,13 +310,22 @@ public class EntityTrackerEntry { // CraftBukkit end this.trackedPlayers.add(entityplayer); - Packet packet = this.b(); + Packet packet = this.c(); entityplayer.playerConnection.sendPacket(packet); if (!this.tracker.getDataWatcher().d()) { entityplayer.playerConnection.sendPacket(new Packet40EntityMetadata(this.tracker.id, this.tracker.getDataWatcher(), true)); } + if (this.tracker instanceof EntityLiving) { + AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).aT(); + Collection collection = attributemapserver.c(); + + if (!collection.isEmpty()) { + entityplayer.playerConnection.sendPacket(new Packet44UpdateAttributes(this.tracker.id, collection)); + } + } + this.j = this.tracker.motX; this.k = this.tracker.motY; this.l = this.tracker.motZ; @@ -320,9 +335,13 @@ public class EntityTrackerEntry { // CraftBukkit start if (this.tracker.vehicle != null && this.tracker.id > this.tracker.vehicle.id) { - entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, this.tracker, this.tracker.vehicle)); } else if (this.tracker.passenger != null && this.tracker.id > this.tracker.passenger.id) { - entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(this.tracker.passenger, this.tracker)); + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(0, this.tracker.passenger, this.tracker)); + } + + if (this.tracker instanceof EntityInsentient && ((EntityInsentient) this.tracker).bE() != null) { + entityplayer.playerConnection.sendPacket(new Packet39AttachEntity(1, this.tracker, ((EntityInsentient) this.tracker).bE())); } // CraftBukkit end @@ -368,7 +387,7 @@ public class EntityTrackerEntry { } private boolean d(EntityPlayer entityplayer) { - return entityplayer.o().getPlayerChunkMap().a(entityplayer, this.tracker.aj, this.tracker.al); + return entityplayer.p().getPlayerChunkMap().a(entityplayer, this.tracker.aj, this.tracker.al); } public void scanPlayers(List list) { @@ -377,7 +396,7 @@ public class EntityTrackerEntry { } } - private Packet b() { + private Packet c() { if (this.tracker.dead) { // CraftBukkit start - Remove useless error spam, just return // this.tracker.world.getLogger().warning("Fetching addPacket for removed entity"); @@ -461,6 +480,14 @@ public class EntityTrackerEntry { packet23vehiclespawn.c = MathHelper.d((float) (entityitemframe.y * 32)); packet23vehiclespawn.d = MathHelper.d((float) (entityitemframe.z * 32)); return packet23vehiclespawn; + } else if (this.tracker instanceof EntityLeash) { + EntityLeash entityleash = (EntityLeash) this.tracker; + + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 77); + packet23vehiclespawn.b = MathHelper.d((float) (entityleash.x * 32)); + packet23vehiclespawn.c = MathHelper.d((float) (entityleash.y * 32)); + packet23vehiclespawn.d = MathHelper.d((float) (entityleash.z * 32)); + return packet23vehiclespawn; } else if (this.tracker instanceof EntityExperienceOrb) { return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker); } else { |