Esempio n. 1
0
        public Chunk loadChunk(World world, int i, int j)
        {
            File file = chunkFileForXZ(i, j);

            if (file != null && file.exists())
            {
                try
                {
                    var            fileinputstream = new FileInputStream(file);
                    NBTTagCompound nbttagcompound  = CompressedStreamTools.func_770_a(fileinputstream);
                    if (!nbttagcompound.hasKey("Level"))
                    {
                        [email protected](
                            (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                                " is missing level data, skipping").toString());
                        return(null);
                    }
                    if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks"))
                    {
                        [email protected](
                            (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                                " is missing block data, skipping").toString());
                        return(null);
                    }
                    Chunk chunk = loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
                    if (!chunk.isAtLocation(i, j))
                    {
                        [email protected](
                            (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                                " is in the wrong location; relocating. (Expected ").append(i).append(", ").append(j).
                            append(", got ").append(chunk.xPosition).append(", ").append(chunk.zPosition).append(")")
                            .toString());
                        nbttagcompound.setInteger("xPos", i);
                        nbttagcompound.setInteger("zPos", j);
                        chunk = loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
                    }
                    return(chunk);
                }
                catch (Exception exception)
                {
                    exception.printStackTrace();
                }
            }
            return(null);
        }
Esempio n. 2
0
        public Chunk loadChunk(World world, int i, int j)
        {
            DataInputStream datainputstream = RegionFileCache.func_22124_c(field_22110_a, i, j);
            NBTTagCompound  nbttagcompound;

            if (datainputstream != null)
            {
                nbttagcompound = CompressedStreamTools.func_774_a(datainputstream);
            }
            else
            {
                return(null);
            }
            if (!nbttagcompound.hasKey("Level"))
            {
                [email protected](
                    (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                        " is missing level data, skipping").toString());
                return(null);
            }
            if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks"))
            {
                [email protected](
                    (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                        " is missing block data, skipping").toString());
                return(null);
            }
            Chunk chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));

            if (!chunk.isAtLocation(i, j))
            {
                [email protected](
                    (new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j).append(
                        " is in the wrong location; relocating. (Expected ").append(i).append(", ").append(j).append(
                        ", got ").append(chunk.xPosition).append(", ").append(chunk.zPosition).append(")").toString());
                nbttagcompound.setInteger("xPos", i);
                nbttagcompound.setInteger("zPos", j);
                chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
            }
            return(chunk);
        }