/**
     * loads or generates the chunk at the chunk location specified
     */
    public Chunk loadChunk(int x, int z)
    {
        long  chunkID = ChunkCoordIntPair.chunkXZ2Int(x, z);
        Chunk chunk   = null;

        if (!id2ChunkDic.ContainsKey(chunkID))
        {
            if (serverChunkGenerator == null)
            {
            }
            else
            {
                chunk = serverChunkGenerator.provideChunk(x, z);
            }

            id2ChunkDic.Add(chunkID, chunk);
            loadedChunks.Add(chunk);
            chunk.onChunkLoad();
            chunk.populateChunk(this, this, x, z);
        }

        chunk = (Chunk)id2ChunkDic [chunkID];

        return(chunk);
    }
        public Chunk loadChunk(int i, int j)
        {
            int k = ChunkCoordIntPair.chunkXZ2Int(i, j);

            field_725_a.remove(Integer.valueOf(k));
            var chunk = (Chunk)id2ChunkMap.get(Integer.valueOf(k));

            if (chunk == null)
            {
                chunk = func_4063_e(i, j);
                if (chunk == null)
                {
                    if (field_730_c == null)
                    {
                        chunk = field_724_b;
                    }
                    else
                    {
                        chunk = field_730_c.provideChunk(i, j);
                    }
                }
                id2ChunkMap.put(Integer.valueOf(k), chunk);
                field_727_f.add(chunk);
                if (chunk != null)
                {
                    chunk.func_4053_c();
                    chunk.onChunkLoad();
                }
                if (!chunk.isTerrainPopulated && chunkExists(i + 1, j + 1) && chunkExists(i, j + 1) &&
                    chunkExists(i + 1, j))
                {
                    populate(this, i, j);
                }
                if (chunkExists(i - 1, j) && !provideChunk(i - 1, j).isTerrainPopulated&& chunkExists(i - 1, j + 1) &&
                    chunkExists(i, j + 1) && chunkExists(i - 1, j))
                {
                    populate(this, i - 1, j);
                }
                if (chunkExists(i, j - 1) && !provideChunk(i, j - 1).isTerrainPopulated&& chunkExists(i + 1, j - 1) &&
                    chunkExists(i, j - 1) && chunkExists(i + 1, j))
                {
                    populate(this, i, j - 1);
                }
                if (chunkExists(i - 1, j - 1) && !provideChunk(i - 1, j - 1).isTerrainPopulated&&
                    chunkExists(i - 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i - 1, j))
                {
                    populate(this, i - 1, j - 1);
                }
            }
            return(chunk);
        }
Exemple #3
0
 /**
  * Returns back a chunk looked up by chunk coordinates Args: x, y
  */
 public Chunk getChunkFromChunkCoords(int chunkX, int chunkZ)
 {
     return(chunkProvider.provideChunk(chunkX, chunkZ));
 }
Exemple #4
0
        public Chunk provideChunk(int i, int j)
        {
            if (i == lastQueriedChunkXPos && j == lastQueriedChunkZPos && lastQueriedChunk != null)
            {
                return(lastQueriedChunk);
            }
            if (!worldObj.field_9209_x && !func_21111_c(i, j))
            {
                return(blankChunk);
            }
            int k  = i & 0x1f;
            int l  = j & 0x1f;
            int i1 = k + l * 32;

            if (!chunkExists(i, j))
            {
                if (chunks[i1] != null)
                {
                    chunks[i1].onChunkUnload();
                    saveChunk(chunks[i1]);
                    saveExtraChunkData(chunks[i1]);
                }
                Chunk chunk = func_4059_c(i, j);
                if (chunk == null)
                {
                    if (chunkProvider == null)
                    {
                        chunk = blankChunk;
                    }
                    else
                    {
                        chunk = chunkProvider.provideChunk(i, j);
                    }
                }
                chunks[i1] = chunk;
                chunk.func_4053_c();
                if (chunks[i1] != null)
                {
                    chunks[i1].onChunkLoad();
                }
                if (!chunks[i1].isTerrainPopulated && chunkExists(i + 1, j + 1) && chunkExists(i, j + 1) &&
                    chunkExists(i + 1, j))
                {
                    populate(this, i, j);
                }
                if (chunkExists(i - 1, j) && !provideChunk(i - 1, j).isTerrainPopulated&& chunkExists(i - 1, j + 1) &&
                    chunkExists(i, j + 1) && chunkExists(i - 1, j))
                {
                    populate(this, i - 1, j);
                }
                if (chunkExists(i, j - 1) && !provideChunk(i, j - 1).isTerrainPopulated&& chunkExists(i + 1, j - 1) &&
                    chunkExists(i, j - 1) && chunkExists(i + 1, j))
                {
                    populate(this, i, j - 1);
                }
                if (chunkExists(i - 1, j - 1) && !provideChunk(i - 1, j - 1).isTerrainPopulated&&
                    chunkExists(i - 1, j - 1) && chunkExists(i, j - 1) && chunkExists(i - 1, j))
                {
                    populate(this, i - 1, j - 1);
                }
            }
            lastQueriedChunkXPos = i;
            lastQueriedChunkZPos = j;
            lastQueriedChunk     = chunks[i1];
            return(chunks[i1]);
        }