Exemplo n.º 1
0
        public virtual void Func_543_c(net.minecraft.src.EntityPlayerMP entityplayermp)
        {
            int    i  = (int)entityplayermp.posX >> 4;
            int    j  = (int)entityplayermp.posZ >> 4;
            double d  = entityplayermp.field_9155_d - entityplayermp.posX;
            double d1 = entityplayermp.field_9154_e - entityplayermp.posZ;
            double d2 = d * d + d1 * d1;

            if (d2 < 64D)
            {
                return;
            }
            int k  = (int)entityplayermp.field_9155_d >> 4;
            int l  = (int)entityplayermp.field_9154_e >> 4;
            int i1 = i - k;
            int j1 = j - l;

            if (i1 == 0 && j1 == 0)
            {
                return;
            }
            for (int k1 = i - playerViewRadius; k1 <= i + playerViewRadius; k1++)
            {
                for (int l1 = j - playerViewRadius; l1 <= j + playerViewRadius; l1++)
                {
                    if (!Func_544_a(k1, l1, k, l))
                    {
                        GetPlayerInstance(k1, l1, true).AddPlayer(entityplayermp);
                    }
                    if (Func_544_a(k1 - i1, l1 - j1, i, j))
                    {
                        continue;
                    }
                    net.minecraft.src.PlayerInstance playerinstance = GetPlayerInstance(k1 - i1, l1 - j1, false);
                    if (playerinstance != null)
                    {
                        playerinstance.RemovePlayer(entityplayermp);
                    }
                }
            }
            entityplayermp.field_9155_d = entityplayermp.posX;
            entityplayermp.field_9154_e = entityplayermp.posZ;


            // CRAFTBUKKIT/SHARP start - send nearest chunks first
            if (i1 > 1 || i1 < -1 || j1 > 1 || j1 < -1)
            {
                int x = i;
                int z = j;
                List <ChunkCoordIntPair> chunksToSend = entityplayermp.chunkCoordIntPairQueue;

                chunksToSend.Sort((a, b) =>
                {
                    return(Math.Max(Math.Abs(a.X - x), Math.Abs(a.Z - z)) - Math.Max(Math.Abs(b.X - x), Math.Abs(b.Z - z)));
                });
            }
            // CRAFTBUKKIT/SHARP end
        }
Exemplo n.º 2
0
        public virtual void MarkBlockNeedsUpdate(int i, int j, int k)
        {
            int l  = i >> 4;
            int i1 = k >> 4;

            net.minecraft.src.PlayerInstance playerinstance = GetPlayerInstance(l, i1, false);
            if (playerinstance != null)
            {
                playerinstance.MarkBlockNeedsUpdate(i & 0xf, j, k & 0xf);
            }
        }
Exemplo n.º 3
0
        private net.minecraft.src.PlayerInstance GetPlayerInstance(int i, int j, bool flag
                                                                   )
        {
            long l = (long)i + unchecked ((long)(0x7fffffffL)) | (long)j + unchecked ((long)(0x7fffffffL
                                                                                             )) << 32;

            net.minecraft.src.PlayerInstance playerinstance = (net.minecraft.src.PlayerInstance
                                                               )playerInstances.GetValueByKey(l);
            if (playerinstance == null && flag)
            {
                playerinstance = new net.minecraft.src.PlayerInstance(this, i, j);
                playerInstances.Add(l, playerinstance);
            }
            return(playerinstance);
        }
Exemplo n.º 4
0
        public virtual void RemovePlayer(net.minecraft.src.EntityPlayerMP entityplayermp)
        {
            int i = (int)entityplayermp.field_9155_d >> 4;
            int j = (int)entityplayermp.field_9154_e >> 4;

            for (int k = i - playerViewRadius; k <= i + playerViewRadius; k++)
            {
                for (int l = j - playerViewRadius; l <= j + playerViewRadius; l++)
                {
                    net.minecraft.src.PlayerInstance playerinstance = GetPlayerInstance(k, l, false);
                    if (playerinstance != null)
                    {
                        playerinstance.RemovePlayer(entityplayermp);
                    }
                }
            }
            players.Remove(entityplayermp);
        }