/// <summary>
        /// loads or generates the chunk at the chunk location specified
        /// </summary>
        public virtual Chunk LoadChunk(int par1, int par2)
        {
            Chunk chunk = new Chunk(WorldObj, par1, par2);

            ChunkMapping.Add(ChunkCoordIntPair.ChunkXZ2Int(par1, par2), chunk);
            chunk.IsChunkLoaded = true;
            return(chunk);
        }
示例#2
0
        /// <summary>
        /// Drops the specified chunk.
        /// </summary>
        public virtual void DropChunk(int par1, int par2)
        {
            ChunkCoordinates chunkcoordinates = worldObj.GetSpawnPoint();
            int i = (par1 * 16 + 8) - chunkcoordinates.PosX;
            int j = (par2 * 16 + 8) - chunkcoordinates.PosZ;
            int c = 200;

            if (i < -c || i > c || j < -c || j > c)
            {
                droppedChunksSet.Add(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));
            }
        }
        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);
        }
示例#4
0
        ///<summary>
        /// Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
        /// specified chunk from the map seed and chunk seed
        ///</summary>
        public Chunk ProvideChunk(int par1, int par2)
        {
            Chunk chunk = (Chunk)chunkMap.GetValueByKey(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));

            if (chunk == null)
            {
                return(LoadChunk(par1, par2));
            }
            else
            {
                return(chunk);
            }
        }
        /// <summary>
        /// Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
        /// specified chunk from the map seed and chunk seed
        /// </summary>
        public virtual Chunk ProvideChunk(int par1, int par2)
        {
            Chunk chunk = (Chunk)ChunkMapping.GetValueByKey(ChunkCoordIntPair.ChunkXZ2Int(par1, par2));

            if (chunk == null)
            {
                return(BlankChunk);
            }
            else
            {
                return(chunk);
            }
        }
        /// <summary>
        /// Recursively called by generate() (generate) and optionally by itself.
        /// </summary>
        protected override void RecursiveGenerate(World par1World, int par2, int par3, int par4, int par5, byte[] par6ArrayOfByte)
        {
            if (CoordMap.ContainsKey(ChunkCoordIntPair.ChunkXZ2Int(par2, par3)))
            {
                return;
            }

            Rand.Next();

            if (CanSpawnStructureAtCoords(par2, par3))
            {
                StructureStart structurestart = GetStructureStart(par2, par3);
                CoordMap[ChunkCoordIntPair.ChunkXZ2Int(par2, par3)] = structurestart;
            }
        }
示例#7
0
        ///<summary>
        /// loads or generates the chunk at the chunk location specified
        ///</summary>
        public Chunk LoadChunk(int par1, int par2)
        {
            long l = ChunkCoordIntPair.ChunkXZ2Int(par1, par2);

            droppedChunksSet.Remove(l);
            Chunk chunk = (Chunk)chunkMap.GetValueByKey(l);

            if (chunk == null)
            {
                int i = 0x1c9c3c;

                if (par1 < -i || par2 < -i || par1 >= i || par2 >= i)
                {
                    return(emptyChunk);
                }

                chunk = LoadChunkFromFile(par1, par2);

                if (chunk == null)
                {
                    if (chunkProvider == null)
                    {
                        chunk = emptyChunk;
                    }
                    else
                    {
                        chunk = chunkProvider.ProvideChunk(par1, par2);
                    }
                }

                chunkMap.Add(l, chunk);
                chunkList.Add(chunk);

                if (chunk != null)
                {
                    chunk.Func_4143_d();
                    chunk.OnChunkLoad();
                }

                chunk.PopulateChunk(this, this, par1, par2);
            }

            return(chunk);
        }
示例#8
0
 /// <summary>
 /// Checks to see if a chunk exists at x, y
 /// </summary>
 public virtual bool ChunkExists(int par1, int par2)
 {
     return(chunkMap.ContainsItem(ChunkCoordIntPair.ChunkXZ2Int(par1, par2)));
 }