EntityTrackerEntry

Server per-entity tracker: builds spawn packets and pushes S12 velocity, S14 movement and S18 teleports to tracking players.

net/minecraft/entity/EntityTrackerEntry.java

Updated 2026-09-12

Deep Analysis

Server per-entity tracker state machine. Decides spawn, delta move/look, velocity, metadata for each tick. Tick flow: updatePlayerList (range/ride/ItemFrame) -> motion branch (rel vs teleport) + head/velocity/metadata. Pushes via EntityPlayerMP.playerNetServerHandler to trackingPlayers set.

Key Methods in Depth (7)

updatePlayerList

Per-tick sync: range scan, attach, ItemFrame maps, movement branch.

updatePlayerList runs each server tick and first checks firstUpdateDone or distance squared over 16 to decide whether to rescan tracking membership via updatePlayerEntities. It detects ridingEntity changes or a 60-tick refresh and broadcasts S1BPacketEntityAttach type 0 so vehicle mounts stay glued on remote clients. For EntityItemFrame every 10 ticks it re-sends map data for displayed ItemMaps and forces sendMetadataToAllAssociatedPlayers for frame rotation. The main motion gate fires when updateCounter modulo updateFrequency is zero, isAirBorne is true, or DataWatcher reports a change, ensuring idle entities still heartbeat. Inside it encodes positions times 32 and rotations times 256 over 360, computes deltas against encoded caches, and sets flag for 4-unit move and flag1 for 4-unit look change. It chooses S15 rel-move, S16 look, S17 look-move or S18 teleport based on the 128-unit byte range, 400-tick forced teleport, ridingEntity and onGround flip, then handles S12 velocity and S19 head look. Finally it increments updateCounter and flushes velocityChanged via func_151261_b.

        if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataWatcher().hasObjectChanged())
        {
            if (this.trackedEntity.ridingEntity == null)
            {
                ++this.ticksSinceLastForcedTeleport;
                int k = MathHelper.floor_double(this.trackedEntity.posX * 32.0D);
                int j1 = MathHelper.floor_double(this.trackedEntity.posY * 32.0D);
                int k1 = MathHelper.floor_double(this.trackedEntity.posZ * 32.0D);
                int l1 = MathHelper.floor_float(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
                int i2 = MathHelper.floor_float(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
                int j2 = k - this.encodedPosX;
                int k2 = j1 - this.encodedPosY;
                int i = k1 - this.encodedPosZ;
                Packet packet1 = null;
                boolean flag = Math.abs(j2) >= 4 || Math.abs(k2) >= 4 || Math.abs(i) >= 4 || this.updateCounter % 60 == 0;
                boolean flag1 = Math.abs(l1 - this.encodedRotationYaw) >= 4 || Math.abs(i2 - this.encodedRotationPitch) >= 4;

                if (this.updateCounter > 0 || this.trackedEntity instanceof EntityArrow)
                {
                    if (j2 >= -128 && j2 < 128 && k2 >= -128 && k2 < 128 && i >= -128 && i < 128 && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity && this.onGround == this.trackedEntity.onGround)

The outer modulo plus isAirBorne plus hasObjectChanged condition throttles per-type updates, for example mobs every 3 ticks versus arrows every 20, while forcing immediate send on motion or metadata dirt. The times-32 and times-256 encoding lines convert doubles to fixed-point protocol units the client decodes, matching S14 byte deltas and S18 int positions. The flag and flag1 thresholds of 4 encoded units filter sub-pixel jitter to save bandwidth. The inner range check on -128 to 128 plus 400-tick and onGround tests selects cheap S14 deltas versus authoritative S18 teleport, which is why large teleports or long drift always correct with S18.

updatePlayerEntity

Adds/removes one player from tracking set with full spawn burst.

updatePlayerEntity manages one candidate player against one tracked entity, skipping when the player is the tracked entity itself to avoid self-tracking loops. It calls func_180233_c for XZ range plus spectator visibility, then requires either chunk watch via isPlayerWatchingThisChunk or forceSpawn to admit a new tracker. On admission it adds to trackingPlayers, sends createSpawnPacket as the entity-type-correct S0C, S0E, S0F, S10 or S11 birth packet, then follows with S1C metadata if the DataWatcher is non-blank. It sends S49 NBT when getNBTTagCompound is non-null, S20 attributes for watched collections, and caches motion into lastTracked fields for future S12 deltas. It sends S12 velocity immediately unless the spawn was S0F mob which already carries motion, then replays S1B attach for riding or leashed states, S04 equipment for five armor slots, S0A bed if sleeping, and S1D for each active potion. On range exit it removes from trackingPlayers and calls removeEntity which emits S13 destroy, keeping client worlds garbage-collected.

    public void updatePlayerEntity(EntityPlayerMP playerMP)
    {
        if (playerMP != this.trackedEntity)
        {
            if (this.func_180233_c(playerMP))
            {
                if (!this.trackingPlayers.contains(playerMP) && (this.isPlayerWatchingThisChunk(playerMP) || this.trackedEntity.forceSpawn))
                {
                    this.trackingPlayers.add(playerMP);
                    Packet packet = this.createSpawnPacket();
                    playerMP.playerNetServerHandler.sendPacket(packet);

                    if (!this.trackedEntity.getDataWatcher().getIsBlank())
                    {
                        playerMP.playerNetServerHandler.sendPacket(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), this.trackedEntity.getDataWatcher(), true));
                    }

                    NBTTagCompound nbttagcompound = this.trackedEntity.getNBTTagCompound();

                    if (nbttagcompound != null)
                    {
                        playerMP.playerNetServerHandler.sendPacket(new S49PacketUpdateEntityNBT(this.trackedEntity.getEntityId(), nbttagcompound));
                    }

                    if (this.trackedEntity instanceof EntityLivingBase)
                    {
                        ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();

The self-inequality plus func_180233_c plus isPlayerWatchingThisChunk chain ensures a player only receives entities in range, in a watched chunk and visible through spectator rules. createSpawnPacket returns the polymorphic birth packet the client needs to allocate the entity shell with correct ID and position. The S1C and S49 follow-ups hydrate DataWatcher flags and tile NBT that the spawn packet alone cannot carry. Missing this burst leaves invisible or untextured entities, while the else-branch S13 destroy on range exit is what removes them when walking away.

createSpawnPacket

Factory mapping entity class to spawn packet type.

createSpawnPacket is a type-switch factory that warns when the entity isDead yet still requested, then returns the exact spawn packet for each class. EntityItem maps to S0E type 2 data 1, EntityPlayerMP to S0C spawn player, minecarts to S0E type 10 with network ID, boats to S0E type 1, and IAnimals plus other EntityLivingBase to S0F mob with head yaw refresh. Projectiles use fixed S0E type IDs including 60 arrow with shooter ID, 61 snowball, 62 egg, 65 pearl, 72 eye, 73 potion with damage, 75 bottle, 76 firework, 90 fish hook with angler fallback, plus fireballs 63, 64 small, 66 wither with acceleration scaled by 8000. FallingBlock uses S0E 70 with Block.getStateId, armor stands 78, XP orbs S11, paintings S10 and item frames or leash knots S0E 71 or 77 with overridden fixed-point hanging coordinates. Any unknown class throws IllegalArgumentException, failing fast rather than sending a corrupt spawn. The caller updatePlayerEntity sends the result before metadata, attributes and equipment so the client has an ID to attach them to.

        else if (this.trackedEntity instanceof EntityArrow)
        {
            Entity entity = ((EntityArrow)this.trackedEntity).shootingEntity;
            return new S0EPacketSpawnObject(this.trackedEntity, 60, entity != null ? entity.getEntityId() : this.trackedEntity.getEntityId());
        }
        else if (this.trackedEntity instanceof EntitySnowball)
        {
            return new S0EPacketSpawnObject(this.trackedEntity, 61);
        }
        else if (this.trackedEntity instanceof EntityPotion)
        {
            return new S0EPacketSpawnObject(this.trackedEntity, 73, ((EntityPotion)this.trackedEntity).getPotionDamage());
        }
        else if (this.trackedEntity instanceof EntityExpBottle)
        {
            return new S0EPacketSpawnObject(this.trackedEntity, 75);
        }

Each branch constructs S0E with the hardcoded vanilla type ID the client uses to pick a renderer and physics, so 60 versus 61 versus 73 is not interchangeable. The arrow line threads shootingEntity ID with a self-ID fallback when the shooter is gone, letting the client attribute kill credit. The potion line passes getPotionDamage as the data int so the client shows the correct splash color and effect. Sending the wrong ID or data spawns the wrong visual or crashes old clients, which is why the final else throws instead of guessing.

sendMetadataToAllAssociatedPlayers

Pushes DataWatcher and attribute deltas.

sendMetadataToAllAssociatedPlayers first fetches the trackedEntity DataWatcher and checks hasObjectChanged to avoid spamming identical S1C packets every tick. On dirty it calls func_151261_b with S1CPacketEntityMetadata carrying entity ID, watcher and false for non-initial, which fans out to trackers plus the tracked player if it is an EntityPlayerMP. It then checks for EntityLivingBase, pulls the ServersideAttributeMap, and reads getAttributeInstanceSet as the delta set of recently modified max-health, speed or attack attributes. If that set is non-empty it sends S20PacketEntityProperties with the set through func_151261_b and immediately clears the set to prevent resend on the next tick. This two-channel push keeps flags like sneaking, hurt color and custom names via S1C separate from numeric attributes via S20. The method is called after every movement send and every 10 ticks for item frames, so metadata converges quickly. Suppressing it leaves ghost names or stale health scaling.

    private void sendMetadataToAllAssociatedPlayers()
    {
        DataWatcher datawatcher = this.trackedEntity.getDataWatcher();

        if (datawatcher.hasObjectChanged())
        {
            this.func_151261_b(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), datawatcher, false));
        }

        if (this.trackedEntity instanceof EntityLivingBase)
        {
            ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
            Set<IAttributeInstance> set = serversideattributemap.getAttributeInstanceSet();

            if (!set.isEmpty())
            {
                this.func_151261_b(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), set));
            }

            set.clear();
        }
    }

The hasObjectChanged guard reads the DataWatcher dirty flag set by updateObject calls, so S1C is only built when a watched byte actually flipped. func_151261_b is used instead of sendPacketToTrackedPlayers so the tracked player itself also receives its own metadata for self-render like skin flags. The attribute set fetch plus isEmpty check isolates numeric modifier changes that DataWatcher cannot express, sending them as S20. The trailing clear resets the delta set, meaning a lost S20 will not auto-retry until the attribute changes again.

sendPacketToTrackedPlayers/func_151261_b

Fan-out helpers with self-include variant.

sendPacketToTrackedPlayers iterates the trackingPlayers hash set and calls playerNetServerHandler.sendPacket for each member, delivering movement, look, metadata or velocity to exactly those in range. It performs no range recheck itself, relying on updatePlayerEntity and func_180233_c to maintain set membership, which makes it a cheap fan-out on the hot tick path. func_151261_b wraps it by first calling sendPacketToTrackedPlayers, then checking if trackedEntity is an EntityPlayerMP and echoing the same packet to that entity own channel. That self-include variant is used for S1C metadata, S20 attributes and S12 velocityChanged where the subject player must also see its own flags or knockback. Using the wrong helper hides self-effects like potion color or takes no knockback visually. Both take a generic Packet so S14, S18, S19 and S1B all flow through the same loop. The design separates observer sync from subject sync with one branch.

    public void sendPacketToTrackedPlayers(Packet packetIn)
    {
        for (EntityPlayerMP entityplayermp : this.trackingPlayers)
        {
            entityplayermp.playerNetServerHandler.sendPacket(packetIn);
        }
    }

    public void func_151261_b(Packet packetIn)
    {
        this.sendPacketToTrackedPlayers(packetIn);

        if (this.trackedEntity instanceof EntityPlayerMP)
        {
            ((EntityPlayerMP)this.trackedEntity).playerNetServerHandler.sendPacket(packetIn);
        }
    }

The for loop over trackingPlayers shows the fan-out cost scales with observer count, each sendPacket queuing on that player Netty channel. The packetIn parameter is opaque, so the same loop carries tiny S14 deltas and large S20 lists without branching. func_151261_b adds the instanceof EntityPlayerMP self-echo, which is required because a player does not track itself in trackingPlayers. Choosing between the two controls whether the subject sees its own S12 knockback or S1C name flags, a frequent source of self-desync bugs when misused.

removeFromTrackedPlayers/removeTrackedPlayerSymmetric

Stops tracking and destroys entity client-side.

sendDestroyEntityPacketToTrackedPlayers loops trackingPlayers and calls removeEntity on each, which for players sends immediate S13 and for other entities queues into destroyedItemsNetCache for batched S13. removeFromTrackedPlayers checks contains before acting, then calls playerMP.removeEntity to destroy the client-side copy and removes the player from the set to stop future sends. removeTrackedPlayerSymmetric is the symmetric alias used on chunk unload or dimension change, performing the same contains, remove and removeEntity sequence. Together they ensure no stale entity shells linger after range exit, logout or chunk unload. Forgetting the removeEntity call leaks ghost mobs that float until the next S18 or relog. The S13 carries only entity IDs, so the client looks up and deletes the matching world entry. These paths are the only clean teardown for tracker membership.

    public void sendDestroyEntityPacketToTrackedPlayers()
    {
        for (EntityPlayerMP entityplayermp : this.trackingPlayers)
        {
            entityplayermp.removeEntity(this.trackedEntity);
        }
    }

    public void removeFromTrackedPlayers(EntityPlayerMP playerMP)
    {
        if (this.trackingPlayers.contains(playerMP))
        {
            playerMP.removeEntity(this.trackedEntity);
            this.trackingPlayers.remove(playerMP);
        }
    }

The destroy loop delegates to EntityPlayerMP.removeEntity, which decides between instant S13 for players and batched cache for others, explaining why player logouts vanish instantly. The contains guard prevents double-destroy S13s that would make the client delete a reused entity ID. removeEntity triggers the S13 with the tracked entity ID so the client can free the renderer and physics. The symmetric variant repeats this pattern for unload paths, so skipping either leaves ghost entities that still receive S14 moves.

func_180233_c

Range + spectator visibility gate.

func_180233_c computes d0 as player X minus encodedPosX divided by 32 and d1 as player Z minus encodedPosZ divided by 32, converting the fixed-point cache back to block units. It checks d0 and d1 against plus and minus trackingDistanceThreshold, which varies by entity type such as 64 for items or 512 for dragons. It also calls trackedEntity.isSpectatedByPlayer to enforce spectator invisibility, hiding non-spectated entities from spectator cameras and vice versa. It ignores Y distance entirely, so vertical range does not gate tracking in 1.8.9. The result gates updatePlayerEntity admission and retention, preventing bandwidth waste on far entities. A false return triggers removal plus S13 destroy, while true plus chunk watch triggers the full spawn burst. Cheats cannot force the server to send out-of-range entities because this gate runs before every send.

    public boolean func_180233_c(EntityPlayerMP playerMP)
    {
        double d0 = playerMP.posX - (double)(this.encodedPosX / 32);
        double d1 = playerMP.posZ - (double)(this.encodedPosZ / 32);
        return d0 >= (double)(-this.trackingDistanceThreshold) && d0 <= (double)this.trackingDistanceThreshold && d1 >= (double)(-this.trackingDistanceThreshold) && d1 <= (double)this.trackingDistanceThreshold && this.trackedEntity.isSpectatedByPlayer(playerMP);
    }

    private boolean isPlayerWatchingThisChunk(EntityPlayerMP playerMP)
    {
        return playerMP.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(playerMP, this.trackedEntity.chunkCoordX, this.trackedEntity.chunkCoordZ);
    }

The d0 and d1 lines decode the last-sent position by integer-dividing the fixed-point cache, noting the int division truncation before cast. The long return line ANDs four range comparisons with isSpectatedByPlayer, so all five must pass to keep tracking. isPlayerWatchingThisChunk below adds a second chunk-visibility requirement checked alongside this gate in updatePlayerEntity. Together they explain why entities pop in at chunk borders or vanish when spectating, and why radar hacks cannot see beyond trackingDistanceThreshold.

Packet Usage

PacketDirTrigger
S0CsentPlayer spawn burst in createSpawnPacket.
S0EsentItem/projectile/object spawn by type ID.
S12sentMotion delta >0.02 or velocityChanged flag.
S14sentSmall delta move/look within +-128 and 400-tick window.
S18sentLarge delta, 400-tick force sync, or ground change.
S19sentHead yaw change >=4/256.
S1BsentRide/leash change.
S1CsentDataWatcher dirty.
S20sentAttribute set non-empty.
S04/S0A/S49sentInitial burst equipment/bed/NBT.

Internal State

trackedEntity/trackingPlayersWatched entity and subscribed EntityPlayerMP set
encodedPosX/Y/Z + RotationYaw/PitchLast sent fixed-point pos (*32) and angle (*256/360) for delta
updateFrequency/trackingDistanceThresholdPer-type tick divisor and XZ range gate
ticksSinceLastForcedTeleportForces S18 every 400 ticks to fix drift
lastTrackedEntityMotionX/Y/motionZLast sent velocity; 0.02 threshold for S12
updateCounter/firstUpdateDoneTick count and initial scan flag with 16-block moved check

Related Vanilla Internals

Full Source

EntityTrackerEntry.java646 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity;
2
3
import com.google.common.collect.Sets;
4
import java.util.Collection;
5
import java.util.List;
6
import java.util.Set;
7
import net.minecraft.block.Block;
8
import net.minecraft.entity.ai.attributes.IAttributeInstance;
9
import net.minecraft.entity.ai.attributes.ServersideAttributeMap;
10
import net.minecraft.entity.item.EntityArmorStand;
11
import net.minecraft.entity.item.EntityBoat;
12
import net.minecraft.entity.item.EntityEnderCrystal;
13
import net.minecraft.entity.item.EntityEnderEye;
14
import net.minecraft.entity.item.EntityEnderPearl;
15
import net.minecraft.entity.item.EntityExpBottle;
16
import net.minecraft.entity.item.EntityFallingBlock;
17
import net.minecraft.entity.item.EntityFireworkRocket;
18
import net.minecraft.entity.item.EntityItem;
19
import net.minecraft.entity.item.EntityItemFrame;
20
import net.minecraft.entity.item.EntityMinecart;
21
import net.minecraft.entity.item.EntityPainting;
22
import net.minecraft.entity.item.EntityTNTPrimed;
23
import net.minecraft.entity.item.EntityXPOrb;
24
import net.minecraft.entity.passive.IAnimals;
25
import net.minecraft.entity.player.EntityPlayer;
26
import net.minecraft.entity.player.EntityPlayerMP;
27
import net.minecraft.entity.projectile.EntityArrow;
28
import net.minecraft.entity.projectile.EntityEgg;
29
import net.minecraft.entity.projectile.EntityFireball;
30
import net.minecraft.entity.projectile.EntityFishHook;
31
import net.minecraft.entity.projectile.EntityPotion;
32
import net.minecraft.entity.projectile.EntitySmallFireball;
33
import net.minecraft.entity.projectile.EntitySnowball;
34
import net.minecraft.entity.projectile.EntityWitherSkull;
35
import net.minecraft.init.Items;
36
import net.minecraft.item.ItemMap;
37
import net.minecraft.item.ItemStack;
38
import net.minecraft.nbt.NBTTagCompound;
39
import net.minecraft.network.Packet;
40
import net.minecraft.network.play.server.S04PacketEntityEquipment;
41
import net.minecraft.network.play.server.S0APacketUseBed;
42
import net.minecraft.network.play.server.S0CPacketSpawnPlayer;
43
import net.minecraft.network.play.server.S0EPacketSpawnObject;
44
import net.minecraft.network.play.server.S0FPacketSpawnMob;
45
import net.minecraft.network.play.server.S10PacketSpawnPainting;
46
import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb;
47
import net.minecraft.network.play.server.S12PacketEntityVelocity;
48
import net.minecraft.network.play.server.S14PacketEntity;
49
import net.minecraft.network.play.server.S18PacketEntityTeleport;
50
import net.minecraft.network.play.server.S19PacketEntityHeadLook;
51
import net.minecraft.network.play.server.S1BPacketEntityAttach;
52
import net.minecraft.network.play.server.S1CPacketEntityMetadata;
53
import net.minecraft.network.play.server.S1DPacketEntityEffect;
54
import net.minecraft.network.play.server.S20PacketEntityProperties;
55
import net.minecraft.network.play.server.S49PacketUpdateEntityNBT;
56
import net.minecraft.potion.PotionEffect;
57
import net.minecraft.util.BlockPos;
58
import net.minecraft.util.MathHelper;
59
import net.minecraft.world.storage.MapData;
60
import org.apache.logging.log4j.LogManager;
61
import org.apache.logging.log4j.Logger;
62
63
public class EntityTrackerEntry
64
{
65
    private static final Logger logger = LogManager.getLogger();
66
67
    /** The entity that this EntityTrackerEntry tracks. */
68
    public Entity trackedEntity;
69
    public int trackingDistanceThreshold;
70
71
    /** check for sync when ticks % updateFrequency==0 */
72
    public int updateFrequency;
73
74
    /** The encoded entity X position. */
75
    public int encodedPosX;
76
77
    /** The encoded entity Y position. */
78
    public int encodedPosY;
79
80
    /** The encoded entity Z position. */
81
    public int encodedPosZ;
82
83
    /** The encoded entity yaw rotation. */
84
    public int encodedRotationYaw;
85
86
    /** The encoded entity pitch rotation. */
87
    public int encodedRotationPitch;
88
    public int lastHeadMotion;
89
    public double lastTrackedEntityMotionX;
90
    public double lastTrackedEntityMotionY;
91
    public double motionZ;
92
    public int updateCounter;
93
    private double lastTrackedEntityPosX;
94
    private double lastTrackedEntityPosY;
95
    private double lastTrackedEntityPosZ;
96
    private boolean firstUpdateDone;
97
    private boolean sendVelocityUpdates;
98
99
    /**
100
     * every 400 ticks a  full teleport packet is sent, rather than just a "move me +x" command, so that position
101
     * remains fully synced.
102
     */
103
    private int ticksSinceLastForcedTeleport;
104
    private Entity field_85178_v;
105
    private boolean ridingEntity;
106
    private boolean onGround;
107
    public boolean playerEntitiesUpdated;
108
    public Set<EntityPlayerMP> trackingPlayers = Sets.<EntityPlayerMP>newHashSet();
109
110
    public EntityTrackerEntry(Entity trackedEntityIn, int trackingDistanceThresholdIn, int updateFrequencyIn, boolean sendVelocityUpdatesIn)
111
    {
112
        this.trackedEntity = trackedEntityIn;
113
        this.trackingDistanceThreshold = trackingDistanceThresholdIn;
114
        this.updateFrequency = updateFrequencyIn;
115
        this.sendVelocityUpdates = sendVelocityUpdatesIn;
116
        this.encodedPosX = MathHelper.floor_double(trackedEntityIn.posX * 32.0D);
117
        this.encodedPosY = MathHelper.floor_double(trackedEntityIn.posY * 32.0D);
118
        this.encodedPosZ = MathHelper.floor_double(trackedEntityIn.posZ * 32.0D);
119
        this.encodedRotationYaw = MathHelper.floor_float(trackedEntityIn.rotationYaw * 256.0F / 360.0F);
120
        this.encodedRotationPitch = MathHelper.floor_float(trackedEntityIn.rotationPitch * 256.0F / 360.0F);
121
        this.lastHeadMotion = MathHelper.floor_float(trackedEntityIn.getRotationYawHead() * 256.0F / 360.0F);
122
        this.onGround = trackedEntityIn.onGround;
123
    }
124
125
    public boolean equals(Object p_equals_1_)
126
    {
127
        return p_equals_1_ instanceof EntityTrackerEntry ? ((EntityTrackerEntry)p_equals_1_).trackedEntity.getEntityId() == this.trackedEntity.getEntityId() : false;
128
    }
129
130
    public int hashCode()
131
    {
132
        return this.trackedEntity.getEntityId();
133
    }
134
135
    public void updatePlayerList(List<EntityPlayer> players)
136
    {
137
        this.playerEntitiesUpdated = false;
138
139
        if (!this.firstUpdateDone || this.trackedEntity.getDistanceSq(this.lastTrackedEntityPosX, this.lastTrackedEntityPosY, this.lastTrackedEntityPosZ) > 16.0D)
140
        {
141
            this.lastTrackedEntityPosX = this.trackedEntity.posX;
142
            this.lastTrackedEntityPosY = this.trackedEntity.posY;
143
            this.lastTrackedEntityPosZ = this.trackedEntity.posZ;
144
            this.firstUpdateDone = true;
145
            this.playerEntitiesUpdated = true;
146
            this.updatePlayerEntities(players);
147
        }
148
149
        if (this.field_85178_v != this.trackedEntity.ridingEntity || this.trackedEntity.ridingEntity != null && this.updateCounter % 60 == 0)
150
        {
151
            this.field_85178_v = this.trackedEntity.ridingEntity;
152
            this.sendPacketToTrackedPlayers(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.ridingEntity));
153
        }
154
155
        if (this.trackedEntity instanceof EntityItemFrame && this.updateCounter % 10 == 0)
156
        {
157
            EntityItemFrame entityitemframe = (EntityItemFrame)this.trackedEntity;
158
            ItemStack itemstack = entityitemframe.getDisplayedItem();
159
160
            if (itemstack != null && itemstack.getItem() instanceof ItemMap)
161
            {
162
                MapData mapdata = Items.filled_map.getMapData(itemstack, this.trackedEntity.worldObj);
163
164
                for (EntityPlayer entityplayer : players)
165
                {
166
                    EntityPlayerMP entityplayermp = (EntityPlayerMP)entityplayer;
167
                    mapdata.updateVisiblePlayers(entityplayermp, itemstack);
168
                    Packet packet = Items.filled_map.createMapDataPacket(itemstack, this.trackedEntity.worldObj, entityplayermp);
169
170
                    if (packet != null)
171
                    {
172
                        entityplayermp.playerNetServerHandler.sendPacket(packet);
173
                    }
174
                }
175
            }
176
177
            this.sendMetadataToAllAssociatedPlayers();
178
        }
179
180
        if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataWatcher().hasObjectChanged())
181
        {
182
            if (this.trackedEntity.ridingEntity == null)
183
            {
184
                ++this.ticksSinceLastForcedTeleport;
185
                int k = MathHelper.floor_double(this.trackedEntity.posX * 32.0D);
186
                int j1 = MathHelper.floor_double(this.trackedEntity.posY * 32.0D);
187
                int k1 = MathHelper.floor_double(this.trackedEntity.posZ * 32.0D);
188
                int l1 = MathHelper.floor_float(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
189
                int i2 = MathHelper.floor_float(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
190
                int j2 = k - this.encodedPosX;
191
                int k2 = j1 - this.encodedPosY;
192
                int i = k1 - this.encodedPosZ;
193
                Packet packet1 = null;
194
                boolean flag = Math.abs(j2) >= 4 || Math.abs(k2) >= 4 || Math.abs(i) >= 4 || this.updateCounter % 60 == 0;
195
                boolean flag1 = Math.abs(l1 - this.encodedRotationYaw) >= 4 || Math.abs(i2 - this.encodedRotationPitch) >= 4;
196
197
                if (this.updateCounter > 0 || this.trackedEntity instanceof EntityArrow)
198
                {
199
                    if (j2 >= -128 && j2 < 128 && k2 >= -128 && k2 < 128 && i >= -128 && i < 128 && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity && this.onGround == this.trackedEntity.onGround)
200
                    {
201
                        if ((!flag || !flag1) && !(this.trackedEntity instanceof EntityArrow))
202
                        {
203
                            if (flag)
204
                            {
205
                                packet1 = new S14PacketEntity.S15PacketEntityRelMove(this.trackedEntity.getEntityId(), (byte)j2, (byte)k2, (byte)i, this.trackedEntity.onGround);
206
                            }
207
                            else if (flag1)
208
                            {
209
                                packet1 = new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte)l1, (byte)i2, this.trackedEntity.onGround);
210
                            }
211
                        }
212
                        else
213
                        {
214
                            packet1 = new S14PacketEntity.S17PacketEntityLookMove(this.trackedEntity.getEntityId(), (byte)j2, (byte)k2, (byte)i, (byte)l1, (byte)i2, this.trackedEntity.onGround);
215
                        }
216
                    }
217
                    else
218
                    {
219
                        this.onGround = this.trackedEntity.onGround;
220
                        this.ticksSinceLastForcedTeleport = 0;
221
                        packet1 = new S18PacketEntityTeleport(this.trackedEntity.getEntityId(), k, j1, k1, (byte)l1, (byte)i2, this.trackedEntity.onGround);
222
                    }
223
                }
224
225
                if (this.sendVelocityUpdates)
226
                {
227
                    double d0 = this.trackedEntity.motionX - this.lastTrackedEntityMotionX;
228
                    double d1 = this.trackedEntity.motionY - this.lastTrackedEntityMotionY;
229
                    double d2 = this.trackedEntity.motionZ - this.motionZ;
230
                    double d3 = 0.02D;
231
                    double d4 = d0 * d0 + d1 * d1 + d2 * d2;
232
233
                    if (d4 > d3 * d3 || d4 > 0.0D && this.trackedEntity.motionX == 0.0D && this.trackedEntity.motionY == 0.0D && this.trackedEntity.motionZ == 0.0D)
234
                    {
235
                        this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
236
                        this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
237
                        this.motionZ = this.trackedEntity.motionZ;
238
                        this.sendPacketToTrackedPlayers(new S12PacketEntityVelocity(this.trackedEntity.getEntityId(), this.lastTrackedEntityMotionX, this.lastTrackedEntityMotionY, this.motionZ));
239
                    }
240
                }
241
242
                if (packet1 != null)
243
                {
244
                    this.sendPacketToTrackedPlayers(packet1);
245
                }
246
247
                this.sendMetadataToAllAssociatedPlayers();
248
249
                if (flag)
250
                {
251
                    this.encodedPosX = k;
252
                    this.encodedPosY = j1;
253
                    this.encodedPosZ = k1;
254
                }
255
256
                if (flag1)
257
                {
258
                    this.encodedRotationYaw = l1;
259
                    this.encodedRotationPitch = i2;
260
                }
261
262
                this.ridingEntity = false;
263
            }
264
            else
265
            {
266
                int j = MathHelper.floor_float(this.trackedEntity.rotationYaw * 256.0F / 360.0F);
267
                int i1 = MathHelper.floor_float(this.trackedEntity.rotationPitch * 256.0F / 360.0F);
268
                boolean flag2 = Math.abs(j - this.encodedRotationYaw) >= 4 || Math.abs(i1 - this.encodedRotationPitch) >= 4;
269
270
                if (flag2)
271
                {
272
                    this.sendPacketToTrackedPlayers(new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte)j, (byte)i1, this.trackedEntity.onGround));
273
                    this.encodedRotationYaw = j;
274
                    this.encodedRotationPitch = i1;
275
                }
276
277
                this.encodedPosX = MathHelper.floor_double(this.trackedEntity.posX * 32.0D);
278
                this.encodedPosY = MathHelper.floor_double(this.trackedEntity.posY * 32.0D);
279
                this.encodedPosZ = MathHelper.floor_double(this.trackedEntity.posZ * 32.0D);
280
                this.sendMetadataToAllAssociatedPlayers();
281
                this.ridingEntity = true;
282
            }
283
284
            int l = MathHelper.floor_float(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
285
286
            if (Math.abs(l - this.lastHeadMotion) >= 4)
287
            {
288
                this.sendPacketToTrackedPlayers(new S19PacketEntityHeadLook(this.trackedEntity, (byte)l));
289
                this.lastHeadMotion = l;
290
            }
291
292
            this.trackedEntity.isAirBorne = false;
293
        }
294
295
        ++this.updateCounter;
296
297
        if (this.trackedEntity.velocityChanged)
298
        {
299
            this.func_151261_b(new S12PacketEntityVelocity(this.trackedEntity));
300
            this.trackedEntity.velocityChanged = false;
301
        }
302
    }
303
304
    /**
305
     * Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity
306
     * itself if a player.
307
     */
308
    private void sendMetadataToAllAssociatedPlayers()
309
    {
310
        DataWatcher datawatcher = this.trackedEntity.getDataWatcher();
311
312
        if (datawatcher.hasObjectChanged())
313
        {
314
            this.func_151261_b(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), datawatcher, false));
315
        }
316
317
        if (this.trackedEntity instanceof EntityLivingBase)
318
        {
319
            ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
320
            Set<IAttributeInstance> set = serversideattributemap.getAttributeInstanceSet();
321
322
            if (!set.isEmpty())
323
            {
324
                this.func_151261_b(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), set));
325
            }
