Exemplo n.º 1
0
        public override void ProcessRegion(World world, MCUtils.Region reg, int rx, int rz, int pass)
        {
            ConsoleOutput.WriteLine($"Starting merge for region [{rx},{rz}] ...");
            int scale = chunkMode ? 32 : 512;

            bool[,] fraction;
            lock (mask)
            {
                fraction = GetSubMask((rx - upperLeftCornerRegionX) * scale, (rz - upperLeftCornerRegionZ) * scale, scale, scale);
            }
            string otherRegionName = otherRegionPrefix + $"r.{rx}.{rz}.mca";
            var    filename        = Path.Combine(otherRegionFolder, otherRegionName);

            if (File.Exists(filename))
            {
                var otherRegion  = RegionImporter.OpenRegionFile(filename);
                var merger       = new RegionMerger(otherRegion, reg, fraction);
                var mergedRegion = merger.Merge();
                for (int x = 0; x < 32; x++)
                {
                    for (int z = 0; z < 32; z++)
                    {
                        reg.chunks[x, z] = mergedRegion.chunks[x, z];
                    }
                }
            }
            else
            {
                ConsoleOutput.WriteWarning($"Merge region '{otherRegionName}' was not found, no merging was done");
            }
        }
Exemplo n.º 2
0
		public void Run()
		{
			MCUtilsConsole.WriteLine("Enter path to region file 1:");
			string r1 = GetFilePath(false);
			if (r1 == null) return;
			MCUtilsConsole.WriteLine("Enter path to region file 2:");
			string r2 = GetFilePath(false);
			if (r2 == null) return;
			MCUtilsConsole.WriteLine("Enter path to map image:");
			string map = GetFilePath(false);
			if (map == null) return;
			MCUtilsConsole.WriteLine("Enter path to output file:");
			string savepath = GetFilePath(true);
			MCUtilsConsole.WriteLine("Starting merge...");
			Region region1;
			Region region2;
			try
			{
				region1 = RegionLoader.LoadRegion(r1);
				region2 = RegionLoader.LoadRegion(r2);
			}
			catch (Exception e)
			{
				MCUtilsConsole.WriteError("Failed to open region file(s):");
				MCUtilsConsole.WriteError(e.ToString());
				return;
			}
			Bitmap mask = new Bitmap(map);
			var merger = new RegionMerger(region1, region2, mask);
			MCUtilsConsole.WriteLine("Merging ...");
			var mergedRegion = merger.Merge();
			MCUtilsConsole.WriteLine("Writing file...");
			FileStream stream = new FileStream(savepath, FileMode.Create);
			RegionSerializer.WriteRegionToStream(mergedRegion, stream, Version.DefaultVersion);
			stream.Close();
			MCUtilsConsole.WriteLine("Done");
		}