private static void MakeStreetLight(BlockManager bm, StreetLights slCurrent, int x1, int z1, int x2, int z2) { if (bm.GetID(x1, 63, z1) == City.GroundBlockID && bm.GetData(x1, 63, z1) == City.GroundBlockData && bm.GetID(x1, 64, z1) == BlockInfo.Air.ID && bm.GetID(x1, 65, z1) == BlockInfo.Air.ID) { switch (slCurrent) { case StreetLights.Glowstone: bm.SetID(x1, 64, z1, BlockInfo.Fence.ID); bm.SetID(x1, 65, z1, BlockInfo.Fence.ID); bm.SetID(x1, 66, z1, BlockInfo.Fence.ID); bm.SetID(x1, 67, z1, BlockInfo.Fence.ID); bm.SetID(x1, 68, z1, BlockInfo.Fence.ID); bm.SetID(x2, 68, z2, BlockInfo.Fence.ID); bm.SetID(x2, 67, z2, BlockInfo.Glowstone.ID); break; case StreetLights.Torches: bm.SetID(x1, 64, z1, BlockInfo.Fence.ID); bm.SetID(x1, 65, z1, BlockInfo.Fence.ID); bm.SetID(x1, 66, z1, BlockInfo.Fence.ID); bm.SetID(x1, 67, z1, BlockInfo.Fence.ID); bm.SetID(x1, 68, z1, BlockInfo.Fence.ID); bm.SetID(x2, 68, z2, BlockInfo.Fence.ID); bm.SetID(x2, 67, z2, BlockInfo.WoodPlank.ID); if (z1 == z2) { BlockHelper.MakeTorch(x2, 67, z2 - 1, BlockInfo.WoodPlank.ID, 0); BlockHelper.MakeTorch(x2, 67, z2 + 1, BlockInfo.WoodPlank.ID, 0); } else { BlockHelper.MakeTorch(x2 - 1, 67, z2, BlockInfo.WoodPlank.ID, 0); BlockHelper.MakeTorch(x2 + 1, 67, z2, BlockInfo.WoodPlank.ID, 0); } break; } } }
public static void MakeNoticeBoard(BlockManager bm, int intFarmSize, int intMapSize) { BlockHelper.MakeSign((intMapSize / 2) - 8, 67, intMapSize - (intFarmSize + 11), "|Public|Notice Board|", (int)BlockType.STONE); for (int x = (intMapSize / 2) - 9; x <= (intMapSize / 2) - 7; x++) { for (int y = 65; y <= 66; y++) { if (x == (intMapSize / 2) - 7 && y == 66) { Version ver = System.Reflection.Assembly.GetEntryAssembly().GetName().Version; BlockHelper.MakeSign(x, y, intMapSize - (intFarmSize + 11), String.Format("Created by|Mace v{0}.{1}.{2}|by Robson.|Have fun :)", ver.Major, ver.Minor, ver.Build), (int)BlockType.STONE); } else { BlockHelper.MakeSign(x, y, intMapSize - (intFarmSize + 11), RandomSign(), (int)BlockType.STONE); } } } }
private static void MakeGuardChest(BlockManager bm, int x, int y, int z) { TileEntityChest tec = new TileEntityChest(); for (int a = 0; a < 5; a++) { tec.Items[a] = BlockHelper.MakeItem(RandomHelper.RandomNumber(ItemInfo.IronSword.ID, ItemInfo.WoodenSword.ID, ItemInfo.StoneSword.ID), 1); } tec.Items[6] = BlockHelper.MakeItem(ItemInfo.Bow.ID, 1); tec.Items[7] = BlockHelper.MakeItem(ItemInfo.Arrow.ID, 64); int intArmourStartID = RandomHelper.RandomNumber(ItemInfo.LeatherCap.ID, ItemInfo.ChainHelmet.ID, ItemInfo.IronHelmet.ID); for (int a = 9; a < 18; a++) { tec.Items[a] = BlockHelper.MakeItem(intArmourStartID + rand.Next(4), 1); // random armour } bm.SetID(x, y, z, (int)BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
private static void MakeStreetLight(BlockManager bm, StreetLights slCurrent, int x1, int z1, int x2, int z2) { if (bm.GetID(x1, 63, z1) == BlockType.GRASS && bm.GetID(x1, 64, z1) == BlockType.AIR && bm.GetID(x1, 65, z1) == BlockType.AIR) { switch (slCurrent) { case StreetLights.Glowstone: bm.SetID(x1, 64, z1, BlockType.FENCE); bm.SetID(x1, 65, z1, BlockType.FENCE); bm.SetID(x1, 66, z1, BlockType.FENCE); bm.SetID(x1, 67, z1, BlockType.FENCE); bm.SetID(x1, 68, z1, BlockType.FENCE); bm.SetID(x2, 68, z2, BlockType.FENCE); bm.SetID(x2, 67, z2, BlockType.GLOWSTONE_BLOCK); break; case StreetLights.Torches: bm.SetID(x1, 64, z1, BlockType.FENCE); bm.SetID(x1, 65, z1, BlockType.FENCE); bm.SetID(x1, 66, z1, BlockType.FENCE); bm.SetID(x1, 67, z1, BlockType.FENCE); bm.SetID(x1, 68, z1, BlockType.FENCE); bm.SetID(x2, 68, z2, BlockType.FENCE); bm.SetID(x2, 67, z2, BlockType.WOOD_PLANK); if (z1 == z2) { BlockHelper.MakeTorch(x2, 67, z2 - 1, BlockType.WOOD_PLANK, 0); BlockHelper.MakeTorch(x2, 67, z2 + 1, BlockType.WOOD_PLANK, 0); } else { BlockHelper.MakeTorch(x2 - 1, 67, z2, BlockType.WOOD_PLANK, 0); BlockHelper.MakeTorch(x2 + 1, 67, z2, BlockType.WOOD_PLANK, 0); } break; } } }
public static void MakeDoor(int x, int y, int z, int intBlockAgainst, bool booIronDoor, int intMirror) { int intDirection = BlockHelper.DoorDirection(x, y + 1, z, intBlockAgainst); int intBlockType = BlockType.WOOD_DOOR; if (booIronDoor) { intBlockType = BlockType.IRON_DOOR; } BlockShapes.MakeBlock(x, y + 1, z, intBlockType, (int)DoorState.TOPHALF + intDirection); BlockShapes.MakeBlock(x, y, z, intBlockType, intDirection); if (intMirror > 0) { MakeDoor(_intMapSize - x, y, z, intBlockAgainst, booIronDoor, 0); MakeDoor(x, y, _intMapSize - z, intBlockAgainst, booIronDoor, 0); MakeDoor(_intMapSize - x, y, _intMapSize - z, intBlockAgainst, booIronDoor, 0); if (intMirror == 2) { MakeDoor(z, y, x, intBlockAgainst, booIronDoor, 1); } } }
public static void MakeDoor(int x, int y, int z, int intBlockAgainst, bool booIronDoor, int intMirror) { int intDirection = BlockHelper.DoorDirection(x, y + 1, z, intBlockAgainst); int intBlockType = BlockInfo.WoodDoor.ID; if (booIronDoor) { intBlockType = BlockInfo.IronDoor.ID; } BlockShapes.MakeBlock(x, y + 1, z, intBlockType, (int)DoorState.TOPHALF + intDirection); BlockShapes.MakeBlock(x, y, z, intBlockType, intDirection); if (intMirror > 0) { MakeDoor(City.MapLength - x, y, z, intBlockAgainst, booIronDoor, 0); MakeDoor(x, y, City.MapLength - z, intBlockAgainst, booIronDoor, 0); MakeDoor(City.MapLength - x, y, City.MapLength - z, intBlockAgainst, booIronDoor, 0); if (intMirror == 2) { MakeDoor(z, y, x, intBlockAgainst, booIronDoor, 1); } } }
public static void PositionRails(BetaWorld worldDest, BlockManager bm) { int intReplaced = 0; for (int x = 0; x < City.MapLength; x++) { for (int z = 0; z < City.MapLength; z++) { for (int y = 0; y < 128; y++) { if (bm.GetID(x, y, z) == BlockInfo.Rails.ID) { BlockHelper.MakeRail(x, y, z); if (++intReplaced > 100) { worldDest.Save(); intReplaced = 0; } } } } } }
private static void MakeHelperChest(BlockManager bm, int x, int y, int z) { TileEntityChest tec = new TileEntityChest(); tec.Items[0] = BlockHelper.MakeItem(ItemInfo.DiamondSword.ID); tec.Items[1] = BlockHelper.MakeItem(ItemInfo.DiamondPickaxe.ID); tec.Items[2] = BlockHelper.MakeItem(ItemInfo.DiamondShovel.ID); tec.Items[3] = BlockHelper.MakeItem(ItemInfo.DiamondPickaxe.ID); tec.Items[4] = BlockHelper.MakeItem((int)BlockType.LADDER, 64); tec.Items[5] = BlockHelper.MakeItem((int)BlockType.DIRT, 64); tec.Items[6] = BlockHelper.MakeItem((int)BlockType.SAND, 64); tec.Items[7] = BlockHelper.MakeItem((int)BlockType.CRAFTING_TABLE, 64); tec.Items[8] = BlockHelper.MakeItem((int)BlockType.FURNACE, 64); tec.Items[9] = BlockHelper.MakeItem(ItemInfo.Bread.ID, 64); tec.Items[10] = BlockHelper.MakeItem((int)BlockType.TORCH, 64); tec.Items[11] = BlockHelper.MakeItem((int)BlockType.STONE, 64); tec.Items[12] = BlockHelper.MakeItem((int)BlockType.CHEST, 64); tec.Items[13] = BlockHelper.MakeItem((int)BlockType.GLASS, 64); tec.Items[14] = BlockHelper.MakeItem((int)BlockType.WOOD, 64); tec.Items[15] = BlockHelper.MakeItem(ItemInfo.Cookie.ID, 64); bm.SetID(x, y, z, (int)BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
public static void MakeMineshaft(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength, Buildings.structPoint spMineshaftEntrance) { _intBlockStartBuildings = intFarmLength + 13; int intMineshaftSize = (1 + intMapLength) - (_intBlockStartBuildings * 2); if (intMineshaftSize % 5 > 0) { intMineshaftSize += 5 - (intMineshaftSize % 5); } _intBlockStartBuildings -= 2; for (int intLevel = 1; intLevel <= 7; intLevel++) { MakeLevel(world, bm, intLevel, intMineshaftSize, spMineshaftEntrance); } int intBlockToReplace = bm.GetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1); BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockType.WOOD, 0); BlockHelper.MakeLadder(spMineshaftEntrance.x, 4, 63, spMineshaftEntrance.z, 0, BlockType.WOOD); BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockType.STONE, 0); bm.SetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1, intBlockToReplace); }
public static void PositionRails(BetaWorld worldDest, BlockManager bm, int intCitySize) { int intReplaced = 0; for (int x = 0; x < intCitySize; x++) { for (int z = 0; z < intCitySize; z++) { for (int y = 0; y < 128; y++) { if (bm.GetID(x, y, z) == BlockType.RAILS) { BlockHelper.MakeRail(x, y, z); if (++intReplaced > 100) { worldDest.Save(); intReplaced = 0; } } } } } }
public static void MakeMineshaft(BetaWorld world, BlockManager bm, Buildings.structPoint spMineshaftEntrance, frmMace frmLogForm) { _intBlockStartBuildings = City.FarmLength + 13; int intMineshaftSize = (1 + City.MapLength) - (_intBlockStartBuildings * 2); if (intMineshaftSize % 5 > 0) { intMineshaftSize += 5 - (intMineshaftSize % 5); } _intBlockStartBuildings -= 2; for (int intLevel = 1; intLevel <= 7; intLevel++) { MakeLevel(world, bm, intLevel, intMineshaftSize, spMineshaftEntrance, frmLogForm); } int intBlockToReplace = bm.GetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1); BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockInfo.Wood.ID, 0); BlockHelper.MakeLadder(spMineshaftEntrance.x, 4, 63, spMineshaftEntrance.z, 0, BlockInfo.Wood.ID); BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockInfo.Stone.ID, 0); bm.SetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1, intBlockToReplace); }
public static void MakeWalls(int intFarmSize, int intMapSize) { // walls for (int a = intFarmSize + 6; a <= intFarmSize + 10; a++) { BlockShapes.MakeHollowLayers(a, intMapSize - a, 58, 71, a, intMapSize - a, (int)BlockType.STONE); } // outside and inside edges at the top BlockShapes.MakeHollowLayers(intFarmSize + 6, intMapSize - (intFarmSize + 6), 72, 72, intFarmSize + 6, intMapSize - (intFarmSize + 6), (int)BlockType.STONE); BlockShapes.MakeHollowLayers(intFarmSize + 10, intMapSize - (intFarmSize + 10), 72, 72, intFarmSize + 10, intMapSize - (intFarmSize + 10), (int)BlockType.STONE); // alternating blocks on top of the edges for (int a = intFarmSize + 6; a <= intMapSize - (intFarmSize + 6); a += 2) { BlockShapes.MakeBlock(a, 73, intFarmSize + 6, (int)BlockType.STONE, 2); } for (int a = intFarmSize + 10; a <= intMapSize - (intFarmSize + 10); a += 2) { BlockShapes.MakeBlock(a, 73, intFarmSize + 10, (int)BlockType.STONE, 2); } // ladder BlockHelper.MakeLadder((intMapSize / 2) - 5, 64, 72, intFarmSize + 11, 2); }
private static TileEntityChest MakeTreasureChest() { TileEntityChest tec = new TileEntityChest(); for (int intItems = RandomHelper.Next(5, 7); intItems >= 2; intItems--) { tec.Items[intItems] = BlockHelper.MakeItem(RandomHelper.RandomNumber( ItemInfo.GoldenApple.ID, ItemInfo.GoldIngot.ID, ItemInfo.Diamond.ID, ItemInfo.GoldMusicDisc.ID, ItemInfo.GreenMusicDisc.ID, ItemInfo.IronIngot.ID, ItemInfo.Saddle.ID, ItemInfo.Compass.ID, ItemInfo.Clock.ID, ItemInfo.Cake.ID, ItemInfo.Cookie.ID ), 1); } tec.Items[0] = BlockHelper.MakeItem(ItemInfo.GetRandomItem().ID, 1); tec.Items[1] = BlockHelper.MakeItem(ItemInfo.GetRandomItem().ID, 1); return(tec); }
private static void MakeStreetSign(BlockManager bm, int x1, int z1, int x2, int z2) { x1 += intBlockStart; z1 += intBlockStart; x2 += intBlockStart; z2 += intBlockStart; bm.SetID(x1, 64, z1, (int)BlockType.WOOD_PLANK); bm.SetID(x2, 64, z2, (int)BlockType.WOOD_PLANK); if (z1 == z2) { x1--; x2++; } else { z1--; z2++; } string strStreetName = RandomHelper.RandomFileLine("Resources\\CityStartingWords.txt"); string strStreetType = RandomHelper.RandomFileLine("Resources\\RoadTypes.txt"); BlockHelper.MakeSign(x1, 64, z1, "|" + strStreetName + "|" + strStreetType + "|", (int)BlockType.WOOD_PLANK); BlockHelper.MakeSign(x2, 64, z2, "|" + strStreetName + "|" + strStreetType + "|", (int)BlockType.WOOD_PLANK); }
private static TileEntityChest MakeHouseChest() { TileEntityChest tec = new TileEntityChest(); for (int intItems = RandomHelper.Next(4, 8); intItems >= 0; intItems--) { switch (RandomHelper.Next(0, 17)) { case 0: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Apple.ID, 1); break; case 1: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Book.ID, 1); break; case 2: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Bowl.ID, 1); break; case 3: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Bread.ID, 1); break; case 4: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Cake.ID, 1); break; case 5: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Clock.ID, 1); break; case 6: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Compass.ID, 1); break; case 7: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Cookie.ID, 1); break; case 8: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Diamond.ID, 1); break; case 9: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Egg.ID, 1); break; case 10: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Feather.ID, 1); break; case 11: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.FishingRod.ID, 1); break; case 12: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.GoldMusicDisc.ID, 1); break; case 13: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.GreenMusicDisc.ID, 1); break; case 14: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Paper.ID, 1); break; case 15: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.Saddle.ID, 1); break; case 16: tec.Items[intItems] = BlockHelper.MakeItem(ItemInfo.String.ID, 1); break; } } return(tec); }
public static void MakeDrawbridges(BlockManager bm) { if (City.HasWalls) { // 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.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.Stone.ID, 2); } else { BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63, City.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.WoodPlank.ID, 2); } BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 64, City.FarmLength + intBridgeEnd, City.FarmLength + 13, BlockInfo.Air.ID, 2); // carve out the entrance/exit BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 64, 67, City.FarmLength + intBridgeEnd, City.FarmLength + 10, BlockInfo.Air.ID, 2); if (Utils.IsValidSign(City.Name)) { BlockHelper.MakeSign((City.MapLength / 2) - 3, 65, City.FarmLength + 5, Utils.ConvertStringToSignText(City.Name.Replace("City of ", "City of~")), City.WallMaterialID, 2); } // add the bottom of a portcullis BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 67, 67, City.FarmLength + 6, City.FarmLength + 6, BlockInfo.Fence.ID, 2); // add room for murder holes BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, (City.MapLength / 2) + 2, 69, 71, City.FarmLength + 8, City.FarmLength + 9, BlockInfo.Air.ID, 2); BlockShapes.MakeSolidBox(City.MapLength / 2, City.MapLength / 2, 69, 72, City.FarmLength + 8, City.FarmLength + 9, BlockInfo.Air.ID, 2); BlockHelper.MakeLadder(City.MapLength / 2, 69, 72, City.FarmLength + 9, 2, City.WallMaterialID); BlockShapes.MakeSolidBoxWithData(City.MapLength / 2, City.MapLength / 2, 72, 72, City.FarmLength + 8, City.FarmLength + 8, City.WallMaterialID, 2, City.WallMaterialData); // murder holes BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, (City.MapLength / 2) - 2, 68, 68, City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2); BlockShapes.MakeSolidBox(City.MapLength / 2, City.MapLength / 2, 68, 68, City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2); BlockShapes.MakeSolidBox((City.MapLength / 2) + 2, (City.MapLength / 2) + 2, 68, 68, City.FarmLength + 8, City.FarmLength + 8, BlockInfo.Air.ID, 2); // chests BlockShapes.MakeBlock((City.MapLength / 2) - 4, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2) + 4, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2) - 3, 70, City.FarmLength + 9, BlockInfo.Air.ID, 2, 100, -1); BlockShapes.MakeBlock((City.MapLength / 2) + 3, 70, City.FarmLength + 9, BlockInfo.Air.ID, 2, 100, -1); TileEntityChest tec = new TileEntityChest(); if (City.HasItemsInChests) { tec.Items[0] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); tec.Items[1] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); tec.Items[2] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); } BlockHelper.MakeChest((City.MapLength / 2) - 3, 69, City.FarmLength + 9, BlockInfo.Gravel.ID, tec, 2); // add torches BlockHelper.MakeTorch((City.MapLength / 2) - 1, 70, City.FarmLength + 9, City.WallMaterialID, 2); BlockHelper.MakeTorch((City.MapLength / 2) + 1, 70, City.FarmLength + 9, City.WallMaterialID, 2); // link to main roads //BlockShapes.MakeSolidBox((City.intMapLength / 2) - 1, (City.intMapLength / 2) + 1, 63, 63, // City.intFarmSize + 11, City.intFarmSize + 13, BlockType.DOUBLE_SLAB, 0); } else if (City.HasMoat) { BlockShapes.MakeSolidBox((City.MapLength / 2) - 2, City.MapLength / 2, 63, 63, City.FarmLength - 2, City.FarmLength + 6, BlockInfo.Stone.ID, 2); } }
public static void MakeWalls(BetaWorld world, int intFarmSize, int intMapSize, string strCityEmblem, string strOutsideLights, int intWallMaterial) { // walls for (int a = intFarmSize + 6; a <= intFarmSize + 10; a++) { BlockShapes.MakeHollowLayers(a, intMapSize - a, 58, 72, a, intMapSize - a, intWallMaterial, 0, -1); world.Save(); } // outside and inside edges at the top BlockShapes.MakeHollowLayers(intFarmSize + 5, intMapSize - (intFarmSize + 5), 72, 73, intFarmSize + 5, intMapSize - (intFarmSize + 5), intWallMaterial, 0, -1); BlockShapes.MakeHollowLayers(intFarmSize + 11, intMapSize - (intFarmSize + 11), 72, 73, intFarmSize + 11, intMapSize - (intFarmSize + 11), intWallMaterial, 0, -1); // alternating blocks on top of the edges for (int a = intFarmSize + 6; a <= intMapSize - (intFarmSize + 6); a += 2) { BlockShapes.MakeBlock(a, 74, intFarmSize + 5, intWallMaterial, 2, 100, -1); } for (int a = intFarmSize + 10; a <= intMapSize - (intFarmSize + 10); a += 2) { BlockShapes.MakeBlock(a, 74, intFarmSize + 11, intWallMaterial, 2, 100, -1); } // ladder BlockHelper.MakeLadder((intMapSize / 2) - 5, 64, 72, intFarmSize + 11, 2, intWallMaterial); BlockShapes.MakeBlock((intMapSize / 2) - 5, 73, intFarmSize + 11, (int)BlockType.AIR, 2, 100, -1); // decorations at the gates switch (strOutsideLights) { case "Fire": // fire above the entrances BlockShapes.MakeBlock((intMapSize / 2) - 1, 69, intFarmSize + 5, (int)BlockType.NETHERRACK, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2), 69, intFarmSize + 5, (int)BlockType.NETHERRACK, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2) - 1, 70, intFarmSize + 5, (int)BlockType.FIRE, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2), 70, intFarmSize + 5, (int)BlockType.FIRE, 2, 100, -1); // fire on the outside walls for (int a = intFarmSize + 8; a < (intMapSize / 2) - 9; a += 4) { BlockShapes.MakeBlock(a, 69, intFarmSize + 5, (int)BlockType.NETHERRACK, 2, 100, -1); BlockShapes.MakeBlock(a, 70, intFarmSize + 5, (int)BlockType.FIRE, 2, 100, -1); } break; case "Torches": // torches above the entrances BlockHelper.MakeTorch((intMapSize / 2), 70, intFarmSize + 5, intWallMaterial, 2); BlockHelper.MakeTorch((intMapSize / 2) - 1, 70, intFarmSize + 5, intWallMaterial, 2); // torches on the outside walls for (int a = intFarmSize + 8; a < (intMapSize / 2) - 9; a += 4) { BlockHelper.MakeTorch(a, 70, intFarmSize + 5, intWallMaterial, 2); } break; } // torches on the inside walls for (int a = intFarmSize + 16; a < (intMapSize / 2); a += 4) { BlockHelper.MakeTorch(a, 69, intFarmSize + 11, intWallMaterial, 2); } // torches on the wall roofs for (int a = intFarmSize + 16; a < (intMapSize / 2); a += 4) { BlockShapes.MakeBlock(a, 73, intFarmSize + 8, (int)BlockType.TORCH, 2, 100, -1); } MakeEmblem(intFarmSize, intMapSize, strCityEmblem); }
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, 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 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."); }
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 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."); }
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."); }
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 static void MakeGuardTowers(BlockManager bm, int intFarmSize, int intMapSize, bool booIncludeWalls, string strOutsideLights, string strFireBeacons) { // remove wall BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 11, 64, 79, intFarmSize + 5, intFarmSize + 11, (int)BlockType.AIR, 1); // add tower BlockShapes.MakeHollowBox(intFarmSize + 4, intFarmSize + 12, 63, 80, intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1); // divide into two rooms BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 12, 2, 72, intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1); BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 11, 64, 67, intFarmSize + 5, intFarmSize + 11, (int)BlockType.AIR, 1); switch (strOutsideLights) { case "Fire": for (int y = 72; y <= 79; y += 7) { BlockShapes.MakeBlock(intFarmSize + 6, y, intFarmSize + 3, (int)BlockType.NETHERRACK, 2); BlockShapes.MakeBlock(intFarmSize + 6, y + 1, intFarmSize + 3, (int)BlockType.FIRE, 2); BlockShapes.MakeBlock(intFarmSize + 10, y, intFarmSize + 3, (int)BlockType.NETHERRACK, 2); BlockShapes.MakeBlock(intFarmSize + 10, y + 1, intFarmSize + 3, (int)BlockType.FIRE, 2); } break; case "Torches": for (int y = 73; y <= 80; y += 7) { BlockHelper.MakeTorch(intFarmSize + 6, y, intFarmSize + 3, (int)BlockType.STONE, 2); BlockHelper.MakeTorch(intFarmSize + 10, y, intFarmSize + 3, (int)BlockType.STONE, 2); } break; } // add torches BlockHelper.MakeTorch(intFarmSize + 6, 79, intFarmSize + 13, (int)BlockType.STONE, 2); BlockHelper.MakeTorch(intFarmSize + 10, 79, intFarmSize + 13, (int)BlockType.STONE, 2); // add torches inside BlockHelper.MakeTorch(intFarmSize + 6, 77, intFarmSize + 11, (int)BlockType.STONE, 2); BlockHelper.MakeTorch(intFarmSize + 10, 77, intFarmSize + 11, (int)BlockType.STONE, 2); BlockHelper.MakeTorch(intFarmSize + 5, 77, intFarmSize + 6, (int)BlockType.STONE, 2); BlockHelper.MakeTorch(intFarmSize + 5, 77, intFarmSize + 10, (int)BlockType.STONE, 2); // add openings to the walls BlockShapes.MakeBlock(intFarmSize + 7, 73, intFarmSize + 12, (int)BlockType.AIR, 2); BlockShapes.MakeBlock(intFarmSize + 9, 73, intFarmSize + 12, (int)BlockType.AIR, 2); BlockShapes.MakeBlock(intFarmSize + 7, 74, intFarmSize + 12, (int)BlockType.AIR, 2); BlockShapes.MakeBlock(intFarmSize + 9, 74, intFarmSize + 12, (int)BlockType.AIR, 2); // add blocks on top of the towers BlockShapes.MakeHollowLayers(intFarmSize + 4, intFarmSize + 12, 81, 81, intFarmSize + 4, intFarmSize + 12, (int)BlockType.STONE, 1); // alternating top blocks for (int x = intFarmSize + 4; x <= intFarmSize + 12; x += 2) { for (int z = intFarmSize + 4; z <= intFarmSize + 12; z += 2) { if (x == intFarmSize + 4 || x == intFarmSize + 12 || z == intFarmSize + 4 || z == intFarmSize + 12) { BlockShapes.MakeBlock(x, 82, z, (int)BlockType.STONE, 1); } } } // add central columns BlockShapes.MakeSolidBox(intFarmSize + 8, intFarmSize + 8, 73, 82, intFarmSize + 8, intFarmSize + 8, (int)BlockType.STONE, 1); BlockHelper.MakeLadder(intFarmSize + 7, 73, 82, intFarmSize + 8, 2); BlockHelper.MakeLadder(intFarmSize + 9, 73, 82, intFarmSize + 8, 2); // add torches on the roof BlockShapes.MakeBlock(intFarmSize + 6, 81, intFarmSize + 6, (int)BlockType.TORCH, 1); BlockShapes.MakeBlock(intFarmSize + 6, 81, intFarmSize + 10, (int)BlockType.TORCH, 2); BlockShapes.MakeBlock(intFarmSize + 10, 81, intFarmSize + 10, (int)BlockType.TORCH, 1); // add cobwebs BlockShapes.MakeBlock(intFarmSize + 5, 79, intFarmSize + 5, (int)BlockType.COBWEB, 1, 30); BlockShapes.MakeBlock(intFarmSize + 5, 79, intFarmSize + 11, (int)BlockType.COBWEB, 1, 30); BlockShapes.MakeBlock(intFarmSize + 11, 79, intFarmSize + 5, (int)BlockType.COBWEB, 1, 30); BlockShapes.MakeBlock(intFarmSize + 11, 79, intFarmSize + 11, (int)BlockType.COBWEB, 1, 30); // add chests MakeGuardChest(bm, intFarmSize + 11, 73, intFarmSize + 11); MakeGuardChest(bm, intMapSize - (intFarmSize + 11), 73, intFarmSize + 11); MakeGuardChest(bm, intFarmSize + 11, 73, intMapSize - (intFarmSize + 11)); MakeGuardChest(bm, intMapSize - (intFarmSize + 11), 73, intMapSize - (intFarmSize + 11)); // add archery slots BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 4, 74, 77, intFarmSize + 8, intFarmSize + 8, (int)BlockType.AIR, 2); BlockShapes.MakeSolidBox(intFarmSize + 4, intFarmSize + 4, 76, 76, intFarmSize + 7, intFarmSize + 9, (int)BlockType.AIR, 2); if (!booIncludeWalls) { BlockHelper.MakeLadder(intFarmSize + 13, 64, 72, intFarmSize + 8, 2); } // include beds BlockHelper.MakeBed(intFarmSize + 5, intFarmSize + 6, 64, intFarmSize + 8, intFarmSize + 8, 2); BlockHelper.MakeBed(intFarmSize + 5, intFarmSize + 6, 64, intFarmSize + 10, intFarmSize + 10, 2); BlockHelper.MakeBed(intFarmSize + 11, intFarmSize + 10, 64, intFarmSize + 8, intFarmSize + 8, 2); // make columns to orientate torches BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 73, intFarmSize + 5, intFarmSize + 5, (int)BlockType.WOOD, 2); BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 5, intFarmSize + 5, (int)BlockType.WOOD, 2); BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.WOOD, 2); BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.WOOD, 2); // add ladders BlockHelper.MakeLadder(intFarmSize + 5, 64, 73, intFarmSize + 6, 2, (int)BlockType.WOOD); // make torches BlockHelper.MakeTorch(intFarmSize + 10, 66, intFarmSize + 5, (int)BlockType.WOOD, 2); BlockHelper.MakeTorch(intFarmSize + 6, 66, intFarmSize + 11, (int)BlockType.WOOD, 2); BlockHelper.MakeTorch(intFarmSize + 10, 66, intFarmSize + 11, (int)BlockType.WOOD, 2); // make columns for real BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 73, intFarmSize + 5, intFarmSize + 5, (int)BlockType.STONE, 2); BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 5, intFarmSize + 5, (int)BlockType.STONE, 2); BlockShapes.MakeSolidBox(intFarmSize + 5, intFarmSize + 5, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.STONE, 2); BlockShapes.MakeSolidBox(intFarmSize + 11, intFarmSize + 11, 64, 71, intFarmSize + 11, intFarmSize + 11, (int)BlockType.STONE, 2); // make cobwebs BlockShapes.MakeBlock(intFarmSize + 11, 67, intFarmSize + 8, (int)BlockType.COBWEB, 2, 75); // make doors from the city to the guard tower BlockShapes.MakeBlock(intFarmSize + 11, 65, intFarmSize + 11, (int)BlockType.GOLD_BLOCK, 1); BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.GOLD_BLOCK, 1); BlockHelper.MakeDoor(intFarmSize + 11, 64, intFarmSize + 12, (int)BlockType.GOLD_BLOCK, true, 2); BlockShapes.MakeBlock(intFarmSize + 11, 65, intFarmSize + 11, (int)BlockType.AIR, 1); BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.AIR, 1); BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 11, (int)BlockType.STONE_PLATE, 1); BlockShapes.MakeBlock(intFarmSize + 11, 64, intFarmSize + 13, (int)BlockType.STONE_PLATE, 2); // make beacon if (strFireBeacons == "Yes") { BlockShapes.MakeSolidBox(intFarmSize + 8, intFarmSize + 8, 83, 84, intFarmSize + 8, intFarmSize + 8, (int)BlockType.STONE, 1); BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 85, 85, intFarmSize + 6, intFarmSize + 10, (int)BlockType.STONE, 1); BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 86, 86, intFarmSize + 6, intFarmSize + 10, (int)BlockType.NETHERRACK, 1); BlockShapes.MakeSolidBox(intFarmSize + 6, intFarmSize + 10, 87, 87, intFarmSize + 6, intFarmSize + 10, (int)BlockType.FIRE, 1); } }
public static void MakeDrawbridges(BlockManager bm, int intFarmSize, int intMapSize, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeItemsInChests, int intWallMaterial, string strMoatType) { if (booIncludeWalls) { // drawbridge int intBridgeEnd = booIncludeMoat ? -2 : 5; if (strMoatType == "Lava") { BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 63, 63, intFarmSize + intBridgeEnd, intFarmSize + 13, (int)BlockType.STONE, 2); } else { BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 63, 63, intFarmSize + intBridgeEnd, intFarmSize + 13, (int)BlockType.WOOD_PLANK, 2); } // carve out the entrance/exit BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 64, 67, intFarmSize + 6, intFarmSize + 10, (int)BlockType.AIR, 2); // add the bottom of a portcullis BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 67, 67, intFarmSize + 6, intFarmSize + 6, (int)BlockType.FENCE, 2); // add room for murder holes BlockShapes.MakeSolidBox((intMapSize / 2) - 2, (intMapSize / 2) + 2, 69, 71, intFarmSize + 8, intFarmSize + 9, (int)BlockType.AIR, 2); BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 69, 72, intFarmSize + 8, intFarmSize + 9, (int)BlockType.AIR, 2); BlockHelper.MakeLadder(intMapSize / 2, 69, 72, intFarmSize + 9, 2, intWallMaterial); BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 72, 72, intFarmSize + 8, intFarmSize + 8, intWallMaterial, 2); // murder holes BlockShapes.MakeSolidBox((intMapSize / 2) - 2, (intMapSize / 2) - 2, 68, 68, intFarmSize + 8, intFarmSize + 8, (int)BlockType.AIR, 2); BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 68, 68, intFarmSize + 8, intFarmSize + 8, (int)BlockType.AIR, 2); BlockShapes.MakeSolidBox((intMapSize / 2) + 2, (intMapSize / 2) + 2, 68, 68, intFarmSize + 8, intFarmSize + 8, (int)BlockType.AIR, 2); // chests BlockShapes.MakeBlock((intMapSize / 2) - 4, 69, intFarmSize + 9, (int)BlockType.GRAVEL, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2) + 4, 69, intFarmSize + 9, (int)BlockType.GRAVEL, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2) - 3, 70, intFarmSize + 9, (int)BlockType.AIR, 2, 100, -1); BlockShapes.MakeBlock((intMapSize / 2) + 3, 70, intFarmSize + 9, (int)BlockType.AIR, 2, 100, -1); TileEntityChest tec = new TileEntityChest(); if (booIncludeItemsInChests) { tec.Items[0] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); tec.Items[1] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); tec.Items[2] = BlockHelper.MakeItem(ItemInfo.LavaBucket.ID, 1); } BlockHelper.MakeChest((intMapSize / 2) - 3, 69, intFarmSize + 9, (int)BlockType.GRAVEL, tec, 2); // add torches BlockHelper.MakeTorch((intMapSize / 2) - 1, 70, intFarmSize + 9, intWallMaterial, 2); BlockHelper.MakeTorch((intMapSize / 2) + 1, 70, intFarmSize + 9, intWallMaterial, 2); // link to main roads //BlockShapes.MakeSolidBox((intMapSize / 2) - 1, (intMapSize / 2) + 1, 63, 63, // intFarmSize + 11, intFarmSize + 13, (int)BlockType.DOUBLE_SLAB, 0); } else if (booIncludeMoat) { BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 63, 63, intFarmSize - 2, intFarmSize + 6, (int)BlockType.STONE, 2); } }
private static void MakeLevel(BetaWorld world, BlockManager bm, int intDepth, int intMineshaftSize) { strResourceNames = ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "names").Split(','); intResourceChances = StringArrayToIntArray( ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "chances").Split(',')); int intTorchChance = Convert.ToInt32(ValueFromXMLElement(Path.Combine("Resources", "MineshaftChests.xml"), "level" + intDepth, "torch_chance")); int[,] intMap = new int[intMineshaftSize, intMineshaftSize]; int intXPosOriginal = intMap.GetLength(0) / 2; int intZPosOriginal = intMap.GetLength(1) / 2; int[,] intArea = new int[intMap.GetLength(0) / MULTIPLIER, intMap.GetLength(1) / MULTIPLIER]; int intXPos = intXPosOriginal / MULTIPLIER; int intZPos = intZPosOriginal / MULTIPLIER; intArea[intXPos, intZPos] = 1; CreateRouteXPlus(intArea, intXPos + 1, intZPos, 0); CreateRouteZPlus(intArea, intXPos, intZPos + 1, 1); CreateRouteXMinus(intArea, intXPos - 1, intZPos, 2); CreateRouteZMinus(intArea, intXPos, intZPos - 1, 3); int intOffsetX = (intXPosOriginal - (intXPos * MULTIPLIER)) - 2; int intOffsetZ = (intZPosOriginal - (intZPos * MULTIPLIER)) - 2; int intGhostX = 0, intGhostZ = 0; bool booGhost = false; if (intDepth == 7) { for (int x = 1; x < intArea.GetLength(0) - 1 && !booGhost; x++) { for (int z = 1; z < intArea.GetLength(1) - 1 && !booGhost; z++) { if (intArea[x, z] == 1 && intArea[x + 1, z] == 0 && intArea[x - 1, z] == 0 && intArea[x, z + 1] == 0) { intArea[x, z] = 9; intGhostX = (x * MULTIPLIER) + intOffsetX; intGhostZ = (z * MULTIPLIER) + intOffsetZ; booGhost = true; } } } } for (int x = 4; x < intMap.GetLength(0) - 4; x++) { for (int z = 4; z < intMap.GetLength(1) - 4; z++) { if (intArea.GetLength(0) > x / MULTIPLIER && intArea.GetLength(1) > z / MULTIPLIER) { if (intMap[x + intOffsetX, z + intOffsetZ] < 4) { intMap[x + intOffsetX, z + intOffsetZ] = intArea[x / MULTIPLIER, z / MULTIPLIER]; } } if ((x + 3) % 5 == 0 && (z + 3) % 5 == 0 && intArea[x / MULTIPLIER, z / MULTIPLIER] == 1) { if (intArea[(x / MULTIPLIER) + 1, z / MULTIPLIER] == 1) { for (int x2 = 0; x2 < 5; x2++) { if (x2 == 1 || x2 == 3) { intMap[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = 8; intMap[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = 8; } else { intMap[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = 5; intMap[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = 5; } } for (int x2 = 0; x2 <= 5; x2++) { if (intMap[x + intOffsetX + x2, z + intOffsetZ] == 5) { intMap[x + intOffsetX + x2, z + intOffsetZ] = 4; } else { intMap[x + intOffsetX + x2, z + intOffsetZ] = 7; } } } if (intArea[x / MULTIPLIER, (z / MULTIPLIER) + 1] == 1) { for (int z2 = 0; z2 < 5; z2++) { if (z2 == 1 || z2 == 3) { intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = 8; intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = 8; } else { intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = 5; intMap[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = 5; } } for (int z2 = 0; z2 <= 5; z2++) { if (intMap[x + intOffsetX, z + intOffsetZ + z2] == 5) { intMap[x + intOffsetX, z + intOffsetZ + z2] = 4; } else { intMap[x + intOffsetX, z + intOffsetZ + z2] = 7; } } } if (intArea[x / MULTIPLIER, z / MULTIPLIER] == 1) { MakeChestAndOrTorch(intArea, intMap, (x - 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX - 2, z + intOffsetZ); MakeChestAndOrTorch(intArea, intMap, (x + 3) / MULTIPLIER, z / MULTIPLIER, x + intOffsetX + 2, z + intOffsetZ); MakeChestAndOrTorch(intArea, intMap, x / MULTIPLIER, (z - 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ - 2); MakeChestAndOrTorch(intArea, intMap, x / MULTIPLIER, (z + 3) / MULTIPLIER, x + intOffsetX, z + intOffsetZ + 2); } } } } intMap[intXPosOriginal, intZPosOriginal] = 3; int intSupportMaterial = RandomHelper.RandomNumber((int)BlockType.WOOD, (int)BlockType.WOOD_PLANK, (int)BlockType.FENCE); intSupportMaterial = (int)BlockType.WOOD_PLANK; for (int x = 0; x < intMap.GetLength(0); x++) { for (int z = 0; z < intMap.GetLength(1); z++) { switch (intMap[x, z]) { case 0: break; case 1: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } break; case 9: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * (intDepth - 1)); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } break; case 2: break; case 4: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.GRAVEL); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.RAILS); } else if (y == 40 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } } break; case 5: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } break; case 6: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 39 - (5 * intDepth) && RandomHelper.NextDouble() > 0.9) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.CHEST); MakeChestItems(bm, x + intBlockStart, y, z + intBlockStart); } else if (y == 41 - (5 * intDepth) && RandomHelper.NextDouble() < (double)intTorchChance / 100) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.TORCH); if (intMap[x - 1, z] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 1); } else if (intMap[x + 1, z] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 2); } else if (intMap[x, z - 1] == 0) { bm.SetData(x + intBlockStart, y, z + intBlockStart, 3); } else { bm.SetData(x + intBlockStart, y, z + intBlockStart, 4); } } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; case 7: case 3: for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 38 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.GRAVEL); } else if (y == 39 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.RAILS); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; case 8: for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++) { if (y == 41 - (5 * intDepth)) { bm.SetID(x + intBlockStart, y, z + intBlockStart, intSupportMaterial); } else { bm.SetID(x + intBlockStart, y, z + intBlockStart, (int)BlockType.AIR); } } break; } } } for (int x = 0; x < intMap.GetLength(0); x++) { for (int z = 0; z < intMap.GetLength(1); z++) { switch (intMap[x, z]) { case 3: case 4: case 7: BlockHelper.MakeRail(x + intBlockStart, 39 - (5 * intDepth), z + intBlockStart); break; } } } if (booGhost) { BlockShapes.MakeSolidBox(intBlockStart + intGhostX - 1, intBlockStart + intGhostX + 5, 39 - (5 * intDepth), 46 - (5 * intDepth), intBlockStart + intGhostZ - 1, intBlockStart + intGhostZ + 5, (int)BlockType.AIR, 0); for (int x = intBlockStart + intGhostX; x <= intBlockStart + intGhostX + 4; x++) { for (int y = 39 - (5 * intDepth); y <= 44 - (5 * intDepth); y++) { for (int z = intBlockStart + intGhostZ + 3; z <= intBlockStart + intGhostZ + 4; z++) { bm.SetID(x, y, z, (int)BlockType.WOOL); bm.SetData(x, y, z, (int)WoolColor.WHITE); } } } bm.SetID(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.TORCH); bm.SetID(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 0, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)TorchOrientation.FLOOR); bm.SetData(intBlockStart + intGhostX + 4, 44 - (5 * intDepth), intBlockStart + intGhostZ + 4, (int)TorchOrientation.FLOOR); bm.SetID(intBlockStart + intGhostX + 1, 43 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.OBSIDIAN); bm.SetID(intBlockStart + intGhostX + 3, 43 - (5 * intDepth), intBlockStart + intGhostZ + 3, (int)BlockType.OBSIDIAN); bm.SetID(intBlockStart + intGhostX + 1, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 1, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)TorchOrientation.FLOOR); bm.SetID(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.SIGN_POST); bm.SetData(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)SignPostOrientation.EAST); BlockHelper.MakeSignPost(intBlockStart + intGhostX + 2, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, "Ghostdancer:|Victim of the|Creeper Rush|of '09"); bm.SetID(intBlockStart + intGhostX + 3, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)BlockType.TORCH); bm.SetData(intBlockStart + intGhostX + 3, 39 - (5 * intDepth), intBlockStart + intGhostZ + 2, (int)TorchOrientation.FLOOR); } world.Save(); //File.WriteAllText("c:\\output.txt", TwoDimensionalArrayToString(intMap)); }
public static bool[,] MakeSewers(int intFarmSize, int intMapSize, int intPlotSize) { int intPlots = 1 + ((intMapSize - ((intFarmSize + 16) * 2)) / intPlotSize); bool[,] booNewSewerEntrances = MakeSewerEntrances(intPlots, false); Maze maze = new Maze(); // 51, 43, 35, 27, 19, 11, 3 for (int y = 3; y <= 51; y += 8) { bool[,] booOldSewerEntrances = booNewSewerEntrances; booNewSewerEntrances = MakeSewerEntrances(intPlots, y == 51); bool[,] booMaze = maze.GenerateMaze((intPlots * 2) + 1, (intPlots * 2) + 1); booMaze = maze.CreateLoops(booMaze, booMaze.GetLength(0) / 4); if (y == 3) { booMaze = maze.DeleteDeadEnds(booMaze, booNewSewerEntrances); } else { booMaze = maze.DeleteDeadEnds(booMaze, MergeBooleanArrays(booNewSewerEntrances, booOldSewerEntrances)); } for (int x = 0; x < booMaze.GetUpperBound(0); x++) { for (int z = 0; z < booMaze.GetUpperBound(1); z++) { if (booMaze[x, z]) { MakeSewerSection(booMaze, x, z, intFarmSize + 18 + (x * intPlotSize / 2), intFarmSize + 18 + (z * intPlotSize / 2), y, intPlotSize); } } } for (int x = 0; x < booMaze.GetUpperBound(0); x++) { for (int z = 0; z < booMaze.GetUpperBound(1); z++) { if (booMaze[x, z]) { if (y > 3 && x % 2 == 1 && z % 2 == 1 && booOldSewerEntrances[(x - 1) / 2, (z - 1) / 2]) { BlockShapes.MakeSolidBox(intFarmSize + 18 + (x * intPlotSize / 2) - 1, intFarmSize + 18 + (x * intPlotSize / 2) + 1, y - 7, y + 1, intFarmSize + 18 + (z * intPlotSize / 2) - 1, intFarmSize + 18 + (z * intPlotSize / 2) + 1, (int)BlockType.AIR); BlockShapes.MakeHollowLayers(intFarmSize + 18 + (x * intPlotSize / 2) - 1, intFarmSize + 18 + (x * intPlotSize / 2) + 1, y, y, intFarmSize + 18 + (z * intPlotSize / 2) - 1, intFarmSize + 18 + (z * intPlotSize / 2) + 1, (int)BlockType.STONE); BlockShapes.MakeSolidBox(intFarmSize + 18 + (x * intPlotSize / 2), intFarmSize + 18 + (x * intPlotSize / 2), y - 7, y + 1, intFarmSize + 18 + (z * intPlotSize / 2) + 1, intFarmSize + 18 + (z * intPlotSize / 2) + 1, (int)BlockType.STONE); BlockHelper.MakeLadder(intFarmSize + 18 + (x * intPlotSize / 2), y - 7, y + 1, intFarmSize + 18 + (z * intPlotSize / 2)); } } } } } return(booNewSewerEntrances); }
public static void InsertBuilding(BlockManager bmDest, int[,] intArea, int intBlockStart, int x1dest, int z1dest, Building bldInsert) { lstInstanceSigns.Clear(); int intHighestSourceY = 0; int intSourceX = 0, intSourceZ = 0; int intRotate = -1; for (int intDistance = 0; intRotate == -1 && intDistance < 10; intDistance++) { for (int intCheck = 0; intRotate == -1 && intCheck <= bldInsert.intSize; intCheck++) { if (CheckArea(intArea, x1dest + intCheck, z1dest - intDistance) == 1) { intRotate = 0; } else if (CheckArea(intArea, x1dest - intDistance, z1dest + intCheck) == 1) { intRotate = 1; } else if (CheckArea(intArea, x1dest + bldInsert.intSize + intDistance, z1dest + intCheck) == 1) { intRotate = 2; } else if (CheckArea(intArea, x1dest + intCheck, z1dest + bldInsert.intSize + intDistance) == 1) { intRotate = 3; } } } if (intRotate == -1) { intRotate = RandomHelper.Next(4); } for (int x = 0; x < bldInsert.intSize; x++) { for (int z = 0; z < bldInsert.intSize; z++) { switch (intRotate) { case 0: intSourceX = x; intSourceZ = z; break; case 1: intSourceX = (bldInsert.intSize - 1) - z; intSourceZ = x; break; case 2: intSourceX = z; intSourceZ = (bldInsert.intSize - 1) - x; break; case 3: intSourceX = (bldInsert.intSize - 1) - x; intSourceZ = (bldInsert.intSize - 1) - z; break; } int intSourceEndY; for (intSourceEndY = 128; intSourceEndY > 64; intSourceEndY--) { if (bmSource.GetID(intSourceX + bldInsert.intSourceX, intSourceEndY, intSourceZ + bldInsert.intSourceZ) != (int)BlockType.AIR) { break; } } if (intSourceEndY > intHighestSourceY) { intHighestSourceY = intSourceEndY; } for (int y = bldInsert.intSourceStartY; y <= intSourceEndY; y++) { if (y != 64 || bmDest.GetID(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest) == (int)BlockType.AIR) { int intBlockID = bmSource.GetID(intSourceX + bldInsert.intSourceX, y, intSourceZ + bldInsert.intSourceZ); int intBlockData = bmSource.GetData(intSourceX + bldInsert.intSourceX, y, intSourceZ + bldInsert.intSourceZ); bmDest.SetID(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, intBlockID); bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, intBlockData); foreach (EntityPainting entPainting in AllEntityPainting) { if (entPainting.TileX == intSourceX + bldInsert.intSourceX && entPainting.TileY == y && entPainting.TileZ == intSourceZ + bldInsert.intSourceZ) { EntityPainting entNewPainting = (EntityPainting)entPainting.Copy(); entNewPainting.TileX = intBlockStart + x + x1dest; entNewPainting.TileY = y; entNewPainting.TileZ = intBlockStart + z + z1dest; entNewPainting.Position.X = entNewPainting.TileX; entNewPainting.Position.Z = entNewPainting.TileZ; entNewPainting.Direction = BlockHelper.RotatePortrait(entPainting.Direction, intRotate); ChunkRef chunkBuilding = cmDest.GetChunkRef((intBlockStart + x + x1dest) / 16, (intBlockStart + z + z1dest) / 16); chunkBuilding.Entities.Add(entNewPainting); cmDest.Save(); } } #region Rotation if (intRotate > 0) { switch (intBlockID) { case (int)BlockType.SIGN_POST: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateSignPost(intBlockData, intRotate)); break; case (int)BlockType.STONE_BUTTON: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateButton(intBlockData, intRotate)); break; case (int)BlockType.PUMPKIN: case (int)BlockType.JACK_O_LANTERN: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotatePumpkin(intBlockData, intRotate)); break; case (int)BlockType.IRON_DOOR: case (int)BlockType.WOOD_DOOR: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateDoor(intBlockData, intRotate)); break; case (int)BlockType.TRAPDOOR: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateTrapdoor(intBlockData, intRotate)); break; case (int)BlockType.BED: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateBed(intBlockData, intRotate)); break; case (int)BlockType.REDSTONE_TORCH_OFF: case (int)BlockType.REDSTONE_TORCH_ON: case (int)BlockType.TORCH: case (int)BlockType.LEVER: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateTorchOrLever(intBlockData, intRotate)); break; case (int)BlockType.WALL_SIGN: case (int)BlockType.LADDER: case (int)BlockType.DISPENSER: case (int)BlockType.FURNACE: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateWallSignOrLadderOrFurnanceOrDispenser(intBlockData, intRotate)); break; case (int)BlockType.COBBLESTONE_STAIRS: case (int)BlockType.WOOD_STAIRS: bmDest.SetData(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, BlockHelper.RotateStairs(intBlockData, intRotate)); break; } } #endregion #region Handle entities switch (intBlockID) { case (int)BlockType.CHEST: TileEntityChest tec = (TileEntityChest)bmSource.GetTileEntity(intSourceX + bldInsert.intSourceX, y, intSourceZ + bldInsert.intSourceZ); if (tec.Items[0] != null) { if (tec.Items[0].ID == ItemInfo.Paper.ID && tec.Items[0].Count == 3) { tec = MakeHouseChest(); } } bmDest.SetTileEntity(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, tec); break; case (int)BlockType.FURNACE: case (int)BlockType.MONSTER_SPAWNER: case (int)BlockType.NOTE_BLOCK: case (int)BlockType.JUKEBOX: case (int)BlockType.TRAPDOOR: bmDest.SetTileEntity(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, bmSource.GetTileEntity(intSourceX + bldInsert.intSourceX, y, intSourceZ + bldInsert.intSourceZ)); break; case (int)BlockType.SIGN_POST: case (int)BlockType.WALL_SIGN: #region Determine sign text int intUniqueType = 0; TileEntitySign tes = (TileEntitySign)bmSource.GetTileEntity(intSourceX + bldInsert.intSourceX, y, intSourceZ + bldInsert.intSourceZ); string strSourceSign = tes.Text1 + " " + tes.Text2 + " " + tes.Text3 + " " + tes.Text4; switch (strSourceSign.Substring(0, 1)) { case "2": case "1": case "0": intUniqueType = Convert.ToInt32(strSourceSign.Substring(0, 1)); strSourceSign = strSourceSign.Remove(0, 1); break; default: intUniqueType = 0; break; } if (strSourceSign.Contains("[")) { string strSignText; bool booDuplicate; int intFail = 0; do { strSignText = SignText(strSourceSign); booDuplicate = false; switch (intUniqueType) { case 1: // unique by instance booDuplicate = lstInstanceSigns.Contains(strSignText); break; case 2: // unique by city booDuplicate = lstCitySigns.Contains(strSignText); break; } intFail++; if (intFail > 100) { Debug.WriteLine("Could not make a unique sign for " + strSourceSign); booDuplicate = false; } } while (booDuplicate); lstCitySigns.Add(strSignText); lstInstanceSigns.Add(strSignText); string[] strRandomSign = BlockHelper.TextToSign(ConvertToSignText(strSignText)); tes.Text1 = strRandomSign[0]; tes.Text2 = strRandomSign[1]; tes.Text3 = strRandomSign[2]; tes.Text4 = strRandomSign[3]; } bmDest.SetTileEntity(intBlockStart + x + x1dest, y, intBlockStart + z + z1dest, tes); break; #endregion } #endregion } } } } }