326
327
            set.clear();
328
        }
329
    }
330
331
    /**
332
     * Send the given packet to all players tracking this entity.
333
     */
334
    public void sendPacketToTrackedPlayers(Packet packetIn)
335
    {
336
        for (EntityPlayerMP entityplayermp : this.trackingPlayers)
337
        {
338
            entityplayermp.playerNetServerHandler.sendPacket(packetIn);
339
        }
340
    }
341
342
    public void func_151261_b(Packet packetIn)
343
    {
344
        this.sendPacketToTrackedPlayers(packetIn);
345
346
        if (this.trackedEntity instanceof EntityPlayerMP)
347
        {
348
            ((EntityPlayerMP)this.trackedEntity).playerNetServerHandler.sendPacket(packetIn);
349
        }
350
    }
351
352
    public void sendDestroyEntityPacketToTrackedPlayers()
353
    {
354
        for (EntityPlayerMP entityplayermp : this.trackingPlayers)
355
        {
356
            entityplayermp.removeEntity(this.trackedEntity);
357
        }
358
    }
359
360
    public void removeFromTrackedPlayers(EntityPlayerMP playerMP)
361
    {
362
        if (this.trackingPlayers.contains(playerMP))
363
        {
364
            playerMP.removeEntity(this.trackedEntity);
365
            this.trackingPlayers.remove(playerMP);
366
        }
367
    }
