BiomePainter.RegionUtil.SetChunkstobePopulated C# (CSharp) Method

SetChunkstobePopulated() public static method

public static SetChunkstobePopulated ( RegionFile region, Bitmap selection, Color selectionColor, byte value ) : void
region Minecraft.RegionFile
selection System.Drawing.Bitmap
selectionColor Color
value byte
return void
        public static void SetChunkstobePopulated(RegionFile region, Bitmap selection, Color selectionColor, byte value)
        {
            for (int chunkX = 0; chunkX < 32; chunkX++)
            {
                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    Chunk c = region.Chunks[chunkX, chunkZ];
                    if (c == null || c.Root == null)
                        continue;

                    bool done = false;
                    for (int z = 0; z < 16; z++)
                    {
                        for (int x = 0; x < 16; x++)
                        {
                            if (selection.GetPixel(OFFSETX + chunkX * 16 + x, OFFSETY + chunkZ * 16 + z).ToArgb() == selectionColor.ToArgb())
                            {
                                ((TAG_Byte)c.Root["Level"]["TerrainPopulated"]).Payload = value;
                                done = true;
                                break;
                            }
                        }
                        if (done)
                            break;
                    }
                }
            }
        }

Usage Example

Example #1
0
        private void setChunksInSelectionToBePopulatedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (world == null || region == null)
            {
                return;
            }

            if (!warnedAboutPopulating)
            {
                DialogResult res = MessageBox.Show(this, String.Format("Setting a chunk to be popluated by Minecraft means the next time that chunk is loaded in Minecraft it will be filled with trees, snow cover, water, lava, and ores depending on the biome(s) the chunk is in.{0}{0}If that chunk has already been populated or already has player-made structures in it, you may find it clogged with more foliage than you wanted. Also smooth stone in your structures may be replaced with ores, dirt, or gravel. I strongly suggest you make a backup copy of your world before using this feature.{0}{0}Are you sure you want to proceed? As always, changes can be undone and won't take effect until you save the region.", Environment.NewLine), "DANGER", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                warnedAboutPopulating = true;
            }

            if (!chkShowPopulate.Checked)
            {
                chkShowPopulate.Checked = true;
            }

            RegionUtil.SetChunkstobePopulated(region, imgRegion.Layers[SELECTIONLAYER].Image, imgRegion.SelectionColor, 0);
            RegionUtil.RenderRegionChunkstobePopulated(region, imgRegion.Layers[POPULATELAYER].Image);
            imgRegion.Redraw();
            history.RecordPopulateState(region, "Set Populate Flags");
        }
All Usage Examples Of BiomePainter.RegionUtil::SetChunkstobePopulated