private static void RenderRegionBiomes(RegionFile region, int chunkStartX, int chunkEndX, int chunkStartZ, int chunkEndZ, int offsetX, int offsetY, Bitmap biomes, String[,] toolTips) { for (int x = chunkStartX; x <= chunkEndX; x++) { for (int z = chunkStartZ; z <= chunkEndZ; z++) { Chunk c = region.Chunks[x, z]; if (c == null || c.Root == null) { continue; } Coord chunkOffset = new Coord(c.Coords); chunkOffset.ChunktoRegionRelative(); chunkOffset = new Coord(chunkOffset.X - chunkStartX, chunkOffset.Z - chunkStartZ); chunkOffset.ChunktoAbsolute(); chunkOffset.Add(offsetX, offsetY); RenderChunkBiomes(c, biomes, toolTips, chunkOffset.X, chunkOffset.Z); } } }
public static void AddorRemoveBlocksSelection(RegionFile region, Bitmap b, Color selectionColor, int[] blockIds, bool add) { if (blockIds == null || blockIds.Length == 0) { return; } List <int> ids = new List <int>(blockIds); 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(); TAG_Compound[] sections = new TAG_Compound[16]; int highest = -1; foreach (TAG t in (TAG[])c.Root["Level"]["Sections"]) { byte index = (byte)t["Y"]; if (index > highest) { highest = index; } sections[index] = (TAG_Compound)t; } //chunk exists but all blocks are air if (highest < 0) { return; } highest = ((highest + 1) * 16) - 1; for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { int y; if (c.ManualHeightmap[x + z * 16] >= 0) { y = c.ManualHeightmap[x + z * 16]; } else { y = GetHeight(sections, x, z, highest); c.ManualHeightmap[x + z * 16] = y; } if (y < 0) { continue; } if (ids.Contains(GetBlock(sections, x, y, z))) { b.SetPixel(OFFSETX + chunkOffset.X + x, OFFSETY + chunkOffset.Z + z, add ? selectionColor : Color.Transparent); } } } } }