public virtual void Func_539_c(int par1, int par2)
        {
            Chunk chunk = ProvideChunk(par1, par2);

            if (!chunk.IsEmpty())
            {
                chunk.OnChunkUnload();
            }

            ChunkMapping.Remove(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));
            Field_889_c.Remove(chunk);
        }
Exemplo n.º 2
0
        ///<summary>
        /// Unloads the 100 oldest chunks from memory, due to a bug with chunkSet.Add() never being called it thinks the list
        /// is always empty and will not remove any chunks.
        ///</summary>
        public bool Unload100OldestChunks()
        {
            for (int i = 0; i < 100; i++)
            {
                if (droppedChunksSet.Count > 0)
                {
                    long  long1  = droppedChunksSet.GetEnumerator().Current;
                    Chunk chunk1 = (Chunk)chunkMap.GetValueByKey(long1);
                    chunk1.OnChunkUnload();
                    SaveChunkData(chunk1);
                    SaveChunkExtraData(chunk1);
                    droppedChunksSet.Remove(long1);
                    chunkMap.Remove(long1);
                    chunkList.Remove(chunk1);
                }
            }

            for (int j = 0; j < 10; j++)
            {
                if (field_35392_h >= chunkList.Count)
                {
                    field_35392_h = 0;
                    break;
                }

                Chunk        chunk        = chunkList[field_35392_h++];
                EntityPlayer entityplayer = worldObj.Func_48456_a((chunk.XPosition << 4) + 8, (chunk.ZPosition << 4) + 8, 288);

                if (entityplayer == null)
                {
                    DropChunk(chunk.XPosition, chunk.ZPosition);
                }
            }

            if (chunkLoader != null)
            {
                chunkLoader.ChunkTick();
            }

            return(chunkProvider.Unload100OldestChunks());
        }
        /// <summary>
        /// Removes BiomeCacheBlocks from this cache that haven't been accessed in at least 30 seconds.
        /// </summary>
        public virtual void CleanupCache()
        {
            long l  = JavaHelper.CurrentTimeMillis();
            long l1 = l - LastCleanupTime;

            if (l1 > 7500L || l1 < 0L)
            {
                LastCleanupTime = l;

                for (int i = 0; i < Cache.Count; i++)
                {
                    BiomeCacheBlock biomecacheblock = (BiomeCacheBlock)Cache[i];
                    long            l2 = l - biomecacheblock.LastAccessTime;

                    if (l2 > 30000L || l2 < 0L)
                    {
                        Cache.RemoveAt(i--);
                        long l3 = (long)biomecacheblock.XPosition & 0xffffffffL | ((long)biomecacheblock.ZPosition & 0xffffffffL) << 32;
                        CacheMap.Remove(l3);
                    }
                }
            }
        }