示例#1
0
 public AnvilChunk(AnvilChunkManager manager, ChunkCoord coord)
 {
     _coord        = coord;
     _manager      = manager;
     _entities     = new ChunkEntityCollection(new TagList());
     _tileEntities = new Dictionary <BlockPos, TagCompound>();
 }
示例#2
0
        public AnvilDimension(string directory, int cacheCapacity = 256)
        {
            _cache = new AnvilCache(cacheCapacity);

            _chunk    = new AnvilChunkManager(directory + Path.DirectorySeparatorChar + "region", _cache);
            _blocks   = new AnvilBlockManager(_chunk);
            _entities = new AnvilEntityCollection(_chunk);
        }
示例#3
0
 public AnvilEntityCollection(AnvilChunkManager chunk)
 {
     _chunk = chunk;
     //_entities = new List<TagCompound>();
 }
示例#4
0
        public static AnvilChunk Load(AnvilChunkManager manager, TagCompound compound)
        {
            /**
             *
             * Untested Code
             *
             *
             */
            if (compound == null || !compound.ContainsKey("Level"))
            {
                return(null);
            }

            TagCompound level = compound["Level"] as TagCompound;
            int         cx    = level.GetInt("xPos");
            int         cy    = level.GetInt("zPos");
            AnvilChunk  c     = new AnvilChunk(manager, new ChunkCoord(cx, cy));

            if (compound.ContainsKey("DataVersion"))
            {
                c.DataVersion = compound.GetInt("DataVersion");
            }
            c._heights = level.GetIntArray("HeightMap");
            bool isTerrainPopulated = level.GetBool("TerrainPopulated");
            bool isLightPopulated   = level.GetBool("LightPopulated");

            //if(isTerrainPopulated && isLightPopulated)
            //{
            //	c._status = ChunkStatus.Lighted;
            //}
            //else if(isTerrainPopulated)
            //{
            //	c._status = ChunkStatus.Carved;
            //}
            c._isTerrainPopulated = level.GetBool("TerrainPopulated");
            c._isLightPopulated   = level.GetBool("LightPopulated");

            //c.InhabitedTime = tag.GetLong("InhabitedTime");

            TagList sections = (TagList)level["Sections"];

            c._sections = new AnvilSection[SectionsPerChunk];
            for (int i = 0; i < sections.Count; i++)
            {
                TagCompound sec = sections[i] as TagCompound;
                if (sec == null)
                {
                    continue;
                }

                c._sections[i] = new AnvilSectionClassic(sec.GetByte("Y"), true);
                c._sections[i].Load(sec);
            }

            if (level.ContainsKey("Biomes", TagType.ByteArray))
            {
                byte[] oldBiome = level.GetByteArray("Biomes");
                for (int i = 0; i < oldBiome.Length; i++)
                {
                    c._biomes[i] = oldBiome[i];
                }
            }
            TagList entities = (TagList)level["Entities"];

            foreach (TagCompound t in entities)
            {
                c.Entities.Add(t);
            }

            TagList tiles = (TagList)level["TileEntities"];

            foreach (TagCompound t in tiles)
            {
                int x = t.GetInt("x");
                int y = t.GetInt("y");
                int z = t.GetInt("z");
                c._tileEntities.Add(new BlockPos(x, y, z), t);
            }

            return(c);
        }