Beispiel #1
0
        static void ListChunks(FileInfo vldbFile, bool old)
        {
            byte[] fileContents = vldbFile.ReadFileFullyInflate();

            using (VLDBReader reader = new VLDBReader(new MemoryStream(fileContents))) {
                if (!old)
                {
                    reader.verifyVldb();
                }

                int regionX = reader.BaseReader.ReadInt();
                int regionZ = reader.BaseReader.ReadInt();

                IDictionary <ChunkPos, int>      header       = reader.ReadHeader(regionX, regionZ);
                SortedDictionary <ChunkPos, int> sortedHeader = new SortedDictionary <ChunkPos, int>(header, new ChunkPosComparer(header));

                Console.WriteLine($"============== {vldbFile.Name} ==============");
                Console.WriteLine($"TOTAL AFFECTED CHUNKS: {header.Keys.Count}");
                Console.WriteLine();

                foreach (ChunkPos chunkPos in sortedHeader.Keys)
                {
                    int offset = header[chunkPos];
                    reader.BaseReader.BaseStream.Position = offset;

                    reader.BaseReader.ReadShort(); // Skip position
                    int amountLightSources = reader.ReadUInt24();

                    Console.WriteLine($"Chunk {chunkPos,10}: {amountLightSources,5} Light sources - OFFSET 0x{$"{header[chunkPos]:X}",-10}");
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            FileInfo testFile =
                new FileInfo(@"E:\Florian\Projekte\IdeaProjects\VarLight\test-servers\1.15\world\varlight\r.0.0.vldb2");

            FileInfo testFileDeflated =
                new FileInfo(
                    @"E:\Florian\Projekte\IdeaProjects\VarLight\test-servers\1.8.8\world\varlight\r.-2.-1.vldb2");

            Console.WriteLine(testFile.IsVldbFile());
            Console.WriteLine(testFileDeflated.IsVldbFile());

            VLDBReader reader;

            using (reader = VLDBReader.OpenVldb(testFile, false)) {
                int regionX = reader.BaseReader.ReadInt();
                int regionZ = reader.BaseReader.ReadInt();

                Console.WriteLine(reader.ReadHeader(regionX, regionZ).DictToString());
            }

            using (reader = VLDBReader.OpenVldb(testFileDeflated, false)) {
                int regionX = reader.BaseReader.ReadInt();
                int regionZ = reader.BaseReader.ReadInt();

                Console.WriteLine(reader.ReadHeader(regionX, regionZ).DictToString());
            }

            Console.WriteLine("==============================");

            using (reader = VLDBReader.OpenVldb(testFile, false)) {
                LightSource[] lightSources = reader.ReadAll();

                Console.WriteLine(testFile.Name);
                foreach (LightSource lightSource in lightSources)
                {
                    Console.WriteLine(lightSource);
                }

                Console.WriteLine("-----------------------");
            }

            using (reader = VLDBReader.OpenVldb(testFileDeflated, false)) {
                LightSource[] lightSources = reader.ReadAll();

                Console.WriteLine(testFileDeflated.Name);
                foreach (LightSource lightSource in lightSources)
                {
                    Console.WriteLine(lightSource);
                }

                Console.WriteLine("-----------------------");
            }
        }
Beispiel #3
0
        static void ListSingleChunk(FileInfo vldbFile, string input, bool old)
        {
            Regex regex = new Regex(@"-?[0-9]+,-?[0-9]+");

            Match match = regex.Match(input);

            if (!match.Success)
            {
                throw new Exception("Could not parse chunk coordinates");
            }

            string coords = match.Value;

            string[] parts = coords.Split(',');

            int chunkX = int.Parse(parts[0]);
            int chunkZ = int.Parse(parts[1]);

            byte[] fileContents = vldbFile.ReadFileFullyInflate();

            ChunkPos targetChunkPos = new ChunkPos(chunkX, chunkZ);

            using (VLDBReader reader = new VLDBReader(new MemoryStream(fileContents))) {
                if (!old)
                {
                    reader.verifyVldb();
                }

                int regionX = reader.BaseReader.ReadInt();
                int regionZ = reader.BaseReader.ReadInt();

                IDictionary <ChunkPos, int> header = reader.ReadHeader(regionX, regionZ);

                if (!header.ContainsKey(targetChunkPos))
                {
                    Console.WriteLine($"File does not contain chunk {targetChunkPos}");
                    return;
                }

                reader.BaseReader.BaseStream.Position = header[targetChunkPos];
                LightSource[] lightSources = reader.ReadChunk(regionX, regionZ).Item2;

                Console.WriteLine($"============== {vldbFile.Name} ==============");
                Console.WriteLine($"CHUNK {targetChunkPos}");
                Console.WriteLine($"AMOUNT LIGHT SOURCES: {lightSources.Length}");
                Console.WriteLine();

                foreach (LightSource lightSource in lightSources)
                {
                    Console.WriteLine(lightSource);
                }
            }
        }
Beispiel #4
0
        static void ListAll(FileInfo vldbFile, bool old)
        {
            using (VLDBReader reader = VLDBReader.OpenVldb(vldbFile, old)) {
                LightSource[] lightSources = reader.ReadAll();

                Console.WriteLine($"============== {vldbFile.Name} ==============");
                Console.WriteLine($"TOTAL LIGHT SOURCES: {lightSources.Length}");
                Console.WriteLine();

                foreach (LightSource lightSource in lightSources)
                {
                    Console.WriteLine(lightSource);
                }
            }
        }