368
369
    public void updatePlayerEntity(EntityPlayerMP playerMP)
370
    {
371
        if (playerMP != this.trackedEntity)
372
        {
373
            if (this.func_180233_c(playerMP))
374
            {
375
                if (!this.trackingPlayers.contains(playerMP) && (this.isPlayerWatchingThisChunk(playerMP) || this.trackedEntity.forceSpawn))
376
                {
377
                    this.trackingPlayers.add(playerMP);
378
                    Packet packet = this.createSpawnPacket();
379
                    playerMP.playerNetServerHandler.sendPacket(packet);
380
381
                    if (!this.trackedEntity.getDataWatcher().getIsBlank())
382
                    {
383
                        playerMP.playerNetServerHandler.sendPacket(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), this.trackedEntity.getDataWatcher(), true));
384
                    }
385
386
                    NBTTagCompound nbttagcompound = this.trackedEntity.getNBTTagCompound();
387
388
                    if (nbttagcompound != null)
389
                    {
390
                        playerMP.playerNetServerHandler.sendPacket(new S49PacketUpdateEntityNBT(this.trackedEntity.getEntityId(), nbttagcompound));
391
                    }
392
393
                    if (this.trackedEntity instanceof EntityLivingBase)
394
                    {
395
                        ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
396
                        Collection<IAttributeInstance> collection = serversideattributemap.getWatchedAttributes();
397
398
                        if (!collection.isEmpty())
399
                        {
400
                            playerMP.playerNetServerHandler.sendPacket(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), collection));
401
                        }
402
                    }
