BiomePainter.RegionUtil.Fill C# (CSharp) Method

Fill() private static method

private static Fill ( RegionFile region, Bitmap selection, Color selectionColor, BiomeUtil util ) : void
region Minecraft.RegionFile
selection System.Drawing.Bitmap
selectionColor Color
util Minecraft.BiomeUtil
return void
        private static void Fill(RegionFile region, Bitmap selection, Color selectionColor, BiomeUtil util)
        {
            foreach (Chunk c in region.Chunks)
            {
                if (c.Root == null)
                    continue;
                Coord chunkOffset = new Coord(region.Coords);
                chunkOffset.RegiontoChunk();
                chunkOffset = new Coord(c.Coords.X - chunkOffset.X, c.Coords.Z - chunkOffset.Z);
                chunkOffset.ChunktoAbsolute();

                Coord chunkAbs = new Coord(c.Coords);
                chunkAbs.ChunktoAbsolute();

                byte[] biomes = (byte[])c.Root["Level"]["Biomes"];

                for (int z = 0; z < 16; z++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        if (selection == null || (selection.GetPixel(OFFSETX + chunkOffset.X + x, OFFSETY + chunkOffset.Z + z).ToArgb() == selectionColor.ToArgb()))
                        {
                            biomes[x + z * 16] = (byte)util.GetBiome(chunkAbs.X + x, chunkAbs.Z + z);
                        }
                    }
                }
            }
        }

Same methods

RegionUtil::Fill ( RegionFile region, Bitmap selection, Color selectionColor, Object biome, long worldSeed ) : void
RegionUtil::Fill ( RegionFile region, Bitmap selection, Color selectionColor, byte biome ) : void

Usage Example

Esempio n. 1
0
        private void Run()
        {
            String[] paths  = Directory.GetFiles(regionDir, "*.mca", SearchOption.TopDirectoryOnly);
            String   format = String.Format("{{0}} region {{1}} of {0}", paths.Length);
            int      count  = 0;

            foreach (String path in paths)
            {
                UpdateStatus(String.Format(format, "Reading", count));
                UpdateProgress(count, paths.Length);
                RegionFile region = new RegionFile(path);
                UpdateStatus(String.Format(format, replace ? "Replacing" : "Filling", count));
                if (!replace)
                {
                    RegionUtil.Fill(region, null, Color.Black, biome1, worldSeed);
                }
                else
                {
                    RegionUtil.Replace(region, null, Color.Black, ((BiomeType)biome1).ID, biome2, worldSeed);
                }
                UpdateStatus(String.Format(format, "Saving", count));
                mutex.WaitOne();
                region.Write(true);
                mutex.ReleaseMutex();
                count++;
            }
            UpdateProgress(paths.Length, paths.Length);
            UpdateStatus("Done");
        }
All Usage Examples Of BiomePainter.RegionUtil::Fill