Esempio n. 1
0
        public void Initialize()
        {
            BasePath = BasePath ?? Config.GetProperty("LevelDBWorldFolder", "World").Trim();

            var directory = new DirectoryInfo(Path.Combine(BasePath, "db"));

            var levelFileName = Path.Combine(BasePath, "level.dat");

            Log.Debug($"Loading level.dat from {levelFileName}");
            if (File.Exists(levelFileName))
            {
                var file = new NbtFile
                {
                    BigEndian = false,
                    UseVarInt = false
                };
                var levelStream = File.OpenRead(levelFileName);
                levelStream.Seek(8, SeekOrigin.Begin);
                file.LoadFromStream(levelStream, NbtCompression.None);
                Log.Debug($"Level DAT\n{file.RootTag}");
                NbtTag dataTag = file.RootTag["Data"];
                //LevelInfo = new LevelInfoBedrock(dataTag);
            }
            else
            {
                Log.Warn($"No level.dat found at {levelFileName}. Creating empty.");
                LevelInfo = new LevelInfoBedrock();
            }

            var db = new Database(directory);

            db.Open();
            _db = db;

            MissingChunkProvider?.Initialize();
        }