403
404
                    this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
405
                    this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
406
                    this.motionZ = this.trackedEntity.motionZ;
407
408
                    if (this.sendVelocityUpdates && !(packet instanceof S0FPacketSpawnMob))
409
                    {
410
                        playerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(this.trackedEntity.getEntityId(), this.trackedEntity.motionX, this.trackedEntity.motionY, this.trackedEntity.motionZ));
411
                    }
412
413
                    if (this.trackedEntity.ridingEntity != null)
414
                    {
415
                        playerMP.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.ridingEntity));
416
                    }
417
418
                    if (this.trackedEntity instanceof EntityLiving && ((EntityLiving)this.trackedEntity).getLeashedToEntity() != null)
419
                    {
420
                        playerMP.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedToEntity()));
421
                    }
422
423
                    if (this.trackedEntity instanceof EntityLivingBase)
424
                    {
425
                        for (int i = 0; i < 5; ++i)
426
                        {
427
                            ItemStack itemstack = ((EntityLivingBase)this.trackedEntity).getEquipmentInSlot(i);
428
429
                            if (itemstack != null)
430
                            {
431
                                playerMP.playerNetServerHandler.sendPacket(new S04PacketEntityEquipment(this.trackedEntity.getEntityId(), i, itemstack));
432
                            }
433
                        }
434
                    }
