BiomePainter.RegionUtil.Replace C# (CSharp) Method

Replace() private static method

private static Replace ( RegionFile region, Bitmap selection, Color selectionColor, byte search, BiomeUtil replace ) : void
region Minecraft.RegionFile
selection System.Drawing.Bitmap
selectionColor Color
search byte
replace Minecraft.BiomeUtil
return void
        private static void Replace(RegionFile region, Bitmap selection, Color selectionColor, byte search, BiomeUtil replace)
        {
            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()))
                        {
                            if (biomes[x + z * 16] == search)
                            {
                                biomes[x + z * 16] = (byte)replace.GetBiome(chunkAbs.X + x, chunkAbs.Z + z);
                            }
                        }
                    }
                }
            }
        }

Same methods

RegionUtil::Replace ( RegionFile region, Bitmap selection, Color selectionColor, byte biome1, Object biome2, long worldSeed ) : void
RegionUtil::Replace ( RegionFile region, Bitmap selection, Color selectionColor, byte search, byte replace ) : 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::Replace