public static structPoint MakeInsideCity(BlockManager bm, BetaWorld worldDest, int[,] intArea, frmMace frmLogForm) { int intBlockStart = City.FarmLength + 13; structPoint spMineshaftEntrance = MakeBuildings(bm, intArea, intBlockStart, worldDest); worldDest.Save(); if (City.HasPaths) { JoinPathsToRoad(bm); } else { RemovePaths(bm, intArea, intBlockStart); } frmLogForm.UpdateLog("Creating street lights: " + City.StreetLightType, true, true); MakeStreetLights(bm); if (City.HasFlowers) { frmLogForm.UpdateLog("Creating flowers", true, true); MakeFlowers(bm, worldDest); } return(spMineshaftEntrance); }
public static structPoint MakeInsideCity(BlockManager bm, AnvilWorld worldDest, int[,] intArea, frmMace frmLogForm) { int intBlockStart = City.edgeLength + 13; structPoint spMineshaftEntrance = MakeBuildings(bm, intArea, intBlockStart, worldDest); worldDest.Save(); if (City.hasPaths) { JoinPathsToRoad(bm); } else { RemovePaths(bm, intArea, intBlockStart); } if (City.hasMainStreets) { frmLogForm.UpdateLog("Creating street lights: " + City.streetLightType, true, true); MakeStreetLights(bm); } return spMineshaftEntrance; }
private static int[, ,] AddResources(int[, ,] intEnlargedArea, int Y, frmMace frmLogForm, string strUndergroundOres) { int X, Z; int intResources = City.mapLength * Y * (City.farmLength + City.mapLength); switch (strUndergroundOres) { case "Sparse": intResources /= 400; break; case "Uncommon": intResources /= 300; break; case "Normal": intResources /= 200; break; case "Common": intResources /= 100; break; case "Dense": intResources /= 50; break; default: intResources /= 200; Debug.Fail("Invalid switch for underground ores."); break; } frmLogForm.UpdateLog("Adding resource patches: " + intResources, true, true); do { X = RNG.Next(1, intEnlargedArea.GetLength(0) - 1); Y = RNG.Next(1, intEnlargedArea.GetLength(1) - 1); Z = RNG.Next(1, intEnlargedArea.GetLength(2) - 1); if (intEnlargedArea[X, Y, Z] == BlockInfo.Stone.ID) { double dblDepth = (double)Y / intEnlargedArea.GetLength(1); // this increases ore frequency as we get lower if (dblDepth < RNG.NextDouble() * 1.5) { intEnlargedArea[X, Y, Z] = SelectRandomResource(dblDepth); intResources--; } } } while (intResources > 0); return(intEnlargedArea); }
private static int[, ,] AddResources(int[, ,] intEnlargedArea, int Y, frmMace frmLogForm) { int X, Z; int intResources = (int)(City.MapLength * Y * City.MapLength * 0.005); frmLogForm.UpdateLog("Adding resource patches: " + intResources, true, true); do { X = RandomHelper.Next(1, intEnlargedArea.GetLength(0) - 1); Y = RandomHelper.Next(1, intEnlargedArea.GetLength(1) - 1); Z = RandomHelper.Next(1, intEnlargedArea.GetLength(2) - 1); if (intEnlargedArea[X, Y, Z] == BlockInfo.Stone.ID) { double dblDepth = (double)Y / intEnlargedArea.GetLength(1); // this increases ore frequency as we get lower if (dblDepth < RandomHelper.NextDouble() * 1.5) { intEnlargedArea[X, Y, Z] = SelectRandomResource(dblDepth); intResources--; } } } while (intResources > 0); return(intEnlargedArea); }
public static void Generate(frmMace frmLogForm, string strUserCityName, bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeBuildings, bool booIncludePaths, bool booIncludeMineshaft, bool booIncludeItemsInChests, bool booIncludeValuableBlocks, bool booIncludeGhostdancerSpawners, string strCitySize, string strMoatType, string strCityEmblem, string strOutsideLights, string strTowerAddition, string strWallMaterial, string strCitySeed, string strWorldSeed, bool booExportSchematic) { #region seed the random number generators int intCitySeed, intWorldSeed; Random randSeeds = new Random(); if (strCitySeed.Length == 0) { intCitySeed = randSeeds.Next(); frmLogForm.UpdateLog("Random city seed: " + intCitySeed); } else { intCitySeed = JavaStringHashCode(strCitySeed); frmLogForm.UpdateLog("Random city seed: " + strCitySeed); } if (strWorldSeed.Length == 0) { intWorldSeed = randSeeds.Next(); frmLogForm.UpdateLog("Random world seed: " + intWorldSeed); } else { intWorldSeed = JavaStringHashCode(strWorldSeed); frmLogForm.UpdateLog("Random world seed: " + strWorldSeed); } RandomHelper.SetSeed(intCitySeed); #endregion #region create minecraft world directory from a random unused city name string strFolder = String.Empty, strCityName = String.Empty; strUserCityName = SafeFilename(strUserCityName); if (strUserCityName.ToLower().Trim().Length == 0) { strUserCityName = "random"; } if (strUserCityName.ToLower().Trim() != "random") { if (Directory.Exists(Utils.GetMinecraftSavesDirectory(strUserCityName))) { if (MessageBox.Show("A world called \"" + strUserCityName + "\" already exists. " + "Would you like to use a random name instead?", "World already exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { frmLogForm.UpdateLog("Cancelled, because a world with this name already exists."); return; } } else { strCityName = strUserCityName; strFolder = Utils.GetMinecraftSavesDirectory(strCityName); } } if (strCityName.Length == 0) { string strStart, strEnd; do { strStart = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityAdj.txt")); strEnd = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityNoun.txt")); strCityName = "City of " + strStart + strEnd; strFolder = Utils.GetMinecraftSavesDirectory(strCityName); } while (strStart.ToLower().Trim() == strEnd.ToLower().Trim() || Directory.Exists(strFolder) || (strStart + strEnd).Length > 14); } Directory.CreateDirectory(strFolder); RandomHelper.SetSeed(intCitySeed); #endregion #region get handles to world, chunk manager and block manager BetaWorld worldDest = BetaWorld.Create(@strFolder); BetaChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion #region determine block sizes // first we set the city size by chunks int intCitySize = 12; switch (strCitySize) { case "Random": intCitySize = RandomHelper.Next(8, 16); break; case "Very small": intCitySize = 5; break; case "Small": intCitySize = 8; break; case "Medium": intCitySize = 12; break; case "Large": intCitySize = 16; break; case "Very large": intCitySize = 25; break; default: Debug.Fail("Invalid switch result"); break; } // then we multiply by 16, because that's the x and z of a chunk intCitySize *= 16; int intFarmLength = booIncludeFarms ? 32 : 8; int intMapLength = intCitySize + (intFarmLength * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest, intMapLength); BlockHelper.SetupClass(bmDest, intMapLength); if (!SourceWorld.SetupClass(worldDest, booIncludeItemsInChests, booIncludeGhostdancerSpawners)) { return; } NoticeBoard.SetupClass(intCitySeed, intWorldSeed); #endregion #region determine random options // ensure selected options take priority, but don't set things on fire if (strTowerAddition == "Random") { strTowerAddition = RandomHelper.RandomString("Fire beacon", "Flag"); } if (strWallMaterial.StartsWith("Wood")) { if (strMoatType == "Lava" || strMoatType == "Fire" || strMoatType == "Random") { strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water"); } strOutsideLights = "Torches"; } if (strWallMaterial == "Random") { if (strMoatType == "Lava" || strMoatType == "Fire" || strOutsideLights == "Fire") { strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone", "Stone"); } else { strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone", "Stone", "Wood Planks"); if (strWallMaterial.StartsWith("Wood")) { if (strMoatType == "Random") { strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water"); } strOutsideLights = "Torches"; } } } if (strOutsideLights == "Random") { strOutsideLights = RandomHelper.RandomString("Fire", "Torches"); } if (strMoatType == "Random") { int intRand = RandomHelper.Next(100); if (intRand >= 90) { strMoatType = "Drop to Bedrock"; } else if (intRand >= 80) { strMoatType = "Cactus"; } else if (intRand >= 50) { strMoatType = "Lava"; } else if (intRand >= 40) { strMoatType = "Fire"; } else { strMoatType = "Water"; } } int intWallMaterial = BlockType.STONE; switch (strWallMaterial) { case "Brick": intWallMaterial = BlockType.BRICK_BLOCK; break; case "Cobblestone": intWallMaterial = BlockType.COBBLESTONE; break; case "Sandstone": intWallMaterial = BlockType.SANDSTONE; break; case "Stone": intWallMaterial = BlockType.STONE; break; case "Wood Planks": intWallMaterial = BlockType.WOOD_PLANK; break; case "Wood Logs": intWallMaterial = BlockType.WOOD; break; case "Bedrock": intWallMaterial = BlockType.BEDROCK; break; case "Mossy Cobblestone": intWallMaterial = BlockType.MOSS_STONE; break; case "Netherrack": intWallMaterial = BlockType.NETHERRACK; break; case "Glass": intWallMaterial = BlockType.GLASS; break; case "Ice": intWallMaterial = BlockType.ICE; break; case "Snow": intWallMaterial = BlockType.SNOW_BLOCK; break; case "Glowstone": intWallMaterial = BlockType.GLOWSTONE_BLOCK; break; case "Dirt": intWallMaterial = BlockType.DIRT; break; case "Obsidian": intWallMaterial = BlockType.OBSIDIAN; break; case "Jack-o-Lantern": intWallMaterial = BlockType.JACK_O_LANTERN; break; case "Soul sand": intWallMaterial = BlockType.SOUL_SAND; break; case "Gold": intWallMaterial = BlockType.GOLD_BLOCK; break; case "Diamond": intWallMaterial = BlockType.DIAMOND_BLOCK; break; default: Debug.Fail("Invalid switch result"); break; } #endregion #region make the city frmLogForm.UpdateLog("Creating underground terrain"); Chunks.CreateInitialChunks(cmDest, intMapLength / 16, frmLogForm); frmLogForm.UpdateProgress(25); Buildings.structPoint spMineshaftEntrance = new Buildings.structPoint(); if (booIncludeWalls) { frmLogForm.UpdateLog("Creating walls"); Walls.MakeWalls(worldDest, intFarmLength, intMapLength, strCityEmblem, strOutsideLights, intWallMaterial); } frmLogForm.UpdateProgress(34); if (booIncludeBuildings || booIncludePaths) { frmLogForm.UpdateLog("Creating paths"); int[,] intArea = Paths.MakePaths(worldDest, bmDest, intFarmLength, intMapLength, strCitySize, booIncludeMineshaft); frmLogForm.UpdateProgress(36); if (booIncludeBuildings) { frmLogForm.UpdateLog("Creating buildings"); spMineshaftEntrance = Buildings.MakeInsideCity(bmDest, worldDest, intArea, intFarmLength, intMapLength, booIncludePaths); frmLogForm.UpdateProgress(45); if (booIncludeMineshaft) { frmLogForm.UpdateLog("Creating mineshaft"); Mineshaft.MakeMineshaft(worldDest, bmDest, intFarmLength, intMapLength, spMineshaftEntrance); } } } frmLogForm.UpdateProgress(51); if (booIncludeMoat) { frmLogForm.UpdateLog("Creating moat"); Moat.MakeMoat(intFarmLength, intMapLength, strMoatType, booIncludeGuardTowers); } frmLogForm.UpdateProgress(52); if (booIncludeDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges"); Drawbridge.MakeDrawbridges(bmDest, intFarmLength, intMapLength, booIncludeMoat, booIncludeWalls, booIncludeItemsInChests, intWallMaterial, strMoatType, strCityName); } frmLogForm.UpdateProgress(53); if (booIncludeGuardTowers) { frmLogForm.UpdateLog("Creating guard towers"); GuardTowers.MakeGuardTowers(bmDest, intFarmLength, intMapLength, booIncludeWalls, strOutsideLights, strTowerAddition, booIncludeItemsInChests, intWallMaterial); } frmLogForm.UpdateProgress(54); if (booIncludeFarms) { frmLogForm.UpdateLog("Creating farms"); Farms.MakeFarms(worldDest, bmDest, intFarmLength, intMapLength); } frmLogForm.UpdateProgress(58); if (!booIncludeValuableBlocks) { cmDest.Save(); worldDest.Save(); Chunks.ReplaceValuableBlocks(worldDest, bmDest, intMapLength, intWallMaterial); } frmLogForm.UpdateProgress(60); Chunks.PositionRails(worldDest, bmDest, intMapLength); frmLogForm.UpdateProgress(62); #endregion #region world settings // spawn looking at one of the city entrances if (booIncludeFarms) { SpawnPoint spLevel = new SpawnPoint(7, 11, 13); worldDest.Level.Spawn = spLevel; worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength - (intFarmLength - 10)); } else { worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength - (intFarmLength - 7)); } // spawn in the middle of the city //#if DEBUG //worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength / 2); //#endif if (strWorldSeed.Length > 0) { worldDest.Level.RandomSeed = intWorldSeed; } #if RELEASE worldDest.Level.Time = RandomHelper.Next(24000); if (RandomHelper.NextDouble() < 0.15) { worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = RandomHelper.Next(6000, 18000); if (RandomHelper.NextDouble() < 0.25) { worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endif #endregion #if DEBUG MakeHelperChest(bmDest, worldDest.Level.Spawn.X + 2, worldDest.Level.Spawn.Y, worldDest.Level.Spawn.Z + 2); #endif frmLogForm.UpdateLog("Creating lighting data"); Chunks.ResetLighting(worldDest, cmDest, frmLogForm, (int)Math.Pow(intMapLength / 16, 2)); worldDest.Level.LevelName = strCityName; worldDest.Save(); if (booExportSchematic) { frmLogForm.UpdateLog("Creating schematic"); AlphaBlockCollection abcExport = new AlphaBlockCollection(intMapLength, 128, intMapLength); for (int x = 0; x < intMapLength; x++) { for (int z = 0; z < intMapLength; z++) { for (int y = 0; y < 128; y++) { abcExport.SetBlock(x, y, z, bmDest.GetBlock(x, y, z)); } } } Schematic CitySchematic = new Schematic(intMapLength, 128, intMapLength); CitySchematic.Blocks = abcExport; CitySchematic.Export(Utils.GetMinecraftSavesDirectory(strCityName) + "\\" + strCityName + ".schematic"); } frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!"); frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list."); }
public void Generate(frmMace frmLogForm, string strUserCityName, bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeBuildings, bool booIncludePaths, bool booIncludeMineshaft, bool booIncludeItemsInChests, bool booIncludeValuableBlocks, string strCitySize, string strMoatType, string strCityEmblem, string strOutsideLights, string strTowerAddition, string strWallMaterial, string strCitySeed, string strWorldSeed) { #region seed the random number generators int intCitySeed, intWorldSeed; Random randSeeds = new Random(); if (strCitySeed == "") { intCitySeed = randSeeds.Next(); frmLogForm.UpdateLog("Random city seed: " + intCitySeed); } else { intCitySeed = JavaStringHashCode(strCitySeed); frmLogForm.UpdateLog("Random city seed: " + strCitySeed); } if (strWorldSeed == "") { intWorldSeed = randSeeds.Next(); frmLogForm.UpdateLog("Random world seed: " + intWorldSeed); } else { intWorldSeed = JavaStringHashCode(strWorldSeed); frmLogForm.UpdateLog("Random world seed: " + strWorldSeed); } RandomHelper.SetSeed(intCitySeed); #endregion #region create minecraft world directory from a random unused city name string strFolder = "", strCityName = ""; strUserCityName = SafeFilename(strUserCityName); if (strUserCityName.ToLower().Trim() == "") { strUserCityName = "Random"; } if (strUserCityName.ToLower().Trim() != "random") { if (Directory.Exists(Utils.GetMinecraftSavesDir(strUserCityName))) { if (MessageBox.Show("A world called \"" + strUserCityName + "\" already exists. " + "Would you like to use a random name instead?", "World already exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { frmLogForm.UpdateLog("Cancelled, because a world with this name already exists."); return; } } else { strCityName = strUserCityName; strFolder = Utils.GetMinecraftSavesDir(strCityName); } } if (strCityName == "") { string strStart, strEnd; do { strStart = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityAdj.txt")); strEnd = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityNoun.txt")); strCityName = "City of " + strStart + strEnd; strFolder = Utils.GetMinecraftSavesDir(strCityName); } while (strStart.ToLower().Trim() == strEnd.ToLower().Trim() || Directory.Exists(strFolder)); } Directory.CreateDirectory(strFolder); RandomHelper.SetSeed(intCitySeed); #endregion #region get handles to world, chunk manager and block manager BetaWorld worldDest = BetaWorld.Create(@strFolder); ChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion #region determine block sizes // first we set the city size by chunks int intCitySize = 12; switch (strCitySize) { case "Random": intCitySize = RandomHelper.Next(8, 16); break; case "Very small": intCitySize = 5; break; case "Small": intCitySize = 8; break; case "Medium": intCitySize = 12; break; case "Large": intCitySize = 16; break; case "Very large": intCitySize = 25; break; } // then we multiply by 16, because that's the x and z of a chunk intCitySize *= 16; int intFarmSize = booIncludeFarms ? 32 : 16; int intMapSize = intCitySize + (intFarmSize * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest, intMapSize); BlockHelper.SetupClass(bmDest, intMapSize); if (!SourceWorld.SetupClass(worldDest, booIncludeItemsInChests)) { return; } NoticeBoard.SetupClass(intCitySeed, intWorldSeed); #endregion #region determine random options // ensure selected options take priority, but don't set things on fire if (strTowerAddition == "Random") { strTowerAddition = RandomHelper.RandomString("Fire beacon", "Flag"); } if (strWallMaterial.StartsWith("Wood")) { if (strMoatType == "Lava" || strMoatType == "Random") { strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water"); } strOutsideLights = "Torches"; } if (strWallMaterial == "Random") { if (strMoatType == "Lava" || strOutsideLights == "Fire") { strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone", "Stone"); } else { strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone", "Stone", "Wood Planks"); if (strWallMaterial.StartsWith("Wood")) { if (strMoatType == "Random") { strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water"); } strOutsideLights = "Torches"; } } } if (strOutsideLights == "Random") { strOutsideLights = RandomHelper.RandomString("Fire", "Torches"); } if (strMoatType == "Random") { int intRand = RandomHelper.Next(100); if (intRand >= 90) { strMoatType = "Drop to Bedrock"; } else if (intRand >= 80) { strMoatType = "Cactus"; } else if (intRand >= 50) { strMoatType = "Lava"; } else { strMoatType = "Water"; } } int intWallMaterial = (int)BlockType.STONE; switch (strWallMaterial) { case "Brick": intWallMaterial = (int)BlockType.BRICK_BLOCK; break; case "Cobblestone": intWallMaterial = (int)BlockType.COBBLESTONE; break; case "Sandstone": intWallMaterial = (int)BlockType.SANDSTONE; break; case "Stone": intWallMaterial = (int)BlockType.STONE; break; case "Wood Planks": intWallMaterial = (int)BlockType.WOOD_PLANK; break; case "Wood Logs": intWallMaterial = (int)BlockType.WOOD; break; case "Bedrock": intWallMaterial = (int)BlockType.BEDROCK; break; case "Glass": intWallMaterial = (int)BlockType.GLASS; break; case "Dirt": intWallMaterial = (int)BlockType.DIRT; break; case "Obsidian": intWallMaterial = (int)BlockType.OBSIDIAN; break; } #endregion #region make the city frmLogForm.UpdateLog("Creating underground terrain"); Chunks.MakeChunks(cmDest, intMapSize / 16, frmLogForm); frmLogForm.UpdateProgress(25); if (booIncludeBuildings || booIncludePaths) { frmLogForm.UpdateLog("Creating paths"); int[,] intArea = Paths.MakePaths(worldDest, bmDest, intFarmSize, intMapSize); frmLogForm.UpdateProgress(34); if (booIncludeBuildings) { frmLogForm.UpdateLog("Creating buildings"); Buildings.MakeInsideCity(bmDest, worldDest, intArea, intFarmSize, intMapSize, booIncludePaths); } } frmLogForm.UpdateProgress(43); if (booIncludeMineshaft) { frmLogForm.UpdateLog("Creating mineshaft"); Mineshaft.MakeMineshaft(worldDest, bmDest, intFarmSize, intMapSize); frmLogForm.UpdateProgress(49); } if (booIncludeWalls) { frmLogForm.UpdateLog("Creating walls"); Walls.MakeWalls(worldDest, intFarmSize, intMapSize, strCityEmblem, strOutsideLights, intWallMaterial); } frmLogForm.UpdateProgress(51); if (booIncludeMoat) { frmLogForm.UpdateLog("Creating moat"); Moat.MakeMoat(intFarmSize, intMapSize, strMoatType, booIncludeGuardTowers); } frmLogForm.UpdateProgress(52); if (booIncludeDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges"); Drawbridge.MakeDrawbridges(bmDest, intFarmSize, intMapSize, booIncludeMoat, booIncludeWalls, booIncludeItemsInChests, intWallMaterial, strMoatType); } frmLogForm.UpdateProgress(53); if (booIncludeGuardTowers) { frmLogForm.UpdateLog("Creating guard towers"); GuardTowers.MakeGuardTowers(bmDest, intFarmSize, intMapSize, booIncludeWalls, strOutsideLights, strTowerAddition, booIncludeItemsInChests, intWallMaterial); } frmLogForm.UpdateProgress(54); if (booIncludeFarms) { frmLogForm.UpdateLog("Creating farms"); Farms.MakeFarms(worldDest, bmDest, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(58); if (!booIncludeValuableBlocks) { cmDest.Save(); worldDest.Save(); Chunks.ReplaceValuableBlocks(worldDest, bmDest, intMapSize); } frmLogForm.UpdateProgress(62); #endregion #region world settings // spawn in a guard tower //worldDest.Level.SpawnX = intFarmSize + 5; //worldDest.Level.SpawnZ = intFarmSize + 5; //worldDest.Level.SpawnY = 82; // spawn looking at one of the city entrances worldDest.Level.SpawnX = intMapSize / 2; worldDest.Level.SpawnZ = intMapSize - (intFarmSize - 10); worldDest.Level.SpawnY = 64; // spawn in the middle of the city //worldDest.Level.SpawnX = intMapSize / 2; //worldDest.Level.SpawnZ = (intMapSize / 2) - 1; //worldDest.Level.SpawnY = 64; // spawn default //world.Level.SpawnX = 0; //world.Level.SpawnY = 65; //world.Level.SpawnZ = 0; if (strWorldSeed != "") { worldDest.Level.RandomSeed = intWorldSeed; } worldDest.Level.LevelName = strCityName; #if RELEASE worldDest.Level.Time = RandomHelper.Next(24000); if (RandomHelper.NextDouble() < 0.15) { worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = RandomHelper.Next(6000, 18000); if (RandomHelper.NextDouble() < 0.25) { worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endif #endregion #if DEBUG MakeHelperChest(bmDest, worldDest.Level.SpawnX + 2, worldDest.Level.SpawnY, worldDest.Level.SpawnZ + 2); #endif frmLogForm.UpdateLog("Resetting lighting"); Chunks.ResetLighting(worldDest, cmDest, frmLogForm, (int)Math.Pow(intMapSize / 16, 2)); worldDest.Save(); frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!"); frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list."); }
// todo low: long code is long static public void Generate(frmMace frmLogForm, string UserWorldName, string strWorldSeed, string strWorldType, bool booWorldMapFeatures, int TotalCities, string[] strCheckedThemes, int ChunksBetweenCities, string strSpawnPoint) { worldCities = new WorldCity[TotalCities]; lstCityNames.Clear(); RandomHelper.SetRandomSeed(); #region create minecraft world directory from a random unused city name string strFolder = String.Empty, strWorldName = String.Empty; UserWorldName = Utils.SafeFilename(UserWorldName); if (UserWorldName.Trim().Length == 0) { UserWorldName = "random"; } if (UserWorldName.ToLower().Trim() != "random") { if (Directory.Exists(Utils.GetMinecraftSavesDirectory(UserWorldName))) { if (MessageBox.Show("A world called \"" + UserWorldName + "\" already exists. " + "Would you like to use a random name instead?", "World already exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { frmLogForm.UpdateLog("Cancelled, because a world with this name already exists.", false, false); return; } } else { strWorldName = UserWorldName; strFolder = Utils.GetMinecraftSavesDirectory(strWorldName); } } if (strWorldName.Length == 0) { strWorldName = Utils.GenerateWorldName(); strFolder = Utils.GetMinecraftSavesDirectory(strWorldName); } Directory.CreateDirectory(strFolder); frmLogForm.UpdateLog("World name: " + strWorldName, false, true); #endregion #region get handles to world, chunk manager and block manager BetaWorld worldDest = BetaWorld.Create(@strFolder); worldDest.Level.LevelName = "Creating. Don't open until Mace is finished."; BetaChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion #region Determine themes // "how does this work, robson?" // well, I'm glad you asked! // we keep selecting a random unused checked theme, until they've all been used once. // after that, all other cities will have a random checked theme strCheckedThemes = RandomHelper.ShuffleArray(strCheckedThemes); for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++) { if (CurrentCityID <= strCheckedThemes.GetUpperBound(0)) { worldCities[CurrentCityID].ThemeName = strCheckedThemes[CurrentCityID]; } else { worldCities[CurrentCityID].ThemeName = RandomHelper.RandomString(strCheckedThemes); } Debug.WriteLine(worldCities[CurrentCityID].ThemeName); City.ThemeName = worldCities[CurrentCityID].ThemeName; worldCities[CurrentCityID].ChunkLength = GetThemeRandomXMLElementNumber("options", "city_size"); } #endregion GenerateCityLocations(TotalCities, ChunksBetweenCities); int intRandomCity = RandomHelper.Next(TotalCities); for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++) { MakeCitySettings(frmLogForm, worldCities[CurrentCityID].ThemeName, CurrentCityID); GenerateCity.Generate(frmLogForm, worldDest, cmDest, bmDest, worldCities[CurrentCityID].x, worldCities[CurrentCityID].z); #region set spawn point if (City.ID == intRandomCity) { switch (strSpawnPoint) { case "Away from the cities": worldDest.Level.Spawn = new SpawnPoint(0, 65, 0); break; case "Inside a random city": worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + 30) * 16) + (City.MapLength / 2), 65, ((worldCities[intRandomCity].z + 30) * 16) + (City.MapLength / 2)); break; case "Outside a random city": if (City.HasFarms) { worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + 30) * 16) + (City.MapLength / 2), 65, ((worldCities[intRandomCity].z + 30) * 16) + 20); } else { worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + 30) * 16) + (City.MapLength / 2), 65, ((worldCities[intRandomCity].z + 30) * 16) + 2); } break; default: Debug.Fail("invalid spawn point"); break; } frmLogForm.UpdateLog("Spawn point set to " + worldDest.Level.Spawn.X + "," + worldDest.Level.Spawn.Y + "," + worldDest.Level.Spawn.Z, false, true); } #endregion } City.ID = TotalCities; frmLogForm.UpdateProgress(0); #region weather #if RELEASE frmLogForm.UpdateLog("Setting weather", false, true); worldDest.Level.Time = RandomHelper.Next(24000); if (RandomHelper.NextDouble() < 0.2) { frmLogForm.UpdateLog("Rain", false, true); worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = RandomHelper.Next(6000, 18000); if (RandomHelper.NextDouble() < 0.25) { frmLogForm.UpdateLog("Thunder", false, true); worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endif #endregion #if DEBUG MakeHelperChest(bmDest, worldDest.Level.Spawn.X + 2, worldDest.Level.Spawn.Y, worldDest.Level.Spawn.Z + 2); #endif #region lighting frmLogForm.UpdateLog("\nCreating world lighting data", false, false); Chunks.ResetLighting(worldDest, cmDest, frmLogForm); frmLogForm.UpdateProgress(0.95); #endregion #region world details worldDest.Level.LevelName = strWorldName; frmLogForm.UpdateLog("Setting world type: " + strWorldType, false, true); switch (strWorldType.ToLower()) { case "creative": worldDest.Level.GameType = GameType.CREATIVE; break; case "survival": worldDest.Level.GameType = GameType.SURVIVAL; break; case "hardcore": worldDest.Level.GameType = GameType.SURVIVAL; worldDest.Level.UseHardcoreMode = true; break; default: Debug.Fail("Invalidate world type selected."); break; } frmLogForm.UpdateLog("World map features: " + booWorldMapFeatures.ToString(), false, true); worldDest.Level.UseMapFeatures = booWorldMapFeatures; if (strWorldSeed != String.Empty) { worldDest.Level.RandomSeed = Utils.JavaStringHashCode(strWorldSeed); frmLogForm.UpdateLog("Specified world seed: " + worldDest.Level.RandomSeed, false, true); } else { worldDest.Level.RandomSeed = RandomHelper.Next(); frmLogForm.UpdateLog("Random world seed: " + worldDest.Level.RandomSeed, false, true); } worldDest.Level.LastPlayed = (DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks) / 10000; frmLogForm.UpdateLog("World time: " + worldDest.Level.LastPlayed, false, true); #endregion worldDest.Save(); frmLogForm.UpdateProgress(1); frmLogForm.UpdateLog("\nCreated the " + strWorldName + "!", false, false); frmLogForm.UpdateLog("It'll be at the top of your MineCraft world list.", false, false); // todo low: export schematic #region export schematic //if (booExportSchematic) //{ // frmLogForm.UpdateLog("Creating schematic"); // AlphaBlockCollection abcExport = new AlphaBlockCollection(intMapLength, 128, intMapLength); // for (int x = 0; x < intMapLength; x++) // { // for (int z = 0; z < intMapLength; z++) // { // for (int y = 0; y < 128; y++) // { // abcExport.SetBlock(x, y, z, bmDest.GetBlock(x, y, z)); // } // } // } // Schematic CitySchematic = new Schematic(intMapLength, 128, intMapLength); // CitySchematic.Blocks = abcExport; // CitySchematic.Export(Utils.GetMinecraftSavesDirectory(strCityName) + "\\" + strCityName + ".schematic"); //} #endregion }
// todo low: this is way too big private static void MakeLevel(BetaWorld world, BlockManager bm, int intDepth, int intMineshaftSize, Buildings.structPoint spMineshaftEntrance, frmMace frmLogForm) { frmLogForm.UpdateLog("Creating mineshaft level " + intDepth, true, true); string[] strResourceNames = Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"), "level" + intDepth, "names").Split(','); int[] intResourceChances = Utils.StringArrayToIntArray(Utils.ValueFromXMLElement( Path.Combine("Resources", "Mineshaft.xml"), "level" + intDepth, "chances").Split(',')); int intTorchChance = Convert.ToInt32(Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"), "level" + intDepth, "torch_chance")); MineshaftBlocks[,] mbAreaFull = new MineshaftBlocks[intMineshaftSize + (MULTIPLIER * 2), intMineshaftSize + (MULTIPLIER * 2)]; //int[,] mbAreaFull = new int[intMineshaftSize + (MULTIPLIER * 2), intMineshaftSize + (MULTIPLIER * 2)]; int intXPosOriginal = spMineshaftEntrance.x - _intBlockStartBuildings; int intZPosOriginal = spMineshaftEntrance.z - _intBlockStartBuildings; _intBlockStartBuildings -= 2; int[,] intAreaOverview = new int[(mbAreaFull.GetLength(0) / MULTIPLIER), (mbAreaFull.GetLength(1) / MULTIPLIER)]; int intXPos = intXPosOriginal / MULTIPLIER; int intZPos = intZPosOriginal / MULTIPLIER; intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air; CreateRouteXPlus(intAreaOverview, intXPos + 1, intZPos, 0); CreateRouteZPlus(intAreaOverview, intXPos, intZPos + 1, 1); CreateRouteXMinus(intAreaOverview, intXPos - 1, intZPos, 2); CreateRouteZMinus(intAreaOverview, intXPos, intZPos - 1, 3); int intOffsetX = (intXPosOriginal - (intXPos * MULTIPLIER)) - 2; int intOffsetZ = (intZPosOriginal - (intZPos * MULTIPLIER)) - 2; List <structSection> lstSections = new List <structSection>(); intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Placeholder; intAreaOverview = AddMineshaftSections(intAreaOverview, intDepth); intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air; for (int x = 0; x < intAreaOverview.GetLength(0); x++) { for (int z = 0; z < intAreaOverview.GetLength(1); z++) { if (intAreaOverview[x, z] >= 100) { structSection structCurrentSection = new structSection(); structCurrentSection.bldMineshaftSection = SourceWorld.GetBuilding(intAreaOverview[x, z] - 100); structCurrentSection.x = ((x * MULTIPLIER) + intOffsetX) - 1; structCurrentSection.z = ((z * MULTIPLIER) + intOffsetZ) - 1; for (int x2 = x; x2 <= x + (structCurrentSection.bldMineshaftSection.intSizeX - 1) / 7; x2++) { for (int z2 = z; z2 <= z + (structCurrentSection.bldMineshaftSection.intSizeZ - 1) / 7; z2++) { if (intAreaOverview[x2, z2] == structCurrentSection.bldMineshaftSection.intID + 100) { intAreaOverview[x2, z2] = (int)MineshaftBlocks.Structure; } } } lstSections.Add(structCurrentSection); } } } for (int x = 4; x < mbAreaFull.GetLength(0) - 4; x++) { for (int z = 4; z < mbAreaFull.GetLength(1) - 4; z++) { if (intAreaOverview.GetLength(0) > x / MULTIPLIER && intAreaOverview.GetLength(1) > z / MULTIPLIER) { switch (mbAreaFull[x + intOffsetX, z + intOffsetZ]) { case MineshaftBlocks.NaturalTerrain: case MineshaftBlocks.Air: case MineshaftBlocks.Placeholder: case MineshaftBlocks.EntranceSection: mbAreaFull[x + intOffsetX, z + intOffsetZ] = (MineshaftBlocks)intAreaOverview[x / MULTIPLIER, z / MULTIPLIER]; break; } } if ((x + 3) % 5 == 0 && (z + 3) % 5 == 0 && intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air) { if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] >= 100) { for (int x2 = 0; x2 < 5; x2++) { mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Structure; } } if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] == (int)MineshaftBlocks.Air) { for (int x2 = 0; x2 < 5; x2++) { if (x2 == 1 || x2 == 3) { mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.CeilingSupport; mbAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = MineshaftBlocks.CeilingSupport; } else { mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Support; mbAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Support; } } for (int x2 = 0; x2 <= 5; x2++) { if (mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] == MineshaftBlocks.Support) { mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] = MineshaftBlocks.RailWithSupport; } else { mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] = MineshaftBlocks.Rail; } } } if (intAreaOverview[x / MULTIPLIER, (z / MULTIPLIER) + 1] == (int)MineshaftBlocks.Air) { for (int z2 = 0; z2 < 5; z2++) { if (z2 == 1 || z2 == 3) { mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = MineshaftBlocks.CeilingSupport; mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = MineshaftBlocks.CeilingSupport; } else { mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = MineshaftBlocks.Support; mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = MineshaftBlocks.Support; } } for (int z2 = 0; z2 <= 5; z2++) { if (mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] == MineshaftBlocks.Support) { mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] = MineshaftBlocks.RailWithSupport; } else { mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] = MineshaftBlocks.Rail; } } } if (intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air) { MakeChestAndOrTorch(intAreaOverview, mbAreaFull, (x - 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX - 2, z + intOffsetZ); MakeChestAndOrTorch(intAreaOverview, mbAreaFull, (x + 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX + 2, z + intOffsetZ); MakeChestAndOrTorch(intAreaOverview, mbAreaFull, x / MULTIPLIER, (z - 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ - 2); MakeChestAndOrTorch(intAreaOverview, mbAreaFull, x / MULTIPLIER, (z + 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ + 2); } } } } mbAreaFull[intXPosOriginal, intZPosOriginal] = MineshaftBlocks.EntranceSection; int intSupportMaterial = RandomHelper.RandomNumber(BlockInfo.Wood.ID, BlockInfo.WoodPlank.ID, BlockInfo.Fence.ID); for (int x = 0; x < mbAreaFull.GetLength(0); x++) { for (int z = 0; z < mbAreaFull.GetLength(1); z++) { if (intDepth <= 4) { if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Gravel.ID) { bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockInfo.Stone.ID); } } if (intDepth <= 2) { if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Sand.ID || bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Sandstone.ID) { bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockInfo.Dirt.ID); } } switch (mbAreaFull[x, z]) { case MineshaftBlocks.NaturalTerrain: break; case MineshaftBlocks.Air: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } break; case MineshaftBlocks.EntranceSection: case MineshaftBlocks.Rail: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Gravel.ID); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Rails.ID); } else { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } } break; case MineshaftBlocks.RailWithSupport: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Gravel.ID); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Rails.ID); } else if (y == 40 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } else { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intSupportMaterial); } } break; case MineshaftBlocks.Support: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intSupportMaterial); } break; case MineshaftBlocks.ChestAndOrTorch: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 39 - (5 * intDepth) && RandomHelper.NextDouble() > 0.9) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Chest.ID); MakeChestItems(bm, x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intResourceChances, strResourceNames); } else if (y == 41 - (5 * intDepth) && RandomHelper.NextDouble() < (double)intTorchChance / 100) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Torch.ID); if (mbAreaFull[x - 1, z] == 0) { bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 1); } else if (mbAreaFull[x + 1, z] == 0) { bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 2); } else if (mbAreaFull[x, z - 1] == 0) { bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 3); } else { bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 4); } } else { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } } break; case MineshaftBlocks.CeilingSupport: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 41 - (5 * intDepth)) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intSupportMaterial); } else { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } } break; case MineshaftBlocks.Unused9: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * (intDepth - 1)); y++) { bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID); } break; case MineshaftBlocks.Structure: // this will be overwritten later break; default: Debug.Fail("Invalid switch result"); break; } } } foreach (structSection MineshaftSection in lstSections) { SourceWorld.InsertBuilding(bm, new int[0, 0], _intBlockStartBuildings, MineshaftSection.x, MineshaftSection.z, MineshaftSection.bldMineshaftSection, 38 - (5 * intDepth)); } world.Save(); _intBlockStartBuildings += 2; //#if DEBUG // File.WriteAllText("output_area_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaOverview)); // File.WriteAllText("output_map_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaFull)); //#endif }
public static void MakeMoat(frmMace frmLogForm) { frmLogForm.UpdateLog("Moat type: " + City.MoatType, true, true); switch (City.MoatType) { case "Drop to Bedrock": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 2, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } break; case "Cactus": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 63, 63, a, City.MapLength - a, BlockInfo.Sand.ID, 0, -1); } for (int a = City.FarmLength + 1; a <= City.MapLength / 2; a += 2) { if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.FarmLength + 1, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength + 1, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.FarmLength + 3, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength + 3, BlockInfo.Cactus.ID, 2, 50, -1); } } for (int a = City.FarmLength; a <= City.MapLength / 2; a += 2) { if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.FarmLength, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.FarmLength + 2, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength + 2, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.FarmLength + 4, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength + 4, BlockInfo.Cactus.ID, 2, 50, -1); } } if (City.HasGuardTowers) { for (int a = City.FarmLength + 3; a <= City.FarmLength + 13; a += 2) { BlockShapes.MakeBlock(a, 64, City.FarmLength + 3, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.FarmLength + 3, BlockInfo.Air.ID, 2, 100, -1); } } break; case "Low Cactus": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 58, a, City.MapLength - a, BlockInfo.Sand.ID, 0, -1); } for (int a = City.FarmLength + 1; a <= City.MapLength / 2; a += 2) { if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.FarmLength + 1, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength + 1, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.FarmLength + 3, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength + 3, BlockInfo.Cactus.ID, 2, 50, -1); } } for (int a = City.FarmLength; a <= City.MapLength / 2; a += 2) { if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.FarmLength, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.FarmLength + 2, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength + 2, BlockInfo.Cactus.ID, 2, 50, -1); } if (RandomHelper.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.FarmLength + 4, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength + 4, BlockInfo.Cactus.ID, 2, 50, -1); } } if (City.HasGuardTowers) { for (int a = City.FarmLength + 3; a <= City.FarmLength + 13; a += 2) { BlockShapes.MakeBlock(a, 59, City.FarmLength + 3, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.FarmLength + 3, BlockInfo.Air.ID, 2, 100, -1); } } break; case "Lava": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 55, 56, a, City.MapLength - a, BlockInfo.Lava.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } break; case "Fire": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 56, 56, a, City.MapLength - a, BlockInfo.Netherrack.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 57, a, City.MapLength - a, BlockInfo.Fire.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } break; case "Water": for (int a = City.FarmLength - 1; a <= City.FarmLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63, a, City.MapLength - a, BlockInfo.Water.ID, 0, -1); } break; default: Debug.Fail("Invalid switch result"); break; } }
public static void MakeGuardTowers(BlockManager bm, frmMace frmLogForm) { // remove wall BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 11, 64, 79, City.EdgeLength + 5, City.EdgeLength + 11, BlockInfo.Air.ID, 1); // add tower BlockShapes.MakeHollowBox(City.EdgeLength + 4, City.EdgeLength + 12, 63, 80, City.EdgeLength + 4, City.EdgeLength + 12, City.WallMaterialID, 1, City.WallMaterialData); // divide into two rooms BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 4, City.EdgeLength + 12, 2, 72, City.EdgeLength + 4, City.EdgeLength + 12, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 11, 64, 67, City.EdgeLength + 5, City.EdgeLength + 11, BlockInfo.Air.ID, 1); switch (City.OutsideLightType) { case "Fire": BlockShapes.MakeBlock(City.EdgeLength + 5, 76, City.EdgeLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 5, 77, City.EdgeLength + 3, BlockInfo.Fire.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 76, City.EdgeLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 77, City.EdgeLength + 3, BlockInfo.Fire.ID, 2, 100, -1); break; case "Torches": for (int y = 73; y <= 80; y += 7) { BlockHelper.MakeTorch(City.EdgeLength + 6, y, City.EdgeLength + 3, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.EdgeLength + 10, y, City.EdgeLength + 3, City.WallMaterialID, 2); } break; case "None": case "": break; default: Debug.Fail("Invalid switch result"); break; } if (City.HasTorchesOnWalkways) { // add torches BlockHelper.MakeTorch(City.EdgeLength + 6, 79, City.EdgeLength + 13, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.EdgeLength + 10, 79, City.EdgeLength + 13, City.WallMaterialID, 2); // add torches inside BlockHelper.MakeTorch(City.EdgeLength + 6, 77, City.EdgeLength + 11, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.EdgeLength + 10, 77, City.EdgeLength + 11, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.EdgeLength + 5, 77, City.EdgeLength + 6, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.EdgeLength + 5, 77, City.EdgeLength + 10, City.WallMaterialID, 2); } // add openings to the walls BlockShapes.MakeBlock(City.EdgeLength + 7, 73, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 9, 73, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 7, 74, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 9, 74, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1); // add blocks on top of the towers BlockShapes.MakeHollowLayers(City.EdgeLength + 4, City.EdgeLength + 12, 81, 81, City.EdgeLength + 4, City.EdgeLength + 12, City.WallMaterialID, 1, City.WallMaterialData); // alternating top blocks for (int x = City.EdgeLength + 4; x <= City.EdgeLength + 12; x += 2) { for (int z = City.EdgeLength + 4; z <= City.EdgeLength + 12; z += 2) { if (x == City.EdgeLength + 4 || x == City.EdgeLength + 12 || z == City.EdgeLength + 4 || z == City.EdgeLength + 12) { BlockShapes.MakeBlock(x, 82, z, City.WallMaterialID, 1, 100, City.WallMaterialData); } } } // add central columns BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 8, City.EdgeLength + 8, 73, 82, City.EdgeLength + 8, City.EdgeLength + 8, City.WallMaterialID, 1, City.WallMaterialData); BlockHelper.MakeLadder(City.EdgeLength + 7, 73, 82, City.EdgeLength + 8, 2, City.WallMaterialID); BlockHelper.MakeLadder(City.EdgeLength + 9, 73, 82, City.EdgeLength + 8, 2, City.WallMaterialID); // add torches on the roof if (City.HasTorchesOnWalkways) { BlockShapes.MakeBlock(City.EdgeLength + 6, 81, City.EdgeLength + 6, BlockInfo.Torch.ID, 1, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 6, 81, City.EdgeLength + 10, BlockInfo.Torch.ID, 2, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 10, 81, City.EdgeLength + 10, BlockInfo.Torch.ID, 1, 100, -1); } // add cobwebs BlockShapes.MakeBlock(City.EdgeLength + 5, 79, City.EdgeLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.EdgeLength + 5, 79, City.EdgeLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 79, City.EdgeLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 79, City.EdgeLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1); // add chests MakeGuardChest(bm, City.EdgeLength + 11, 73, City.EdgeLength + 11); MakeGuardChest(bm, City.MapLength - (City.EdgeLength + 11), 73, City.EdgeLength + 11); MakeGuardChest(bm, City.EdgeLength + 11, 73, City.MapLength - (City.EdgeLength + 11)); MakeGuardChest(bm, City.MapLength - (City.EdgeLength + 11), 73, City.MapLength - (City.EdgeLength + 11)); // add archery slots BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 74, 77, City.EdgeLength + 8, City.EdgeLength + 8, BlockInfo.Air.ID, 2); BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 76, 76, City.EdgeLength + 7, City.EdgeLength + 9, BlockInfo.Air.ID, 2); if (!City.HasWalls) { BlockHelper.MakeLadder(City.EdgeLength + 13, 64, 72, City.EdgeLength + 8, 2, City.WallMaterialID); } // include beds BlockHelper.MakeBed(City.EdgeLength + 5, City.EdgeLength + 6, 64, City.EdgeLength + 8, City.EdgeLength + 8, 2); BlockHelper.MakeBed(City.EdgeLength + 5, City.EdgeLength + 6, 64, City.EdgeLength + 10, City.EdgeLength + 10, 2); BlockHelper.MakeBed(City.EdgeLength + 11, City.EdgeLength + 10, 64, City.EdgeLength + 8, City.EdgeLength + 8, 2); // make columns to orientate torches BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 5, 64, 73, City.EdgeLength + 5, City.EdgeLength + 5, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 5, City.EdgeLength + 5, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 5, 64, 71, City.EdgeLength + 11, City.EdgeLength + 11, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 11, City.EdgeLength + 11, BlockInfo.Wood.ID, 2); // add ladders BlockHelper.MakeLadder(City.EdgeLength + 5, 64, 73, City.EdgeLength + 6, 2, BlockInfo.Wood.ID); // make torches if (City.HasTorchesOnWalkways) { BlockHelper.MakeTorch(City.EdgeLength + 10, 66, City.EdgeLength + 5, BlockInfo.Wood.ID, 2); BlockHelper.MakeTorch(City.EdgeLength + 6, 66, City.EdgeLength + 11, BlockInfo.Wood.ID, 2); BlockHelper.MakeTorch(City.EdgeLength + 10, 66, City.EdgeLength + 11, BlockInfo.Wood.ID, 2); } // make columns for real BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 5, City.EdgeLength + 5, 64, 73, City.EdgeLength + 5, City.EdgeLength + 5, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 5, City.EdgeLength + 5, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 5, City.EdgeLength + 5, 64, 71, City.EdgeLength + 11, City.EdgeLength + 11, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 11, City.EdgeLength + 11, City.WallMaterialID, 2, City.WallMaterialData); // make cobwebs BlockShapes.MakeBlock(City.EdgeLength + 11, 67, City.EdgeLength + 8, BlockInfo.Cobweb.ID, 2, 75, -1); // make doors from the city to the guard tower BlockShapes.MakeBlock(City.EdgeLength + 11, 65, City.EdgeLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1); BlockHelper.MakeDoor(City.EdgeLength + 11, 64, City.EdgeLength + 12, BlockInfo.GoldBlock.ID, true, 2); BlockShapes.MakeBlock(City.EdgeLength + 11, 65, City.EdgeLength + 11, BlockInfo.Air.ID, 1, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.Air.ID, 1, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.StonePlate.ID, 1, 100, -1); BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 13, BlockInfo.StonePlate.ID, 2, 100, -1); //BlockShapes.MakeBlock(City.intFarmSize + 13, 64, City.intFarmSize + 11, BlockInfo.Stone.ID_PLATE, 1, 100, -1); // add guard tower sign BlockHelper.MakeSign(City.EdgeLength + 12, 65, City.EdgeLength + 13, "~Guard Tower~~", City.WallMaterialID, 1); BlockHelper.MakeSign(City.EdgeLength + 8, 74, City.EdgeLength + 13, "~Guard Tower~~", City.WallMaterialID, 2); // make beacon frmLogForm.UpdateLog("Creating tower addition: " + City.TowersAdditionType, true, true); switch (City.TowersAdditionType) { case "Fire beacon": BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 8, City.EdgeLength + 8, 83, 84, City.EdgeLength + 8, City.EdgeLength + 8, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 6, City.EdgeLength + 10, 85, 85, City.EdgeLength + 6, City.EdgeLength + 10, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBox(City.EdgeLength + 6, City.EdgeLength + 10, 86, 86, City.EdgeLength + 6, City.EdgeLength + 10, BlockInfo.Netherrack.ID, 1); BlockShapes.MakeSolidBox(City.EdgeLength + 6, City.EdgeLength + 10, 87, 87, City.EdgeLength + 6, City.EdgeLength + 10, BlockInfo.Fire.ID, 1); break; case "Flag": BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 83, 91, City.EdgeLength + 12, City.EdgeLength + 12, BlockInfo.Fence.ID, 2); BlockShapes.MakeBlock(City.EdgeLength + 4, 84, City.EdgeLength + 13, BlockInfo.Fence.ID, 2, 100, 0); BlockShapes.MakeBlock(City.EdgeLength + 4, 91, City.EdgeLength + 13, BlockInfo.Fence.ID, 2, 100, 0); int[] intColours = RNG.ShuffleArray(Enumerable.Range(0, 15).ToArray()); // select a random flag file and turn it into an array string[] strFlagLines = File.ReadAllLines(RNG.RandomItemFromArray(Directory.GetFiles("Resources", "Flag_*.txt"))); for (int x = 0; x < strFlagLines[0].Length; x++) { for (int y = 0; y < strFlagLines.GetLength(0); y++) { int WoolColourID = Convert.ToInt32(strFlagLines[y].Substring(x, 1)); BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 4, City.EdgeLength + 4, 90 - y, 90 - y, City.EdgeLength + 13 + x, City.EdgeLength + 13 + x, BlockInfo.Wool.ID, 2, intColours[WoolColourID]); } } break; } }
public void Generate(frmMace frmLogForm, bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeNoticeboard, bool booIncludeBuildings, bool booIncludePaths, string strCitySize, string strMoatType, string strCityEmblem, string strOutsideLights, string strFireBeacons) { #region create minecraft world directory from a random unused city name string strFolder = "", strCityName = ""; do { strCityName = "City of " + RandomHelper.RandomFileLine("Resources\\CityStartingWords.txt") + RandomHelper.RandomFileLine("Resources\\CityEndingWords.txt"); strFolder = Environment.GetEnvironmentVariable("APPDATA") + @"\.minecraft\saves\" + strCityName + @"\"; } while (Directory.Exists(strFolder)); Directory.CreateDirectory(strFolder); #endregion #region get handles to world, chunk manager and block manager BetaWorld worldDest = BetaWorld.Create(@strFolder); ChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion Random rand = new Random(); #region determine block sizes // first we set the city size by chunks int intCitySize = 12; switch (strCitySize) { case "Random": intCitySize = rand.Next(8, 16); break; case "Very small": intCitySize = 5; break; case "Small": intCitySize = 8; break; case "Medium": intCitySize = 12; break; case "Large": intCitySize = 16; break; case "Very large": intCitySize = 25; break; } // then we multiply by 16, because that's the x and z of a chunk intCitySize *= 16; int intFarmSize = booIncludeFarms ? 32 : 16; int intMapSize = intCitySize + (intFarmSize * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest, intMapSize); BlockHelper.SetupClass(bmDest, intMapSize); SourceWorld.SetupClass(); #endregion if (strOutsideLights == "Random") { strOutsideLights = RandomHelper.RandomString("Fire", "Torches"); } #region make the city frmLogForm.UpdateLog("Creating chunks"); Chunks.MakeChunks(cmDest, 0, intMapSize / 16, frmLogForm); frmLogForm.UpdateProgress(35); // todo: test excluding paths/buildings if (booIncludeBuildings || booIncludePaths) { frmLogForm.UpdateLog("Creating paths"); int[,] intArea = Paths.MakePaths(worldDest, bmDest, intFarmSize, intMapSize); frmLogForm.UpdateProgress(38); if (booIncludeBuildings) { frmLogForm.UpdateLog("Creating buildings"); Buildings.MakeInsideCity(bmDest, worldDest, intArea, intFarmSize, intMapSize, booIncludePaths); } } frmLogForm.UpdateProgress(50); if (booIncludeWalls) { frmLogForm.UpdateLog("Creating walls"); Walls.MakeWalls(worldDest, intFarmSize, intMapSize, strCityEmblem, strOutsideLights); } frmLogForm.UpdateProgress(51); if (booIncludeMoat) { frmLogForm.UpdateLog("Creating moat"); Moat.MakeMoat(intFarmSize, intMapSize, strMoatType, booIncludeGuardTowers); } frmLogForm.UpdateProgress(52); if (booIncludeDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges"); Drawbridge.MakeDrawbridges(bmDest, intFarmSize, intMapSize, booIncludeMoat, booIncludeWalls); } frmLogForm.UpdateProgress(53); if (booIncludeGuardTowers) { frmLogForm.UpdateLog("Creating guard towers"); GuardTowers.MakeGuardTowers(bmDest, intFarmSize, intMapSize, booIncludeWalls, strOutsideLights, strFireBeacons); } frmLogForm.UpdateProgress(54); if (booIncludeWalls && booIncludeNoticeboard) { frmLogForm.UpdateLog("Creating noticeboard"); NoticeBoard.MakeNoticeBoard(bmDest, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(55); if (booIncludeFarms) { frmLogForm.UpdateLog("Creating farms"); Farms.MakeFarms(worldDest, bmDest, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(58); #endregion #region world settings // spawn in a guard tower //world.Level.SpawnX = intFarmSize + 5; //world.Level.SpawnZ = intFarmSize + 5; //world.Level.SpawnY = 74; // spawn looking at one of the city entrances worldDest.Level.SpawnX = intMapSize / 2; worldDest.Level.SpawnZ = intMapSize - (intFarmSize - 10); worldDest.Level.SpawnY = 64; // spawn default //world.Level.SpawnX = 0; //world.Level.SpawnY = 65; //world.Level.SpawnZ = 0; worldDest.Level.LevelName = strCityName; worldDest.Level.Time = rand.Next(24000); if (rand.NextDouble() < 0.15) { worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = rand.Next(6000, 18000); if (rand.NextDouble() < 0.25) { worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endregion #if DEBUG MakeHelperChest(bmDest, worldDest.Level.SpawnX + 2, worldDest.Level.SpawnY, worldDest.Level.SpawnZ + 2); #endif frmLogForm.UpdateLog("Resetting lighting"); Chunks.ResetLighting(worldDest, cmDest, frmLogForm, (int)Math.Pow(intMapSize / 16, 2)); worldDest.Save(); frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!"); frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list."); }
public static void MakeMoat(frmMace frmLogForm, BlockManager bm) { frmLogForm.UpdateLog("Moat type: " + City.MoatType, true, true); switch (City.MoatType) { case "Drop to Bedrock": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 2, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } BlockShapes.MakeHollowLayers(City.EdgeLength - 2, City.MapLength - (City.EdgeLength - 2), 64, 64, City.EdgeLength - 2, City.MapLength - (City.EdgeLength - 2), BlockInfo.Fence.ID, 0, -1); break; case "Cactus": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 63, 63, a, City.MapLength - a, BlockInfo.Sand.ID, 0, -1); } for (int a = City.EdgeLength + 1; a <= City.MapLength / 2; a += 2) { if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1); } } for (int a = City.EdgeLength; a <= City.MapLength / 2; a += 2) { if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.EdgeLength, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 64, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1); } } if (City.HasGuardTowers) { for (int a = City.EdgeLength + 3; a <= City.EdgeLength + 13; a += 2) { BlockShapes.MakeBlock(a, 64, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 65, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1); } } break; case "Cactus Low": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 58, a, City.MapLength - a, BlockInfo.Sand.ID, 0, -1); } for (int a = City.EdgeLength + 1; a <= City.MapLength / 2; a += 2) { if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1); } } for (int a = City.EdgeLength; a <= City.MapLength / 2; a += 2) { if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.EdgeLength, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1); } if (RNG.NextDouble() > 0.5) { BlockShapes.MakeBlock(a, 59, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1); } } if (City.HasGuardTowers) { for (int a = City.EdgeLength + 3; a <= City.EdgeLength + 13; a += 2) { BlockShapes.MakeBlock(a, 59, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 60, City.EdgeLength + 3, BlockInfo.Air.ID, 2, 100, -1); } } break; case "Lava": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 55, 56, a, City.MapLength - a, BlockInfo.Lava.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } break; case "Fire": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 56, 56, a, City.MapLength - a, BlockInfo.Netherrack.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 57, 57, a, City.MapLength - a, BlockInfo.Fire.ID, 0, -1); BlockShapes.MakeHollowLayers(a, City.MapLength - a, 58, 63, a, City.MapLength - a, BlockInfo.Air.ID, 0, -1); } break; case "Water": for (int a = City.EdgeLength - 1; a <= City.EdgeLength + 5; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 59, 63, a, City.MapLength - a, BlockInfo.Water.ID, 0, -1); } break; default: Debug.Fail("Invalid switch result"); break; } // drawbridge int intBridgeEnd = City.HasMoat ? -2 : 5; if (City.MoatType == "Lava" || City.MoatType == "Fire") { BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63, City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.StoneBrick.ID, 2); } else { BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63, City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.WoodPlank.ID, 2); } BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 65, City.EdgeLength + intBridgeEnd, City.EdgeLength + 13, BlockInfo.Air.ID, 2); }
public static void Generate(frmMace frmLogForm, BetaWorld worldDest, BetaChunkManager cmDest, BlockManager bmDest, int x, int z) { #region create a city name string strStart, strEnd; do { strStart = RandomHelper.RandomFileLine(Path.Combine("Resources", City.CityNamePrefixFilename)); strEnd = RandomHelper.RandomFileLine(Path.Combine("Resources", City.CityNameSuffixFilename)); City.Name = "City of " + strStart + strEnd; } while (GenerateWorld.lstCityNames.Contains(City.Name) || strStart.ToLower().Trim() == strEnd.ToLower().Trim() || (strStart + strEnd).Length > 14); GenerateWorld.lstCityNames.Add(City.Name); #endregion #region determine block sizes City.CityLength *= 16; // chunk length City.FarmLength = City.HasFarms ? 32 : 8; City.MapLength = City.CityLength + (City.FarmLength * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest); BlockHelper.SetupClass(bmDest); NoticeBoard.SetupClass(); if (!SourceWorld.SetupClass(worldDest)) { return; } #endregion #region determine random options #pragma warning disable switch (City.WallMaterialID) { case BlockType.WOOD_PLANK: case BlockType.WOOD: case BlockType.LEAVES: case BlockType.VINES: case BlockType.WOOL: case BlockType.BOOKSHELF: switch (City.OutsideLightType) { case "Fire": frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true); City.OutsideLightType = "Torches"; break; } switch (City.MoatType) { case "Fire": case "Lava": frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true); City.MoatType = "Water"; break; } break; } #pragma warning restore #endregion #region make the city frmLogForm.UpdateLog("Creating the " + City.Name, false, false); frmLogForm.UpdateLog("City length in blocks: " + City.MapLength, true, true); frmLogForm.UpdateLog("City position in blocks: " + ((x + 30) * 16) + "," + ((z + 30) * 16), true, true); frmLogForm.UpdateLog("Theme: " + City.ThemeName, true, true); frmLogForm.UpdateLog("Creating underground terrain", true, false); Chunks.CreateInitialChunks(cmDest, frmLogForm); frmLogForm.UpdateProgress(0.35); Buildings.structPoint spMineshaftEntrance = new Buildings.structPoint(); if (City.HasWalls) { frmLogForm.UpdateLog("Creating walls", true, false); Walls.MakeWalls(worldDest, frmLogForm); } frmLogForm.UpdateProgress(0.45); if (City.HasBuildings || City.HasPaths) { frmLogForm.UpdateLog("Creating paths", true, false); int[,] intArea = Paths.MakePaths(worldDest, bmDest); frmLogForm.UpdateProgress(0.50); if (City.HasBuildings) { frmLogForm.UpdateLog("Creating buildings", true, false); spMineshaftEntrance = Buildings.MakeInsideCity(bmDest, worldDest, intArea, frmLogForm); frmLogForm.UpdateProgress(0.55); if (City.HasMineshaft) { frmLogForm.UpdateLog("Creating mineshaft", true, false); Mineshaft.MakeMineshaft(worldDest, bmDest, spMineshaftEntrance, frmLogForm); } } } frmLogForm.UpdateProgress(0.60); if (City.HasMoat) { frmLogForm.UpdateLog("Creating moat", true, false); Moat.MakeMoat(frmLogForm); } frmLogForm.UpdateProgress(0.65); if (City.HasDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges", true, false); Drawbridge.MakeDrawbridges(bmDest); } frmLogForm.UpdateProgress(0.70); if (City.HasGuardTowers) { frmLogForm.UpdateLog("Creating guard towers", true, false); GuardTowers.MakeGuardTowers(bmDest, frmLogForm); } frmLogForm.UpdateProgress(0.75); if (City.HasFarms) { frmLogForm.UpdateLog("Creating farms", true, false); Farms.MakeFarms(worldDest, bmDest, frmLogForm); } frmLogForm.UpdateProgress(0.80); if (!City.HasValuableBlocks) { frmLogForm.UpdateLog("Replacing valuable blocks", true, true); cmDest.Save(); worldDest.Save(); Chunks.ReplaceValuableBlocks(worldDest, bmDest); } frmLogForm.UpdateProgress(0.90); frmLogForm.UpdateLog("Creating rail data", true, false); Chunks.PositionRails(worldDest, bmDest); frmLogForm.UpdateProgress(0.95); frmLogForm.UpdateLog("Creating position data", true, false); Chunks.MoveChunks(worldDest, cmDest, x, z); frmLogForm.UpdateProgress(1); #endregion }
public static void MakeWalls(BetaWorld world, frmMace frmLogForm) { // walls for (int a = City.EdgeLength + 6; a <= City.EdgeLength + 10; a++) { BlockShapes.MakeHollowLayers(a, City.MapLength - a, 1, 72, a, City.MapLength - a, City.WallMaterialID, 0, City.WallMaterialData); world.Save(); } // outside and inside edges at the top BlockShapes.MakeHollowLayers(City.EdgeLength + 5, City.MapLength - (City.EdgeLength + 5), 72, 73, City.EdgeLength + 5, City.MapLength - (City.EdgeLength + 5), City.WallMaterialID, 0, City.WallMaterialData); BlockShapes.MakeHollowLayers(City.EdgeLength + 11, City.MapLength - (City.EdgeLength + 11), 72, 73, City.EdgeLength + 11, City.MapLength - (City.EdgeLength + 11), City.WallMaterialID, 0, City.WallMaterialData); // alternating blocks on top of the edges for (int a = City.EdgeLength + 6; a <= City.MapLength - (City.EdgeLength + 6); a += 2) { BlockShapes.MakeBlock(a, 74, City.EdgeLength + 5, City.WallMaterialID, 2, 100, City.WallMaterialData); } for (int a = City.EdgeLength + 12; a <= City.MapLength - (City.EdgeLength + 12); a += 2) { BlockShapes.MakeBlock(a, 74, City.EdgeLength + 11, City.WallMaterialID, 2, 100, City.WallMaterialData); } // ladder BlockHelper.MakeLadder((City.MapLength / 2) - 5, 64, 72, City.EdgeLength + 11, 2, City.WallMaterialID); BlockShapes.MakeBlock((City.MapLength / 2) - 5, 73, City.EdgeLength + 11, BlockInfo.Air.ID, 2, 100, -1); // decorations at the gates frmLogForm.UpdateLog("Creating wall lights: " + City.OutsideLightType, true, true); switch (City.OutsideLightType) { case "Fire": // fire above the entrances BlockShapes.MakeBlock((City.MapLength / 2) - 1, 69, City.EdgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2), 69, City.EdgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2) - 1, 70, City.EdgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2), 70, City.EdgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); // fire on the outside walls for (int a = City.EdgeLength + 8; a < (City.MapLength / 2) - 9; a += 4) { BlockShapes.MakeBlock(a, 69, City.EdgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 70, City.EdgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); } break; case "Torches": // torches above the entrances BlockHelper.MakeTorch((City.MapLength / 2), 70, City.EdgeLength + 5, City.WallMaterialID, 2); BlockHelper.MakeTorch((City.MapLength / 2) - 1, 70, City.EdgeLength + 5, City.WallMaterialID, 2); // torches on the outside walls for (int a = City.EdgeLength + 8; a < (City.MapLength / 2) - 9; a += 4) { BlockHelper.MakeTorch(a, 70, City.EdgeLength + 5, City.WallMaterialID, 2); } break; case "None": case "": break; default: Debug.Fail("Invalid switch result"); break; } if (City.HasTorchesOnWalkways) { // torches on the inside walls for (int a = City.EdgeLength + 16; a < (City.MapLength / 2); a += 4) { BlockHelper.MakeTorch(a, 69, City.EdgeLength + 11, City.WallMaterialID, 2); } // torches on the wall roofs for (int a = City.EdgeLength + 16; a < (City.MapLength / 2); a += 4) { BlockShapes.MakeBlock(a, 73, City.EdgeLength + 8, BlockInfo.Torch.ID, 2, 100, -1); } } frmLogForm.UpdateLog("Creating wall emblems: " + City.CityEmblemType, true, true); MakeEmblem(); }
public static void MakeFarms(BetaWorld world, BlockManager bm, frmMace frmLogForm) { if (City.HasFarms) { frmLogForm.UpdateLog("Creating farm buildings", true, true); AddBuildings(bm); frmLogForm.UpdateLog("Creating farms and outside features", true, true); int intFail = 0; int intFarms = 0; while (intFail <= 500) { int xlen = RandomHelper.Next(8, 26); int x1 = RandomHelper.Next(5, City.MapLength - (5 + xlen)); int zlen = RandomHelper.Next(8, 26); int z1 = RandomHelper.Next(5, City.MapLength - (5 + zlen)); if (!(x1 >= City.FarmLength && z1 >= City.FarmLength && x1 <= City.MapLength - City.FarmLength && z1 <= City.MapLength - City.FarmLength)) { bool booValid = true; for (int x = x1 - 2; x <= x1 + xlen + 2 && booValid; x++) { for (int z = z1 - 2; z <= z1 + zlen + 2 && booValid; z++) { // make sure it doesn't overlap with the spawn point or another farm if ((x == City.MapLength / 2 && z == SpawnZ) || bm.GetID(x, 63, z) != City.GroundBlockID || bm.GetID(x, 64, z) != BlockInfo.Air.ID) { booValid = false; intFail++; } } } if (booValid) { // first there is a 25% chance of a hill or pond // if not, for large farms, there is a 50% chance it'll be an orchard // if not, 33% are cactus, 33% are wheat and 33% are sugarcane FarmTypes curFarm; int intFarmType = RandomHelper.Next(100); if (xlen >= 10 && zlen >= 10 && intFarmType > 75) { if (RandomHelper.NextDouble() > 0.5) { curFarm = FarmTypes.Pond; MakePond(bm, x1, xlen, z1, zlen, false); } else { curFarm = FarmTypes.Hill; MakeHill(bm, x1, xlen, z1, zlen, false); } } else { intFarmType = RandomHelper.Next(100); if (((xlen >= 11 && zlen >= 16) || (xlen >= 16 && zlen >= 11)) && intFarmType > 50) { curFarm = FarmTypes.Orchard; xlen = ((int)((xlen - 1) / 5) * 5) + 1; zlen = ((int)((zlen - 1) / 5) * 5) + 1; } else { intFarmType = RandomHelper.Next(3); if (intFarmType == 2) { curFarm = FarmTypes.Cactus; } else if (intFarmType == 1) { curFarm = FarmTypes.Wheat; xlen += (xlen % 2) - 1; zlen += (zlen % 2) - 1; } else { curFarm = FarmTypes.SugarCane; xlen += (xlen % 2) - 1; zlen += (zlen % 2) - 1; } } } int intWallMaterial = RandomHelper.NextDouble() > 0.5 ? BlockInfo.Fence.ID : BlockInfo.Leaves.ID; switch (curFarm) { case FarmTypes.Hill: case FarmTypes.Pond: intWallMaterial = 0; break; case FarmTypes.SugarCane: case FarmTypes.Mushroom: if (RandomHelper.NextDouble() > 0.5) { intWallMaterial = 0; } break; case FarmTypes.Wheat: intWallMaterial = BlockInfo.Leaves.ID; break; // no need for default - the other types don't need anything here } #pragma warning disable switch (intWallMaterial) { case BlockType.FENCE: BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 64, z1, z1 + zlen, BlockInfo.Fence.ID, 0, -1); break; case BlockType.LEAVES: // the saplings will all disappear if one of them is broken. // so we put wood beneath them to stop that happening BlockShapes.MakeHollowLayers(x1, x1 + xlen, 63, 63, z1, z1 + zlen, BlockInfo.Wood.ID, 0, -1); BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 65, z1, z1 + zlen, BlockInfo.Leaves.ID, 0, RandomHelper.RandomNumber((int)LeafType.OAK, (int)LeafType.SPRUCE, (int)LeafType.BIRCH)); break; case 0: // no wall break; default: Debug.Fail("Invalid switch result"); break; } #pragma warning restore switch (curFarm) { case FarmTypes.Orchard: int intSaplingType = RandomHelper.RandomNumber(SaplingBirchDataID, SaplingOakDataID, SaplingSpruceDataID); for (int x = x1 + 3; x <= x1 + xlen - 3; x += 5) { for (int z = z1 + 3; z <= z1 + zlen - 3; z += 5) { BlockShapes.MakeBlock(x, 63, z, City.GroundBlockID, City.GroundBlockData); BlockShapes.MakeBlock(x, 64, z, BlockInfo.Sapling.ID, intSaplingType); } } break; case FarmTypes.Cactus: int intAttempts = 0; do { int xCactus = RandomHelper.Next(x1 + 1, x1 + xlen); int zCactus = RandomHelper.Next(z1 + 1, z1 + zlen); bool booValidFarm = true; for (int xCheck = xCactus - 1; xCheck <= xCactus + 1 && booValidFarm; xCheck++) { for (int zCheck = zCactus - 1; zCheck <= zCactus + 1 && booValidFarm; zCheck++) { if (bm.GetID(xCheck, 64, zCheck) != BlockInfo.Air.ID) { booValidFarm = false; } } } if (booValidFarm) { bm.SetID(xCactus, 64, zCactus, BlockInfo.Cactus.ID); if (RandomHelper.NextDouble() > 0.5) { bm.SetID(xCactus, 65, zCactus, BlockInfo.Cactus.ID); } } }while (++intAttempts < 100); break; case FarmTypes.Wheat: BlockShapes.MakeHollowLayers(x1, x1 + xlen, 66, 66, z1, z1 + zlen, BlockInfo.Glass.ID, 0, -1); BlockShapes.MakeSolidBox(x1 + 1, x1 + xlen - 1, 67, 67, z1 + 1, z1 + zlen - 1, BlockInfo.Glass.ID, 0); break; // no need for a default, because there's nothing to do for the other farms } for (int x = x1 + 1; x <= x1 + xlen - 1; x++) { for (int z = z1 + 1; z <= z1 + zlen - 1; z++) { switch (curFarm) { case FarmTypes.Cactus: bm.SetID(x, 63, z, BlockInfo.Sand.ID); break; case FarmTypes.Wheat: if (z == z1 + 1) { bm.SetID(x, 63, z, BlockInfo.DoubleSlab.ID); } else if (x % 2 == 0) { BlockShapes.MakeBlock(x, 63, z, BlockInfo.Farmland.ID, 1); bm.SetID(x, 64, z, BlockInfo.Crops.ID); } else { bm.SetID(x, 63, z, BlockInfo.StationaryWater.ID); } break; case FarmTypes.SugarCane: if (z != z1 + 1) { if (x % 2 == 0) { bm.SetID(x, 64, z, BlockInfo.SugarCane.ID); if (RandomHelper.Next(100) > 50) { bm.SetID(x, 65, z, BlockInfo.SugarCane.ID); } } else { bm.SetID(x, 63, z, BlockInfo.StationaryWater.ID); } } break; // no need for a default, because there's nothing to do for the other farms } } } int intDoorPosition = x1 + RandomHelper.Next(1, xlen - 1); if (curFarm == FarmTypes.Wheat) { bm.SetID(intDoorPosition, 63, z1, BlockInfo.DoubleSlab.ID); } if (intWallMaterial != 0) { if (curFarm == FarmTypes.Wheat || intWallMaterial == BlockInfo.Leaves.ID) { BlockShapes.MakeBlock(intDoorPosition, 64, z1, BlockInfo.WoodDoor.ID, 4); BlockShapes.MakeBlock(intDoorPosition, 65, z1, BlockInfo.WoodDoor.ID, 4 + (int)DoorState.TOPHALF); } else { bm.SetID(intDoorPosition, 64, z1, BlockInfo.FenceGate.ID); bm.SetData(intDoorPosition, 64, z1, 0); } } intFail = 0; if (++intFarms > 10) { world.Save(); intFarms = 0; } } } } MakeMiniPondsAndHills(world, bm); } if (City.HasFlowers) { MakeFlowers(world, bm); } }
public static void Generate(frmMace frmLogForm, BetaWorld worldDest, BetaChunkManager cmDest, BlockManager bmDest, int x, int z, bool booExportSchematics, string strUndergroundOres) { #region create a city name string strStart, strEnd; do { strStart = RNG.RandomFileLine(Path.Combine("Resources", City.CityNamePrefixFilename)); strEnd = RNG.RandomFileLine(Path.Combine("Resources", City.CityNameSuffixFilename)); City.Name = City.CityNamePrefix + strStart + strEnd; } while (GenerateWorld.lstCityNames.Contains(City.Name) || strStart.ToLower().Trim() == strEnd.ToLower().Trim() || (strStart + strEnd).Length > 14); GenerateWorld.lstCityNames.Add(City.Name); #endregion #region determine block sizes City.CityLength *= 16; City.FarmLength *= 16; City.EdgeLength = 8; City.MapLength = City.CityLength + (City.EdgeLength * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest); BlockHelper.SetupClass(bmDest); NoticeBoard.SetupClass(); if (!SourceWorld.SetupClass(worldDest)) { return; } #endregion #region determine random options switch (City.WallMaterialID) { case BlockType.WOOD_PLANK: case BlockType.WOOD: case BlockType.LEAVES: case BlockType.VINES: case BlockType.WOOL: case BlockType.BOOKSHELF: switch (City.OutsideLightType) { case "Fire": frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true); City.OutsideLightType = "Torches"; break; } switch (City.MoatType) { case "Fire": case "Lava": frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true); City.MoatType = "Water"; break; } break; } switch (City.PathType.ToLower().Trim()) { case "stone_raised": City.PathBlockID = BlockInfo.DoubleSlab.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 0; City.PathExtends = 2; break; case "sandstone_raised": City.PathBlockID = BlockInfo.Sandstone.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 1; City.PathExtends = 2; break; case "woodplanks_raised": City.PathBlockID = BlockInfo.WoodPlank.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 2; City.PathExtends = 2; break; case "cobblestone_raised": City.PathBlockID = BlockInfo.Cobblestone.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 3; City.PathExtends = 2; break; case "brick_raised": City.PathBlockID = BlockInfo.BrickBlock.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 4; City.PathExtends = 2; break; case "stonebrick_raised": City.PathBlockID = BlockInfo.StoneBrick.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = BlockInfo.Slab.ID; City.PathAlternativeBlockData = 5; City.PathExtends = 2; break; case "stonebrick": City.PathBlockID = BlockInfo.StoneBrick.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = 0; City.PathAlternativeBlockData = 0; City.PathExtends = 1; break; case "sandstone": City.PathBlockID = BlockInfo.Sandstone.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = 0; City.PathAlternativeBlockData = 0; City.PathExtends = 1; break; case "stone": City.PathBlockID = BlockInfo.Stone.ID; City.PathBlockData = 0; City.PathAlternativeBlockID = 0; City.PathAlternativeBlockData = 0; City.PathExtends = 1; break; case "wood": City.PathBlockID = BlockInfo.Wood.ID; City.PathBlockData = RNG.Next(0, 2); City.PathAlternativeBlockID = 0; City.PathAlternativeBlockData = 0; City.PathExtends = 1; break; } #endregion #region make the city frmLogForm.UpdateLog("Creating the " + City.Name, false, false); frmLogForm.UpdateLog("City length in blocks: " + City.MapLength, true, true); frmLogForm.UpdateLog("Edge length in blocks: " + City.EdgeLength, true, true); frmLogForm.UpdateLog("Farm length in blocks: " + City.FarmLength, true, true); frmLogForm.UpdateLog("City position in blocks: " + ((x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + "," + ((z + Chunks.CITY_RELOCATION_CHUNKS) * 16), true, true); frmLogForm.UpdateLog("Theme: " + City.ThemeName, true, true); frmLogForm.UpdateLog("Creating underground terrain", true, false); Chunks.CreateInitialChunks(cmDest, frmLogForm, strUndergroundOres); frmLogForm.UpdateProgress(0.21); Buildings.structPoint spMineshaftEntrance = new Buildings.structPoint(); if (City.HasWalls) { frmLogForm.UpdateLog("Creating walls", true, false); Walls.MakeWalls(worldDest, frmLogForm); } frmLogForm.UpdateProgress(0.24); if (City.HasDrawbridges) { frmLogForm.UpdateLog("Creating entrances", true, false); Entrances.MakeEntrances(bmDest); } frmLogForm.UpdateProgress(0.27); if (City.HasMoat) { frmLogForm.UpdateLog("Creating moat", true, false); Moat.MakeMoat(frmLogForm, bmDest); } frmLogForm.UpdateProgress(0.30); if (City.HasBuildings || City.HasPaths) { frmLogForm.UpdateLog("Creating paths", true, false); frmLogForm.UpdateLog("Path type: " + City.PathType, true, true); int[,] intArea = Paths.MakePaths(worldDest, bmDest); frmLogForm.UpdateProgress(0.33); if (City.HasBuildings) { frmLogForm.UpdateLog("Creating buildings", true, false); spMineshaftEntrance = Buildings.MakeInsideCity(bmDest, worldDest, intArea, frmLogForm); frmLogForm.UpdateProgress(0.36); if (City.HasMineshaft) { frmLogForm.UpdateLog("Creating mineshaft", true, false); Mineshaft.MakeMineshaft(worldDest, bmDest, spMineshaftEntrance, frmLogForm); } } } frmLogForm.UpdateProgress(0.39); if (City.HasGuardTowers) { frmLogForm.UpdateLog("Creating guard towers", true, false); GuardTowers.MakeGuardTowers(bmDest, frmLogForm); } frmLogForm.UpdateProgress(0.42); if (City.HasFarms) { frmLogForm.UpdateLog("Creating farms", true, false); Farms2.MakeFarms(worldDest, bmDest); } frmLogForm.UpdateProgress(0.45); if (City.HasFlowers) { frmLogForm.UpdateLog("Creating flowers", true, false); Flowers.MakeFlowers(worldDest, bmDest); } frmLogForm.UpdateProgress(0.46); if (!City.HasValuableBlocks) { frmLogForm.UpdateLog("Replacing valuable blocks", true, true); cmDest.Save(); worldDest.Save(); Chunks.ReplaceValuableBlocks(worldDest, bmDest); } frmLogForm.UpdateProgress(0.48); frmLogForm.UpdateLog("Creating rail data", true, false); Chunks.PositionRails(worldDest, bmDest); frmLogForm.UpdateProgress(0.50); frmLogForm.UpdateLog("Creating lighting data", true, false); Chunks.ResetLighting(worldDest, cmDest, frmLogForm); frmLogForm.UpdateProgress(0.95); #endregion #region export schematic if (booExportSchematics) { frmLogForm.UpdateLog("Creating schematic in world folder", true, false); AlphaBlockCollection abcExport = new AlphaBlockCollection(City.MapLength, 128, City.MapLength + City.FarmLength); for (int xBlock = 0; xBlock < City.MapLength; xBlock++) { for (int zBlock = -City.FarmLength; zBlock < City.MapLength; zBlock++) { for (int y = 0; y < 128; y++) { abcExport.SetBlock(xBlock, y, City.FarmLength + zBlock, bmDest.GetBlock(xBlock, y, zBlock)); } } } Schematic CitySchematic = new Schematic(City.MapLength, 128, City.MapLength + City.FarmLength); CitySchematic.Blocks = abcExport; CitySchematic.Export(worldDest.Path + "\\" + City.Name + ".schematic"); } #endregion #region positioning frmLogForm.UpdateLog("Creating position data", true, false); Chunks.MoveChunks(worldDest, cmDest, x, z); frmLogForm.UpdateProgress(1); #endregion }
public static void MakeGuardTowers(BlockManager bm, frmMace frmLogForm) { // remove wall BlockShapes.MakeSolidBox(City.FarmLength + 5, City.FarmLength + 11, 64, 79, City.FarmLength + 5, City.FarmLength + 11, BlockInfo.Air.ID, 1); // add tower BlockShapes.MakeHollowBox(City.FarmLength + 4, City.FarmLength + 12, 63, 80, City.FarmLength + 4, City.FarmLength + 12, City.WallMaterialID, 1, City.WallMaterialData); // divide into two rooms BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 12, 2, 72, City.FarmLength + 4, City.FarmLength + 12, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBox(City.FarmLength + 5, City.FarmLength + 11, 64, 67, City.FarmLength + 5, City.FarmLength + 11, BlockInfo.Air.ID, 1); switch (City.OutsideLightType) { case "Fire": BlockShapes.MakeBlock(City.FarmLength + 5, 76, City.FarmLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 5, 77, City.FarmLength + 3, BlockInfo.Fire.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 76, City.FarmLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 77, City.FarmLength + 3, BlockInfo.Fire.ID, 2, 100, -1); break; case "Torches": for (int y = 73; y <= 80; y += 7) { BlockHelper.MakeTorch(City.FarmLength + 6, y, City.FarmLength + 3, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.FarmLength + 10, y, City.FarmLength + 3, City.WallMaterialID, 2); } break; case "None": break; default: Debug.Fail("Invalid switch result"); break; } // add torches BlockHelper.MakeTorch(City.FarmLength + 6, 79, City.FarmLength + 13, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.FarmLength + 10, 79, City.FarmLength + 13, City.WallMaterialID, 2); // add torches inside BlockHelper.MakeTorch(City.FarmLength + 6, 77, City.FarmLength + 11, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.FarmLength + 10, 77, City.FarmLength + 11, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.FarmLength + 5, 77, City.FarmLength + 6, City.WallMaterialID, 2); BlockHelper.MakeTorch(City.FarmLength + 5, 77, City.FarmLength + 10, City.WallMaterialID, 2); // add openings to the walls BlockShapes.MakeBlock(City.FarmLength + 7, 73, City.FarmLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 9, 73, City.FarmLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 7, 74, City.FarmLength + 12, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 9, 74, City.FarmLength + 12, BlockInfo.Air.ID, 2, 100, -1); // add blocks on top of the towers BlockShapes.MakeHollowLayers(City.FarmLength + 4, City.FarmLength + 12, 81, 81, City.FarmLength + 4, City.FarmLength + 12, City.WallMaterialID, 1, City.WallMaterialData); // alternating top blocks for (int x = City.FarmLength + 4; x <= City.FarmLength + 12; x += 2) { for (int z = City.FarmLength + 4; z <= City.FarmLength + 12; z += 2) { if (x == City.FarmLength + 4 || x == City.FarmLength + 12 || z == City.FarmLength + 4 || z == City.FarmLength + 12) { BlockShapes.MakeBlock(x, 82, z, City.WallMaterialID, 1, 100, City.WallMaterialData); } } } // add central columns BlockShapes.MakeSolidBoxWithData(City.FarmLength + 8, City.FarmLength + 8, 73, 82, City.FarmLength + 8, City.FarmLength + 8, City.WallMaterialID, 1, City.WallMaterialData); BlockHelper.MakeLadder(City.FarmLength + 7, 73, 82, City.FarmLength + 8, 2, City.WallMaterialID); BlockHelper.MakeLadder(City.FarmLength + 9, 73, 82, City.FarmLength + 8, 2, City.WallMaterialID); // add torches on the roof BlockShapes.MakeBlock(City.FarmLength + 6, 81, City.FarmLength + 6, BlockInfo.Torch.ID, 1, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 6, 81, City.FarmLength + 10, BlockInfo.Torch.ID, 2, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 10, 81, City.FarmLength + 10, BlockInfo.Torch.ID, 1, 100, -1); // add cobwebs BlockShapes.MakeBlock(City.FarmLength + 5, 79, City.FarmLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.FarmLength + 5, 79, City.FarmLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 79, City.FarmLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 79, City.FarmLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1); // add chests MakeGuardChest(bm, City.FarmLength + 11, 73, City.FarmLength + 11); MakeGuardChest(bm, City.MapLength - (City.FarmLength + 11), 73, City.FarmLength + 11); MakeGuardChest(bm, City.FarmLength + 11, 73, City.MapLength - (City.FarmLength + 11)); MakeGuardChest(bm, City.MapLength - (City.FarmLength + 11), 73, City.MapLength - (City.FarmLength + 11)); // add archery slots BlockShapes.MakeSolidBox(City.FarmLength + 4, City.FarmLength + 4, 74, 77, City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2); BlockShapes.MakeSolidBox(City.FarmLength + 4, City.FarmLength + 4, 76, 76, City.FarmLength + 7, City.FarmLength + 9, BlockInfo.Air.ID, 2); if (!City.HasWalls) { BlockHelper.MakeLadder(City.FarmLength + 13, 64, 72, City.FarmLength + 8, 2, City.WallMaterialID); } // include beds BlockHelper.MakeBed(City.FarmLength + 5, City.FarmLength + 6, 64, City.FarmLength + 8, City.FarmLength + 8, 2); BlockHelper.MakeBed(City.FarmLength + 5, City.FarmLength + 6, 64, City.FarmLength + 10, City.FarmLength + 10, 2); BlockHelper.MakeBed(City.FarmLength + 11, City.FarmLength + 10, 64, City.FarmLength + 8, City.FarmLength + 8, 2); // make columns to orientate torches BlockShapes.MakeSolidBox(City.FarmLength + 5, City.FarmLength + 5, 64, 73, City.FarmLength + 5, City.FarmLength + 5, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.FarmLength + 11, City.FarmLength + 11, 64, 71, City.FarmLength + 5, City.FarmLength + 5, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.FarmLength + 5, City.FarmLength + 5, 64, 71, City.FarmLength + 11, City.FarmLength + 11, BlockInfo.Wood.ID, 2); BlockShapes.MakeSolidBox(City.FarmLength + 11, City.FarmLength + 11, 64, 71, City.FarmLength + 11, City.FarmLength + 11, BlockInfo.Wood.ID, 2); // add ladders BlockHelper.MakeLadder(City.FarmLength + 5, 64, 73, City.FarmLength + 6, 2, BlockInfo.Wood.ID); // make torches BlockHelper.MakeTorch(City.FarmLength + 10, 66, City.FarmLength + 5, BlockInfo.Wood.ID, 2); BlockHelper.MakeTorch(City.FarmLength + 6, 66, City.FarmLength + 11, BlockInfo.Wood.ID, 2); BlockHelper.MakeTorch(City.FarmLength + 10, 66, City.FarmLength + 11, BlockInfo.Wood.ID, 2); // make columns for real BlockShapes.MakeSolidBoxWithData(City.FarmLength + 5, City.FarmLength + 5, 64, 73, City.FarmLength + 5, City.FarmLength + 5, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 11, City.FarmLength + 11, 64, 71, City.FarmLength + 5, City.FarmLength + 5, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 5, City.FarmLength + 5, 64, 71, City.FarmLength + 11, City.FarmLength + 11, City.WallMaterialID, 2, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 11, City.FarmLength + 11, 64, 71, City.FarmLength + 11, City.FarmLength + 11, City.WallMaterialID, 2, City.WallMaterialData); // make cobwebs BlockShapes.MakeBlock(City.FarmLength + 11, 67, City.FarmLength + 8, BlockInfo.Cobweb.ID, 2, 75, -1); // make doors from the city to the guard tower BlockShapes.MakeBlock(City.FarmLength + 11, 65, City.FarmLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 64, City.FarmLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1); BlockHelper.MakeDoor(City.FarmLength + 11, 64, City.FarmLength + 12, BlockInfo.GoldBlock.ID, true, 2); BlockShapes.MakeBlock(City.FarmLength + 11, 65, City.FarmLength + 11, BlockInfo.Air.ID, 1, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 64, City.FarmLength + 11, BlockInfo.Air.ID, 1, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 64, City.FarmLength + 11, BlockInfo.StonePlate.ID, 1, 100, -1); BlockShapes.MakeBlock(City.FarmLength + 11, 64, City.FarmLength + 13, BlockInfo.StonePlate.ID, 2, 100, -1); //BlockShapes.MakeBlock(City.intFarmSize + 13, 64, City.intFarmSize + 11, BlockInfo.Stone.ID_PLATE, 1, 100, -1); // add guard tower sign BlockHelper.MakeSign(City.FarmLength + 12, 65, City.FarmLength + 13, "~Guard Tower~~", City.WallMaterialID, 1); BlockHelper.MakeSign(City.FarmLength + 8, 74, City.FarmLength + 13, "~Guard Tower~~", City.WallMaterialID, 2); // make beacon frmLogForm.UpdateLog("Creating tower addition: " + City.TowersAdditionType, true, true); switch (City.TowersAdditionType) { case "Fire beacon": BlockShapes.MakeSolidBoxWithData(City.FarmLength + 8, City.FarmLength + 8, 83, 84, City.FarmLength + 8, City.FarmLength + 8, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 6, City.FarmLength + 10, 85, 85, City.FarmLength + 6, City.FarmLength + 10, City.WallMaterialID, 1, City.WallMaterialData); BlockShapes.MakeSolidBox(City.FarmLength + 6, City.FarmLength + 10, 86, 86, City.FarmLength + 6, City.FarmLength + 10, BlockInfo.Netherrack.ID, 1); BlockShapes.MakeSolidBox(City.FarmLength + 6, City.FarmLength + 10, 87, 87, City.FarmLength + 6, City.FarmLength + 10, BlockInfo.Fire.ID, 1); break; case "Flag": BlockShapes.MakeSolidBox(City.FarmLength + 4, City.FarmLength + 4, 83, 91, City.FarmLength + 12, City.FarmLength + 12, BlockInfo.Fence.ID, 2); BlockShapes.MakeBlock(City.FarmLength + 4, 84, City.FarmLength + 13, BlockInfo.Fence.ID, 2, 100, 0); BlockShapes.MakeBlock(City.FarmLength + 4, 91, City.FarmLength + 13, BlockInfo.Fence.ID, 2, 100, 0); int[] intColours = RandomHelper.ShuffleArray(Enumerable.Range(0, 15).ToArray()); switch (RandomHelper.Next(8)) { case 0: //2vert BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 13, City.FarmLength + 17, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 18, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[1]); break; case 1: //3vert BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 13, City.FarmLength + 15, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 16, City.FarmLength + 18, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 19, City.FarmLength + 21, BlockInfo.Wool.ID, 2, intColours[2]); break; case 2: //4vert BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 13, City.FarmLength + 14, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 15, City.FarmLength + 16, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 17, City.FarmLength + 18, BlockInfo.Wool.ID, 2, intColours[2]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 19, City.FarmLength + 20, BlockInfo.Wool.ID, 2, intColours[3]); break; case 3: //2horiz BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 87, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 88, 90, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[1]); break; case 4: //3horiz BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 86, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 87, 88, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 89, 90, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[2]); break; case 5: //quarters BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 87, City.FarmLength + 13, City.FarmLength + 17, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 87, City.FarmLength + 18, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 88, 90, City.FarmLength + 13, City.FarmLength + 17, BlockInfo.Wool.ID, 2, intColours[2]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 88, 90, City.FarmLength + 18, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[3]); break; case 6: //cross BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 87, 88, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 17, City.FarmLength + 18, BlockInfo.Wool.ID, 2, intColours[1]); break; default: // inside "circle" BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 85, 90, City.FarmLength + 13, City.FarmLength + 22, BlockInfo.Wool.ID, 2, intColours[0]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 86, 89, City.FarmLength + 17, City.FarmLength + 18, BlockInfo.Wool.ID, 2, intColours[1]); BlockShapes.MakeSolidBoxWithData(City.FarmLength + 4, City.FarmLength + 4, 87, 88, City.FarmLength + 16, City.FarmLength + 19, BlockInfo.Wool.ID, 2, intColours[1]); break; } break; } }
public static void MakeWalls(AnvilWorld world, frmMace frmLogForm) { // walls for (int a = City.edgeLength + 6; a <= City.edgeLength + 10; a++) { BlockShapes.MakeHollowLayers(a, City.mapLength - a, 1, 72, a, City.mapLength - a, City.wallMaterialID, 0, City.wallMaterialData); world.Save(); } // outside and inside edges at the top BlockShapes.MakeHollowLayers(City.edgeLength + 5, City.mapLength - (City.edgeLength + 5), 72, 73, City.edgeLength + 5, City.mapLength - (City.edgeLength + 5), City.wallMaterialID, 0, City.wallMaterialData); BlockShapes.MakeHollowLayers(City.edgeLength + 11, City.mapLength - (City.edgeLength + 11), 72, 73, City.edgeLength + 11, City.mapLength - (City.edgeLength + 11), City.wallMaterialID, 0, City.wallMaterialData); // alternating blocks on top of the edges for (int a = City.edgeLength + 6; a <= City.mapLength - (City.edgeLength + 6); a += 2) { BlockShapes.MakeBlock(a, 74, City.edgeLength + 5, City.wallMaterialID, 2, 100, City.wallMaterialData); } for (int a = City.edgeLength + 12; a <= City.mapLength - (City.edgeLength + 12); a += 2) { BlockShapes.MakeBlock(a, 74, City.edgeLength + 11, City.wallMaterialID, 2, 100, City.wallMaterialData); } // ladder BlockHelper.MakeLadder((City.mapLength / 2) - 5, 64, 72, City.edgeLength + 11, 2, City.wallMaterialID); BlockShapes.MakeSolidBox((City.mapLength / 2) - 5, (City.mapLength / 2) + 5, 65, 74, City.edgeLength + 11, City.edgeLength + 11, BlockInfo.Air.ID, 2); // decorations at the gates frmLogForm.UpdateLog("Creating wall lights: " + City.outsideLightType, true, true); switch (City.outsideLightType) { case "Fire": // fire above the entrances BlockShapes.MakeBlock((City.mapLength / 2) - 1, 69, City.edgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock((City.mapLength / 2), 69, City.edgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock((City.mapLength / 2) - 1, 70, City.edgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); BlockShapes.MakeBlock((City.mapLength / 2), 70, City.edgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); // fire on the outside walls for (int a = City.edgeLength + 8; a < (City.mapLength / 2) - 9; a += 4) { BlockShapes.MakeBlock(a, 69, City.edgeLength + 5, BlockInfo.Netherrack.ID, 2, 100, -1); BlockShapes.MakeBlock(a, 70, City.edgeLength + 5, BlockInfo.Fire.ID, 2, 100, -1); } break; case "Torches": // torches above the entrances BlockHelper.MakeTorch((City.mapLength / 2), 70, City.edgeLength + 5, City.wallMaterialID, 2); BlockHelper.MakeTorch((City.mapLength / 2) - 1, 70, City.edgeLength + 5, City.wallMaterialID, 2); // torches on the outside walls for (int a = City.edgeLength + 8; a < (City.mapLength / 2) - 9; a += 4) { BlockHelper.MakeTorch(a, 70, City.edgeLength + 5, City.wallMaterialID, 2); } break; case "None": case "": break; default: Debug.Fail("Invalid switch result"); break; } if (City.hasTorchesOnWalkways) { // torches on the inside walls for (int a = City.edgeLength + 16; a < (City.mapLength / 2); a += 4) { BlockHelper.MakeTorch(a, 69, City.edgeLength + 11, City.wallMaterialID, 2); } // torches on the wall roofs for (int a = City.edgeLength + 16; a < (City.mapLength / 2); a += 4) { BlockShapes.MakeBlock(a, 73, City.edgeLength + 8, BlockInfo.Torch.ID, 2, 100, -1); } } for (int a = City.edgeLength + 16; a < (City.mapLength / 2); a += 24) { switch (City.npcs) { case "Ghostdancer's NPCs": EntityVillager eVillager; eVillager = new EntityVillager(new TypedEntity("GKnight")); eVillager.Health = 20; BlockShapes.MakeEntity(a, 73, City.edgeLength + 8, eVillager, 2); break; case "Minecraft Villagers": EntityMob eMob; eMob = new EntityMob(new TypedEntity("VillagerGolem")); eMob.Health = 100; BlockShapes.MakeEntity(a, 73, City.edgeLength + 8, eMob, 2); break; } } frmLogForm.UpdateLog("Creating wall emblems: " + City.cityEmblemType, true, true); MakeEmblem(); }
public void Generate(frmMace frmLogForm, string strUserCityName, bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeNoticeboard, bool booIncludeBuildings, bool booIncludePaths, string strCitySize, string strMoatType, string strCityEmblem, string strOutsideLights, string strFireBeacons, string strCitySeed, string strWorldSeed) { #region Seed the random number generators int intCitySeed, intWorldSeed; Random randSeeds = new Random(); if (strCitySeed == "") { intCitySeed = randSeeds.Next(); frmLogForm.UpdateLog("Random city seed: " + intCitySeed); } else { intCitySeed = JavaStringHashCode(strCitySeed); frmLogForm.UpdateLog("Random city seed: " + strCitySeed); } if (strWorldSeed == "") { intWorldSeed = randSeeds.Next(); frmLogForm.UpdateLog("Random world seed: " + intWorldSeed); } else { intWorldSeed = JavaStringHashCode(strWorldSeed); frmLogForm.UpdateLog("Random world seed: " + strWorldSeed); } RandomHelper.SetSeed(intCitySeed); #endregion #region create minecraft world directory from a random unused city name string strFolder = "", strCityName = ""; strUserCityName = SafeFilename(strUserCityName); if (strUserCityName.ToLower().Trim() == "") { strUserCityName = "Random"; } if (strUserCityName.ToLower().Trim() != "random") { if (Directory.Exists(Environment.GetEnvironmentVariable("APPDATA") + @"\.minecraft\saves\" + strUserCityName + @"\")) { if (MessageBox.Show("A world called \"" + strUserCityName + "\" already exists. " + "Would you like to use a random name instead?", "World already exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { frmLogForm.UpdateLog("Cancelled, because a world with this name already exists."); return; } } else { strCityName = strUserCityName; } } if (strCityName == "") { string strStart, strEnd; do { strStart = RandomHelper.RandomFileLine("Resources\\CityAdj.txt"); strEnd = RandomHelper.RandomFileLine("Resources\\CityNoun.txt"); strCityName = "City of " + strStart + strEnd; strFolder = Environment.GetEnvironmentVariable("APPDATA") + @"\.minecraft\saves\" + strCityName + @"\"; } while (strStart.ToLower().Trim() == strEnd.ToLower().Trim() || Directory.Exists(strFolder)); } Directory.CreateDirectory(strFolder); #endregion RandomHelper.SetSeed(intCitySeed); #region get handles to world, chunk manager and block manager BetaWorld worldDest = BetaWorld.Create(@strFolder); ChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion #region determine block sizes // first we set the city size by chunks int intCitySize = 12; switch (strCitySize) { case "Random": intCitySize = RandomHelper.Next(8, 16); break; case "Very small": intCitySize = 5; break; case "Small": intCitySize = 8; break; case "Medium": intCitySize = 12; break; case "Large": intCitySize = 16; break; case "Very large": intCitySize = 25; break; } // then we multiply by 16, because that's the x and z of a chunk intCitySize *= 16; int intFarmSize = booIncludeFarms ? 32 : 16; int intMapSize = intCitySize + (intFarmSize * 2); #endregion #region setup classes BlockShapes.SetupClass(bmDest, intMapSize); BlockHelper.SetupClass(bmDest, intMapSize); SourceWorld.SetupClass(worldDest); #endregion if (strOutsideLights == "Random") { strOutsideLights = RandomHelper.RandomString("Fire", "Torches"); } #region make the city frmLogForm.UpdateLog("Creating chunks"); Chunks.MakeChunks(cmDest, 0, intMapSize / 16, frmLogForm); frmLogForm.UpdateProgress(35); if (booIncludeBuildings || booIncludePaths) { frmLogForm.UpdateLog("Creating paths"); int[,] intArea = Paths.MakePaths(worldDest, bmDest, intFarmSize, intMapSize); frmLogForm.UpdateProgress(38); if (booIncludeBuildings) { frmLogForm.UpdateLog("Creating buildings"); Buildings.MakeInsideCity(bmDest, worldDest, intArea, intFarmSize, intMapSize, booIncludePaths); } } frmLogForm.UpdateProgress(50); if (booIncludeWalls) { frmLogForm.UpdateLog("Creating walls"); Walls.MakeWalls(worldDest, intFarmSize, intMapSize, strCityEmblem, strOutsideLights); } frmLogForm.UpdateProgress(51); if (booIncludeMoat) { frmLogForm.UpdateLog("Creating moat"); Moat.MakeMoat(intFarmSize, intMapSize, strMoatType, booIncludeGuardTowers); } frmLogForm.UpdateProgress(52); if (booIncludeDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges"); Drawbridge.MakeDrawbridges(bmDest, intFarmSize, intMapSize, booIncludeMoat, booIncludeWalls); } frmLogForm.UpdateProgress(53); if (booIncludeGuardTowers) { frmLogForm.UpdateLog("Creating guard towers"); GuardTowers.MakeGuardTowers(bmDest, intFarmSize, intMapSize, booIncludeWalls, strOutsideLights, strFireBeacons); } frmLogForm.UpdateProgress(54); if (booIncludeWalls && booIncludeNoticeboard) { frmLogForm.UpdateLog("Creating noticeboard"); NoticeBoard.MakeNoticeBoard(bmDest, intFarmSize, intMapSize, intCitySeed, intWorldSeed); } frmLogForm.UpdateProgress(55); if (booIncludeFarms) { frmLogForm.UpdateLog("Creating farms"); Farms.MakeFarms(worldDest, bmDest, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(58); #endregion #region world settings // spawn in a guard tower //world.Level.SpawnX = intFarmSize + 5; //world.Level.SpawnZ = intFarmSize + 5; //world.Level.SpawnY = 74; // spawn looking at one of the city entrances worldDest.Level.SpawnX = intMapSize / 2; worldDest.Level.SpawnZ = intMapSize - (intFarmSize - 10); worldDest.Level.SpawnY = 64; // spawn in the middle of the city //worldDest.Level.SpawnX = intMapSize / 2; //worldDest.Level.SpawnZ = (intMapSize / 2) - 1; //worldDest.Level.SpawnY = 64; // spawn default //world.Level.SpawnX = 0; //world.Level.SpawnY = 65; //world.Level.SpawnZ = 0; if (strWorldSeed != "") { worldDest.Level.RandomSeed = intWorldSeed; } worldDest.Level.LevelName = strCityName; worldDest.Level.Time = RandomHelper.Next(24000); if (RandomHelper.NextDouble() < 0.15) { worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = RandomHelper.Next(6000, 18000); if (RandomHelper.NextDouble() < 0.25) { worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endregion #if DEBUG MakeHelperChest(bmDest, worldDest.Level.SpawnX + 2, worldDest.Level.SpawnY, worldDest.Level.SpawnZ + 2); #endif frmLogForm.UpdateLog("Resetting lighting"); Chunks.ResetLighting(worldDest, cmDest, frmLogForm, (int)Math.Pow(intMapSize / 16, 2)); worldDest.Save(); frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!"); frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list."); }
static public void Generate(frmMace frmLogForm, string UserWorldName, string strWorldSeed, string strWorldType, bool booWorldMapFeatures, int TotalCities, string[] strCheckedThemes, int ChunksBetweenCities, string strSpawnPoint, bool booExportSchematics, string strSelectedNPCs, string strUndergroundOres) { frmLogForm.UpdateLog("Started at " + DateTime.Now.ToLocalTime(), false, true); worldCities = new WorldCity[TotalCities]; lstCityNames.Clear(); Chunks.biomes.Clear(); RNG.SetRandomSeed(); #region create minecraft world directory from a random unused world name string strFolder = String.Empty, strWorldName = String.Empty; UserWorldName = UserWorldName.ToSafeFilename(); if (UserWorldName.Trim().Length == 0) { UserWorldName = "random"; } if (UserWorldName.ToLower().Trim() != "random") { if (Directory.Exists(UserWorldName.ToMinecraftSaveDirectory())) { if (MessageBox.Show("A world called \"" + UserWorldName + "\" already exists. " + "Would you like to use a random name instead?", "World already exists", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { frmLogForm.UpdateLog("Cancelled, because a world with this name already exists.", false, false); return; } } else { strWorldName = UserWorldName; strFolder = strWorldName.ToMinecraftSaveDirectory(); } } if (strWorldName.Length == 0) { strWorldName = Utils.GenerateWorldName(); strFolder = strWorldName.ToMinecraftSaveDirectory(); } Directory.CreateDirectory(strFolder); frmLogForm.btnSaveLogNormal.Tag = Path.Combine(strFolder, "LogNormal.txt"); frmLogForm.btnSaveLogVerbose.Tag = Path.Combine(strFolder, "LogVerbose.txt"); frmLogForm.UpdateLog("World name: " + strWorldName, false, true); #endregion #region get handles to world, chunk manager and block manager AnvilWorld worldDest = AnvilWorld.Create(@strFolder); worldDest.Level.LevelName = "Creating. Don't open until Mace is finished."; RegionChunkManager cmDest = worldDest.GetChunkManager(); BlockManager bmDest = worldDest.GetBlockManager(); bmDest.AutoLight = false; #endregion #region Determine themes // "how does this work, robson?" // well, I'm glad you asked! // we keep selecting a random unused checked theme, until they've all been used once. // after that, all other cities will have a random checked theme int maxFarmSize = 0; strCheckedThemes = RNG.ShuffleArray(strCheckedThemes); for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++) { if (CurrentCityID <= strCheckedThemes.GetUpperBound(0)) { worldCities[CurrentCityID].ThemeName = strCheckedThemes[CurrentCityID]; } else { worldCities[CurrentCityID].ThemeName = RNG.RandomItem(strCheckedThemes); } City.themeName = worldCities[CurrentCityID].ThemeName; worldCities[CurrentCityID].ChunkLength = GetThemeRandomXMLElementNumber("options", "city_size"); int farmSize = GetThemeLastXMLElementNumber("options", "farm_size"); maxFarmSize = Math.Max(maxFarmSize, farmSize); } #endregion GenerateCityLocations(TotalCities, ChunksBetweenCities + maxFarmSize); int intRandomCity = RNG.Next(TotalCities); for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++) { MakeCitySettings(frmLogForm, worldCities[CurrentCityID].ThemeName, CurrentCityID, strSelectedNPCs); if (!GenerateCity.Generate(frmLogForm, worldDest, cmDest, bmDest, worldCities[CurrentCityID].x, worldCities[CurrentCityID].z, booExportSchematics, strUndergroundOres)) { frmLogForm.UpdateLog("World generation failed/cancelled.", false, false); return; } #region set spawn point if (City.id == intRandomCity) { switch (strSpawnPoint) { case "Away from the cities": worldDest.Level.Spawn = new SpawnPoint(0, 65, 0); break; case "Inside a random city": worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2), 65, ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2)); break; case "Outside a random city": worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2), 65, ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + 2); break; default: Debug.Fail("invalid spawn point"); break; } frmLogForm.UpdateLog("Spawn point set to " + worldDest.Level.Spawn.X + "," + worldDest.Level.Spawn.Y + "," + worldDest.Level.Spawn.Z, false, true); } #endregion } #region weather frmLogForm.UpdateLog("Setting weather", false, true); worldDest.Level.Time = RNG.Next(24000); if (RNG.NextDouble() < 0.15) { frmLogForm.UpdateLog("Rain", false, true); worldDest.Level.IsRaining = true; // one-quarter to three-quarters of a day worldDest.Level.RainTime = RNG.Next(6000, 18000); if (RNG.NextDouble() < 0.25) { frmLogForm.UpdateLog("Thunder", false, true); worldDest.Level.IsThundering = true; worldDest.Level.ThunderTime = worldDest.Level.RainTime; } } #endregion #region world details worldDest.Level.LevelName = strWorldName; frmLogForm.UpdateLog("Setting world type: " + strWorldType, false, true); switch (strWorldType.ToLower()) { case "creative": worldDest.Level.GameType = GameType.CREATIVE; break; case "survival": worldDest.Level.GameType = GameType.SURVIVAL; break; case "hardcore": worldDest.Level.GameType = GameType.SURVIVAL; worldDest.Level.Hardcore = true; break; default: Debug.Fail("Invalidate world type selected."); break; } frmLogForm.UpdateLog("World map features: " + booWorldMapFeatures.ToString(), false, true); worldDest.Level.UseMapFeatures = booWorldMapFeatures; if (strWorldSeed != String.Empty) { long seed = 0; if (long.TryParse(strWorldSeed, out seed)) { worldDest.Level.RandomSeed = seed; frmLogForm.UpdateLog("Specified world seed: " + worldDest.Level.RandomSeed, false, true); } else { worldDest.Level.RandomSeed = strWorldSeed.ToJavaHashCode(); frmLogForm.UpdateLog("Specified world seed: " + strWorldSeed, false, true); frmLogForm.UpdateLog("Specified world seed converted to a number: " + worldDest.Level.RandomSeed, false, true); } } else { worldDest.Level.RandomSeed = RNG.Next(); frmLogForm.UpdateLog("Random world seed: " + worldDest.Level.RandomSeed, false, true); } worldDest.Level.LastPlayed = (DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks) / 10000; frmLogForm.UpdateLog("World time: " + worldDest.Level.LastPlayed, false, true); #endregion cmDest.Save(); worldDest.Save(); Chunks.SetBiomeData(@strFolder); frmLogForm.UpdateLog("\nCreated the " + strWorldName + "!", false, false); frmLogForm.UpdateLog("It'll be at the top of your MineCraft world list.", false, false); frmLogForm.UpdateLog("Finished at " + DateTime.Now.ToLocalTime(), false, true); }
public void Generate(frmMace frmLogForm, bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeNoticeboard, bool booIncludeBuildings, bool booIncludeSewers, string strCitySize, string strMoatLiquid) { string strFolder, strCityName; do { strCityName = "City of " + RandomHelper.RandomFileLine("CityStartingWords.txt") + RandomHelper.RandomFileLine("CityEndingWords.txt"); strFolder = Environment.GetEnvironmentVariable("APPDATA") + @"\.minecraft\saves\" + strCityName + @"\"; } while (Directory.Exists(strFolder)); Directory.CreateDirectory(strFolder); BetaWorld world = BetaWorld.Create(@strFolder); int intFarmSize = 28; if (!booIncludeFarms) { intFarmSize = 2; } int intPlotSize = 12; int intPlots = 15; Random rand = new Random(); switch (strCitySize) { case "Random": intPlots = rand.Next(10, 20); break; case "Very small": intPlots = 6; break; case "Small": intPlots = 10; break; case "Medium": intPlots = 15; break; case "Large": intPlots = 20; break; case "Very large": intPlots = 23; break; default: Debug.Assert(false); break; } int intMapSize = (intPlots * intPlotSize) + (intFarmSize * 2); ChunkManager cm = world.GetChunkManager(); frmLogForm.UpdateLog("Creating chunks"); Chunks.MakeChunks(cm, -1, 2 + (intMapSize / 16), frmLogForm); frmLogForm.UpdateProgress(34); BlockManager bm = world.GetBlockManager(); bm.AutoLight = false; BlockShapes.SetupClass(bm, intMapSize); BlockHelper.SetupClass(bm, intMapSize); bool[,] booSewerEntrances; if (booIncludeSewers) { frmLogForm.UpdateLog("Creating sewers"); booSewerEntrances = Sewers.MakeSewers(intFarmSize, intMapSize, intPlotSize); } else { booSewerEntrances = new bool[2 + ((intMapSize - ((intFarmSize + 16) * 2)) / intPlotSize), 2 + ((intMapSize - ((intFarmSize + 16) * 2)) / intPlotSize)]; } frmLogForm.UpdateProgress(35); if (booIncludeBuildings) { frmLogForm.UpdateLog("Creating plots"); Plots.MakeBuildings(bm, booSewerEntrances, intFarmSize, intMapSize, intPlotSize); } frmLogForm.UpdateProgress(36); if (booIncludeWalls) { frmLogForm.UpdateLog("Creating walls"); Walls.MakeWalls(intFarmSize, intMapSize); } frmLogForm.UpdateProgress(37); if (booIncludeMoat) { frmLogForm.UpdateLog("Creating moat"); Moat.MakeMoat(intFarmSize, intMapSize, strMoatLiquid); } frmLogForm.UpdateProgress(38); if (booIncludeDrawbridges) { frmLogForm.UpdateLog("Creating drawbridges"); Drawbridge.MakeDrawbridges(bm, intFarmSize, intMapSize, booIncludeMoat, booIncludeWalls); } frmLogForm.UpdateProgress(39); if (booIncludeGuardTowers) { frmLogForm.UpdateLog("Creating guard towers"); GuardTowers.MakeGuardTowers(bm, intFarmSize, intMapSize, booIncludeWalls); } frmLogForm.UpdateProgress(40); if (booIncludeWalls && booIncludeNoticeboard) { frmLogForm.UpdateLog("Creating noticeboard"); NoticeBoard.MakeNoticeBoard(bm, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(41); if (booIncludeFarms) { frmLogForm.UpdateLog("Creating farms"); Farms.MakeFarms(bm, intFarmSize, intMapSize); } frmLogForm.UpdateProgress(42); world.Level.LevelName = strCityName; // spawn in a guard tower //world.Level.SpawnX = intFarmSize + 5; //world.Level.SpawnZ = intFarmSize + 5; //world.Level.SpawnY = 74; // spawn looking at one of the city entrances world.Level.SpawnX = intMapSize / 2; world.Level.SpawnZ = intMapSize - 21; world.Level.SpawnY = 64; if (rand.NextDouble() < 0.1) { world.Level.IsRaining = true; if (rand.NextDouble() < 0.25) { world.Level.IsThundering = true; } } //MakeHelperChest(bm, world.Level.SpawnX + 2, world.Level.SpawnY, world.Level.SpawnZ + 2); frmLogForm.UpdateLog("Resetting lighting"); Chunks.ResetLighting(cm, frmLogForm, (int)Math.Pow(3 + (intMapSize / 16), 2)); world.Save(); frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!"); frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list."); }