435
436
                    if (this.trackedEntity instanceof EntityPlayer)
437
                    {
438
                        EntityPlayer entityplayer = (EntityPlayer)this.trackedEntity;
439
440
                        if (entityplayer.isPlayerSleeping())
441
                        {
442
                            playerMP.playerNetServerHandler.sendPacket(new S0APacketUseBed(entityplayer, new BlockPos(this.trackedEntity)));
443
                        }
444
                    }
445
446
                    if (this.trackedEntity instanceof EntityLivingBase)
447
                    {
448
                        EntityLivingBase entitylivingbase = (EntityLivingBase)this.trackedEntity;
449
450
                        for (PotionEffect potioneffect : entitylivingbase.getActivePotionEffects())
451
                        {
452
                            playerMP.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(this.trackedEntity.getEntityId(), potioneffect));
453
                        }
454
                    }
455
                }
456
            }
457
            else if (this.trackingPlayers.contains(playerMP))
458
            {
459
                this.trackingPlayers.remove(playerMP);
460
                playerMP.removeEntity(this.trackedEntity);
461
            }
462
        }
463
    }
464
465
    public boolean func_180233_c(EntityPlayerMP playerMP)
466
    {
467
        double d0 = playerMP.posX - (double)(this.encodedPosX / 32);
468
        double d1 = playerMP.posZ - (double)(this.encodedPosZ / 32);
469
        return d0 >= (double)(-this.trackingDistanceThreshold) && d0 <= (double)this.trackingDistanceThreshold && d1 >= (double)(-this.trackingDistanceThreshold) && d1 <= (double)this.trackingDistanceThreshold && this.trackedEntity.isSpectatedByPlayer(playerMP);
470
    }
