private static void RunOptionsAndReturnExitCode(CliOptions opts) { Console.Clear(); var cgui = new ConsoleGui(); var pbBlocks = new ConsoleGuiProgressBar(0, 0, Console.WindowWidth, 0, 1) { ForegroundColor = ConsoleColor.Green, BackgroundColor = ConsoleColor.DarkGray }; var lBlocksTotal = new ConsoleGuiLabel(0, 1, "Total Blocks : {0}"); var lBlocksRemaining = new ConsoleGuiLabel(0, 2, "Remaining Blocks: {0}"); var lBlocksFailed = new ConsoleGuiLabel(0, 3, "Failed Blocks : {0}"); var lStatus = new ConsoleGuiLabel(0, 4, "Status : {0}"); cgui.Add(pbBlocks); cgui.Add(lBlocksTotal); cgui.Add(lBlocksRemaining); cgui.Add(lBlocksFailed); cgui.Add(lStatus); var failed = new List <int>(); var inputMap = NbtMap.Load(opts.InputMap); var outputMap = NbtMap.Load(opts.OutputMap); var inputSchematic = new NBTFile(opts.InputSchematic); var tag = new NbtTree(inputSchematic.GetDataInputStream()).Root; var bLower = tag["Blocks"].ToTagByteArray().Data; var addBlocks = new byte[(bLower.Length >> 1) + 1]; if (tag.ContainsKey("AddBlocks")) { addBlocks = tag["AddBlocks"].ToTagByteArray().Data; } lStatus.Value = "Processing..."; for (var index = 0; index < bLower.Length; index++) { short oldId; if ((index & 1) == 1) { oldId = (short)(((addBlocks[index >> 1] & 0x0F) << 8) + (bLower[index] & 0xFF)); } else { oldId = (short)(((addBlocks[index >> 1] & 0xF0) << 4) + (bLower[index] & 0xFF)); } if (!TranslateId(oldId, inputMap, outputMap, out var newId)) { failed.Add(oldId); } bLower[index] = (byte)(newId & 0xFF); addBlocks[index >> 1] = (byte)(((index & 1) == 1) ? addBlocks[index >> 1] & 0xF0 | (newId >> 8) & 0xF : addBlocks[index >> 1] & 0xF | ((newId >> 8) & 0xF) << 4); // Gui lBlocksTotal.Value = index + 1; lBlocksRemaining.Value = bLower.Length - index - 1; lBlocksFailed.Value = failed.Count; pbBlocks.Value = (float)index / bLower.Length; if (index % 10000 == 0) { cgui.Render(); } } cgui.Render(); tag["Blocks"] = new TagNodeByteArray(bLower); if (!tag.ContainsKey("AddBlocks")) { tag.Add("AddBlocks", new TagNodeByteArray(addBlocks)); } else { tag["AddBlocks"] = new TagNodeByteArray(addBlocks); } lStatus.Value = "Saving..."; cgui.Render(); var schematicFile = new NBTFile(opts.OutputSchematic); using (var nbtStream = schematicFile.GetDataOutputStream()) { if (nbtStream == null) { return; } var tree = new NbtTree(tag, "Schematic"); tree.WriteTo(nbtStream); } lStatus.Value = "Done. Press Enter."; cgui.Render(); Console.WriteLine(); foreach (var i in failed) { Console.WriteLine($"Failed ID: {i}"); } Console.ReadKey(); }