471
472
    private boolean isPlayerWatchingThisChunk(EntityPlayerMP playerMP)
473
    {
474
        return playerMP.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(playerMP, this.trackedEntity.chunkCoordX, this.trackedEntity.chunkCoordZ);
475
    }
476
477
    public void updatePlayerEntities(List<EntityPlayer> players)
478
    {
479
        for (int i = 0; i < players.size(); ++i)
480
        {
481
            this.updatePlayerEntity((EntityPlayerMP)players.get(i));
482
        }
483
    }
484
485
    /**
486
     * Creates a spawn packet for the entity managed by this entry.
487
     */
488
    private Packet createSpawnPacket()
489
    {
490
        if (this.trackedEntity.isDead)
491
        {
492
            logger.warn("Fetching addPacket for removed entity");
493
        }
494
495
        if (this.trackedEntity instanceof EntityItem)
496
        {
497
            return new S0EPacketSpawnObject(this.trackedEntity, 2, 1);
498
        }
499
        else if (this.trackedEntity instanceof EntityPlayerMP)
500
        {
501
            return new S0CPacketSpawnPlayer((EntityPlayer)this.trackedEntity);
502
        }
503
        else if (this.trackedEntity instanceof EntityMinecart)
504
        {
505
            EntityMinecart entityminecart = (EntityMinecart)this.trackedEntity;
506
            return new S0EPacketSpawnObject(this.trackedEntity, 10, entityminecart.getMinecartType().getNetworkID());
507
        }
508
        else if (this.trackedEntity instanceof EntityBoat)
509
        {
510
            return new S0EPacketSpawnObject(this.trackedEntity, 1);
511
        }
512
        else if (this.trackedEntity instanceof IAnimals)
513
        {
514
            this.lastHeadMotion = MathHelper.floor_float(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
515
            return new S0FPacketSpawnMob((EntityLivingBase)this.trackedEntity);
516
        }
517
        else if (this.trackedEntity instanceof EntityFishHook)
518
        {
519
            Entity entity1 = ((EntityFishHook)this.trackedEntity).angler;
520
            return new S0EPacketSpawnObject(this.trackedEntity, 90, entity1 != null ? entity1.getEntityId() : this.trackedEntity.getEntityId());
521
        }
522
        else if (this.trackedEntity instanceof EntityArrow)
523
        {
524
            Entity entity = ((EntityArrow)this.trackedEntity).shootingEntity;
525
            return new S0EPacketSpawnObject(this.trackedEntity, 60, entity != null ? entity.getEntityId() : this.trackedEntity.getEntityId());
526
        }
527
        else if (this.trackedEntity instanceof EntitySnowball)
528
        {
529
            return new S0EPacketSpawnObject(this.trackedEntity, 61);
530
        }
531
        else if (this.trackedEntity instanceof EntityPotion)
532
        {
533
            return new S0EPacketSpawnObject(this.trackedEntity, 73, ((EntityPotion)this.trackedEntity).getPotionDamage());
534
        }
535
        else if (this.trackedEntity instanceof EntityExpBottle)
536
        {
537
            return new S0EPacketSpawnObject(this.trackedEntity, 75);
538
        }
539
        else if (this.trackedEntity instanceof EntityEnderPearl)
540
        {
541
            return new S0EPacketSpawnObject(this.trackedEntity, 65);
542
        }
543
        else if (this.trackedEntity instanceof EntityEnderEye)
544
        {
545
            return new S0EPacketSpawnObject(this.trackedEntity, 72);
546
        }
547
        else if (this.trackedEntity instanceof EntityFireworkRocket)
548
        {
549
            return new S0EPacketSpawnObject(this.trackedEntity, 76);
550
        }
551
        else if (this.trackedEntity instanceof EntityFireball)
552
        {
553
            EntityFireball entityfireball = (EntityFireball)this.trackedEntity;
554
            S0EPacketSpawnObject s0epacketspawnobject2 = null;
555
            int i = 63;
556
557
            if (this.trackedEntity instanceof EntitySmallFireball)
558
            {
559
                i = 64;
560
            }
561
            else if (this.trackedEntity instanceof EntityWitherSkull)
562
            {
563
                i = 66;
564
            }
565
566
            if (entityfireball.shootingEntity != null)
567
            {
568
                s0epacketspawnobject2 = new S0EPacketSpawnObject(this.trackedEntity, i, ((EntityFireball)this.trackedEntity).shootingEntity.getEntityId());
569
            }
570
            else
571
            {
572
                s0epacketspawnobject2 = new S0EPacketSpawnObject(this.trackedEntity, i, 0);
573
            }
574
575
            s0epacketspawnobject2.setSpeedX((int)(entityfireball.accelerationX * 8000.0D));
576
            s0epacketspawnobject2.setSpeedY((int)(entityfireball.accelerationY * 8000.0D));
577
            s0epacketspawnobject2.setSpeedZ((int)(entityfireball.accelerationZ * 8000.0D));
578
            return s0epacketspawnobject2;
579
        }
580
        else if (this.trackedEntity instanceof EntityEgg)
581
        {
582
            return new S0EPacketSpawnObject(this.trackedEntity, 62);
583
        }
584
        else if (this.trackedEntity instanceof EntityTNTPrimed)
585
        {
586
            return new S0EPacketSpawnObject(this.trackedEntity, 50);
587
        }
588
        else if (this.trackedEntity instanceof EntityEnderCrystal)
589
        {
590
            return new S0EPacketSpawnObject(this.trackedEntity, 51);
591
        }
592
        else if (this.trackedEntity instanceof EntityFallingBlock)
593
        {
594
            EntityFallingBlock entityfallingblock = (EntityFallingBlock)this.trackedEntity;
595
            return new S0EPacketSpawnObject(this.trackedEntity, 70, Block.getStateId(entityfallingblock.getBlock()));
596
        }
597
        else if (this.trackedEntity instanceof EntityArmorStand)
598
        {
599
            return new S0EPacketSpawnObject(this.trackedEntity, 78);
600
        }
601
        else if (this.trackedEntity instanceof EntityPainting)
602
        {
603
            return new S10PacketSpawnPainting((EntityPainting)this.trackedEntity);
604
        }
605
        else if (this.trackedEntity instanceof EntityItemFrame)
606
        {
607
            EntityItemFrame entityitemframe = (EntityItemFrame)this.trackedEntity;
608
            S0EPacketSpawnObject s0epacketspawnobject1 = new S0EPacketSpawnObject(this.trackedEntity, 71, entityitemframe.facingDirection.getHorizontalIndex());
609
            BlockPos blockpos1 = entityitemframe.getHangingPosition();
610
            s0epacketspawnobject1.setX(MathHelper.floor_float((float)(blockpos1.getX() * 32)));
611
            s0epacketspawnobject1.setY(MathHelper.floor_float((float)(blockpos1.getY() * 32)));
612
            s0epacketspawnobject1.setZ(MathHelper.floor_float((float)(blockpos1.getZ() * 32)));
613
            return s0epacketspawnobject1;
614
        }
615
        else if (this.trackedEntity instanceof EntityLeashKnot)
616
        {
617
            EntityLeashKnot entityleashknot = (EntityLeashKnot)this.trackedEntity;
618
            S0EPacketSpawnObject s0epacketspawnobject = new S0EPacketSpawnObject(this.trackedEntity, 77);
619
            BlockPos blockpos = entityleashknot.getHangingPosition();
620
            s0epacketspawnobject.setX(MathHelper.floor_float((float)(blockpos.getX() * 32)));
621
            s0epacketspawnobject.setY(MathHelper.floor_float((float)(blockpos.getY() * 32)));
622
            s0epacketspawnobject.setZ(MathHelper.floor_float((float)(blockpos.getZ() * 32)));
623
            return s0epacketspawnobject;
624
        }
625
        else if (this.trackedEntity instanceof EntityXPOrb)
626
        {
627
            return new S11PacketSpawnExperienceOrb((EntityXPOrb)this.trackedEntity);
628
        }
629
        else
630
        {
631
            throw new IllegalArgumentException("Don\'t know how to add " + this.trackedEntity.getClass() + "!");
632
        }
633
    }
634
635
    /**
636
     * Remove a tracked player from our list and tell the tracked player to destroy us from their world.
637
     */
638
    public void removeTrackedPlayerSymmetric(EntityPlayerMP playerMP)
639
    {
640
        if (this.trackingPlayers.contains(playerMP))
641
        {
642
            this.trackingPlayers.remove(playerMP);
643
            playerMP.removeEntity(this.trackedEntity);
644
        }
645
    }
646
}

Deobfuscated MCP 1.8.9 source of EntityTrackerEntry from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/EntityTrackerEntry.java), stored verbatim.