private static void MakeChestItems(BlockManager bm, int x, int y, int z, int[] intResourceChances, string[] strResourceNames) { string strResource = strResourceNames[RandomHelper.RandomWeightedNumber(intResourceChances)]; string strAmount; _dictResourceAmounts.TryGetValue(strResource.ToLower(), out strAmount); strAmount = strAmount ?? "1,1"; int intAmount = RandomHelper.Next(Convert.ToInt32(strAmount.Split(',')[0]), Convert.ToInt32(strAmount.Split(',')[1]) + 1); string strBlockID; _dictResourceIDs.TryGetValue(strResource.ToLower(), out strBlockID); TileEntityChest tec = new TileEntityChest(); int intSlot = 0; do { if (intAmount > MINECRAFT_ITEM_STACK_AMOUNT) { tec.Items[intSlot++] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID), MINECRAFT_ITEM_STACK_AMOUNT); } else { tec.Items[intSlot++] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID), intAmount); } intAmount -= MINECRAFT_ITEM_STACK_AMOUNT; } while (intAmount > 0); bm.SetTileEntity(x, y, z, tec); }
private static void MakeGuardChest(BlockManager bm, int x, int y, int z) { TileEntityChest tec = new TileEntityChest(); if (City.HasItemsInChests) { for (int a = 0; a < 5; a++) { tec.Items[a] = BlockHelper.MakeItem(RNG.RandomItem(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 = RNG.RandomItem(ItemInfo.LeatherCap.ID, ItemInfo.ChainHelmet.ID, ItemInfo.IronHelmet.ID); for (int a = 9; a < 18; a++) { // random armour tec.Items[a] = BlockHelper.MakeItem(intArmourStartID + RNG.Next(4), 1); } } bm.SetID(x, y, z, BlockInfo.Chest.ID); bm.SetTileEntity(x, y, z, tec); }
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.DiamondAxe.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); tec.Items[16] = BlockHelper.MakeItem(ItemInfo.RedstoneDust.ID, 64); tec.Items[17] = BlockHelper.MakeItem((int)BlockType.IRON_BLOCK, 64); tec.Items[18] = BlockHelper.MakeItem((int)BlockType.DIAMOND_BLOCK, 64); tec.Items[19] = BlockHelper.MakeItem((int)BlockType.GOLD_BLOCK, 64); bm.SetID(x, y, z, (int)BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
// This function will create a new Block object of type 'Chest', fills it // with random items, and returns it static AlphaBlock BuildChest() { // A default, appropriate TileEntity entry is created AlphaBlock block = new AlphaBlock(BlockType.CHEST); TileEntityChest ent = block.GetTileEntity() as TileEntityChest; // Unless Substrate has a bug, the TileEntity was definitely a TileEntityChest if (ent == null) { Console.WriteLine("Catastrophic"); return(null); } // Loop through each slot in the chest, assign an item // with a probability for (int i = 0; i < ent.Items.Capacity; i++) { if (rand.NextDouble() < 0.3) { // Ask the ItemTable for a random Item type registered with Substrate ItemInfo itype = ItemInfo.GetRandomItem(); // Create the item object, give it an appropriate, random count (items in stack) Item item = new Item(itype.ID); item.Count = 1 + rand.Next(itype.StackSize); // Assign the item to the chest at slot i ent.Items[i] = item; } } // That's all, we've got a loaded chest block ready to be // inserted into a chunk return(block); }
private static void MakeSewerEntrance(BlockManager bm, int x, int z, int intPlotSize) { // path BlockShapes.MakeHollowLayers(x, x + 8, 63, 63, z, z + intPlotSize, (int)BlockType.DOUBLE_SLAB); // building BlockShapes.MakeHollowBox(x + 2, x + 6, 63, 67, z + 2, z + 6, (int)BlockType.STONE); // doorway BlockShapes.MakeSolidBox(x + 4, x + 4, 64, 65, z + 2, z + 2, (int)BlockType.AIR); // tunnel down BlockShapes.MakeSolidBox(x + 4, x + 4, 55, 63, z + 4, z + 4, (int)BlockType.AIR); // ladder back BlockShapes.MakeSolidBox(x + 4, x + 4, 52, 55, z + 5, z + 5, (int)BlockType.STONE); // ladder rungs BlockHelper.MakeLadder(x + 4, 52, 63, z + 4); // hatch bm.SetID(x + 4, 64, z + 4, (int)BlockType.TRAPDOOR); bm.SetData(x + 4, 64, z + 4, 2); // chest with torches bm.SetID(x + 5, 64, z + 5, (int)BlockType.CHEST); TileEntityChest tec = new TileEntityChest(); tec.Items[0] = BlockHelper.MakeItem((int)BlockType.REDSTONE_TORCH_ON, 64); tec.Items[1] = BlockHelper.MakeItem((int)BlockType.TORCH, 32); bm.SetTileEntity(x + 5, 64, z + 5, tec); // sign BlockHelper.MakeSign(x + 4, 66, z + 1, "Sewers||Currently|empty!", (int)BlockType.STONE); }
private static TileEntityChest MakeHouseChest() { TileEntityChest tec = new TileEntityChest(); for (int intItems = RandomHelper.Next(4, 8); intItems >= 0; intItems--) { tec.Items[intItems] = BlockHelper.MakeItem(RandomHelper.RandomNumber( ItemInfo.Apple.ID, ItemInfo.Book.ID, ItemInfo.Bowl.ID, ItemInfo.Bread.ID, ItemInfo.Cake.ID, ItemInfo.Clock.ID, ItemInfo.Compass.ID, ItemInfo.Cookie.ID, ItemInfo.Diamond.ID, ItemInfo.Egg.ID, ItemInfo.Feather.ID, ItemInfo.FishingRod.ID, ItemInfo.GoldMusicDisc.ID, ItemInfo.GreenMusicDisc.ID, ItemInfo.Paper.ID, ItemInfo.Saddle.ID, ItemInfo.String.ID, ItemInfo.GoldIngot.ID, ItemInfo.IronIngot.ID, BlockType.TORCH, ItemInfo.FlintAndSteel.ID, ItemInfo.Bow.ID, ItemInfo.IronSword.ID, ItemInfo.Shears.ID), 1); } return(tec); }
private bool Func_50078_a(World par1World, int par2, int par3, int par4) { int i = par1World.GetBlockId(par2, par3, par4); int j = par1World.GetBlockMetadata(par2, par3, par4); if (i == Block.Chest.BlockID) { TileEntityChest tileentitychest = (TileEntityChest)par1World.GetBlockTileEntity(par2, par3, par4); if (tileentitychest.NumUsingPlayers < 1) { return(true); } } else { if (i == Block.StoneOvenActive.BlockID) { return(true); } if (i == Block.Bed.BlockID && !BlockBed.IsBlockFootOfBed(j)) { return(true); } } return(false); }
private static void MakeHelperChest(BlockManager bm, int x, int y, int z) { TileEntityChest tec = new TileEntityChest(); tec.Items[0] = BlockHelper.MakeItem(ItemInfo.DiamondSword.ID, 1); tec.Items[1] = BlockHelper.MakeItem(ItemInfo.DiamondPickaxe.ID, 1); tec.Items[2] = BlockHelper.MakeItem(ItemInfo.DiamondShovel.ID, 1); tec.Items[3] = BlockHelper.MakeItem(ItemInfo.DiamondAxe.ID, 1); tec.Items[4] = BlockHelper.MakeItem(BlockInfo.Ladder.ID, 64); tec.Items[5] = BlockHelper.MakeItem(BlockInfo.Dirt.ID, 64); tec.Items[6] = BlockHelper.MakeItem(BlockInfo.Sand.ID, 64); tec.Items[7] = BlockHelper.MakeItem(BlockInfo.CraftTable.ID, 64); tec.Items[8] = BlockHelper.MakeItem(BlockInfo.Furnace.ID, 64); tec.Items[9] = BlockHelper.MakeItem(ItemInfo.Bread.ID, 64); tec.Items[10] = BlockHelper.MakeItem(BlockInfo.Torch.ID, 64); tec.Items[11] = BlockHelper.MakeItem(BlockInfo.Stone.ID, 64); tec.Items[12] = BlockHelper.MakeItem(BlockInfo.Chest.ID, 64); tec.Items[13] = BlockHelper.MakeItem(BlockInfo.Glass.ID, 64); tec.Items[14] = BlockHelper.MakeItem(BlockInfo.Wood.ID, 64); tec.Items[15] = BlockHelper.MakeItem(ItemInfo.Cookie.ID, 64); tec.Items[16] = BlockHelper.MakeItem(ItemInfo.RedstoneDust.ID, 64); tec.Items[17] = BlockHelper.MakeItem(BlockInfo.IronBlock.ID, 64); tec.Items[18] = BlockHelper.MakeItem(BlockInfo.DiamondBlock.ID, 64); tec.Items[19] = BlockHelper.MakeItem(BlockInfo.GoldBlock.ID, 64); bm.SetID(x, y, z, BlockInfo.Chest.ID); bm.SetTileEntity(x, y, z, tec); }
public override bool onRightClick(World world, EntityPlayer player, ItemStack heldStack, BlockPos pos, int meta, Direction clickedFace, Vector3 clickedPos) { if (!world.getBlock(pos.move(Direction.UP)).isSolid) { TileEntityChest chest = ((TileEntityChest)world.getTileEntity(pos)); player.contManager.openContainer(player, ContainerManager.containerChest, chest.chestData); //chest.chestOpen.setOpen(true); return(true); } return(false); }
/// <summary> /// performs the check for adjacent chests to determine if this chest is double or not. /// </summary> public virtual void CheckForAdjacentChests() { if (AdjacentChestChecked) { return; } AdjacentChestChecked = true; AdjacentChestZNeg = null; AdjacentChestXPos = null; AdjacentChestXNeg = null; AdjacentChestZPos = null; if (WorldObj.GetBlockId(XCoord - 1, YCoord, ZCoord) == Block.Chest.BlockID) { AdjacentChestXNeg = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord - 1, YCoord, ZCoord); } if (WorldObj.GetBlockId(XCoord + 1, YCoord, ZCoord) == Block.Chest.BlockID) { AdjacentChestXPos = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord + 1, YCoord, ZCoord); } if (WorldObj.GetBlockId(XCoord, YCoord, ZCoord - 1) == Block.Chest.BlockID) { AdjacentChestZNeg = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord, YCoord, ZCoord - 1); } if (WorldObj.GetBlockId(XCoord, YCoord, ZCoord + 1) == Block.Chest.BlockID) { AdjacentChestZPos = (TileEntityChest)WorldObj.GetBlockTileEntity(XCoord, YCoord, ZCoord + 1); } if (AdjacentChestZNeg != null) { AdjacentChestZNeg.UpdateContainingBlockInfo(); } if (AdjacentChestZPos != null) { AdjacentChestZPos.UpdateContainingBlockInfo(); } if (AdjacentChestXPos != null) { AdjacentChestXPos.UpdateContainingBlockInfo(); } if (AdjacentChestXNeg != null) { AdjacentChestXNeg.UpdateContainingBlockInfo(); } }
public static void MakeDrawbridges(BlockManager bm, int intFarmSize, int intMapSize, bool booIncludeMoat, bool booIncludeWalls) { if (booIncludeWalls) { // drawbridge int intBridgeEnd = booIncludeMoat ? -2 : 5; BlockShapes.MakeSolidBox((intMapSize / 2) - 2, intMapSize / 2, 63, 63, intFarmSize + intBridgeEnd, intFarmSize + 13, (int)BlockType.STONE, 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, (int)BlockType.STONE); BlockShapes.MakeSolidBox(intMapSize / 2, intMapSize / 2, 72, 72, intFarmSize + 8, intFarmSize + 8, (int)BlockType.STONE, 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(); 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, (int)BlockType.STONE, 2); BlockHelper.MakeTorch((intMapSize / 2) + 1, 70, intFarmSize + 9, (int)BlockType.STONE, 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 int FixPotions(ref TileEntityChest chest) { int fixedPotions = 0; for (int slot = 0; slot <= chest.Items.Capacity; slot++) { Item item = chest.Items[slot]; if (item != null && item.ID == ItemInfo.Potion.NameID && FixPotion(ref item)) { fixedPotions++; } } return(fixedPotions); }
public static void MakeChest(int x, int y, int z, int intBlockAgainst, TileEntityChest tec, int intMirror) { BlockShapes.MakeBlock(x, y, z, BlockType.CHEST, BlockHelper.BlockDirection(x, y, z, intBlockAgainst)); _bmDest.SetTileEntity(x, y, z, tec); if (intMirror > 0) { MakeChest(_intMapSize - x, y, z, intBlockAgainst, tec, 0); MakeChest(x, y, _intMapSize - z, intBlockAgainst, tec, 0); MakeChest(_intMapSize - x, y, _intMapSize - z, intBlockAgainst, tec, 0); if (intMirror == 2) { MakeChest(z, y, x, intBlockAgainst, tec, 1); } } }
public static void MakeChest(int x, int y, int z, int intBlockAgainst, TileEntityChest tec, int intMirror) { BlockShapes.MakeBlock(x, y, z, BlockInfo.Chest.ID, BlockHelper.BlockDirection(x, y, z, intBlockAgainst)); _bmDest.SetTileEntity(x, y, z, tec); if (intMirror > 0) { MakeChest(City.MapLength - x, y, z, intBlockAgainst, tec, 0); MakeChest(x, y, City.MapLength - z, intBlockAgainst, tec, 0); MakeChest(City.MapLength - x, y, City.MapLength - z, intBlockAgainst, tec, 0); if (intMirror == 2) { MakeChest(z, y, x, intBlockAgainst, tec, 1); } } }
private static void MakeChestItems(BlockManager bm, int x, int y, int z) { string strResource = strResourceNames[RandomHelper.RandomWeightedNumber(intResourceChances)]; string strAmount; dictResourceAmounts.TryGetValue(strResource.ToLower(), out strAmount); strAmount = strAmount ?? "1,1"; int intAmount = RandomHelper.Next(Convert.ToInt32(strAmount.Split(',')[0]), Convert.ToInt32(strAmount.Split(',')[1]) + 1); string strBlockID; dictResourceIDs.TryGetValue(strResource.ToLower(), out strBlockID); TileEntityChest tec = new TileEntityChest(); tec.Items[0] = BlockHelper.MakeItem(Convert.ToInt32(strBlockID), intAmount); bm.SetTileEntity(x, y, z, tec); }
private static void MakeGuardChest(int x, int y, int z) { TileEntityChest tec = new TileEntityChest(); // todo: replace numbers with constants when next version of Substrate is released for (int a = 0; a < 5; a++) { tec.Items[a] = MakeItem(SelectRandomNumber(267, 268, 272), 1); // random sword (iron, wood, stone) } tec.Items[6] = MakeItem(261, 1); // crossbow tec.Items[7] = MakeItem(262, 64); // arrows int intArmourStartID = SelectRandomNumber(298, 302, 306); for (int a = 9; a < 18; a++) { tec.Items[a] = MakeItem(SelectRandomNumber(intArmourStartID, intArmourStartID + 1, intArmourStartID + 2, intArmourStartID + 3), 1); // random armour } bm.SetID(x, y, z, (int)BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
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 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); }
public ChestItemRenderHelper() { Field_35610_b = new TileEntityChest(); }
public static void InsertBuilding(BlockManager bmDest, int[,] intArea, int intBlockStart, int x1dest, int z1dest, Building bldInsert, int y1dest) { List <Spawner> lstSpawners = new List <Spawner>(); _lstInstanceSigns.Clear(); int intRandomWoolColour = RandomHelper.Next(16); int intSourceX = 0, intSourceZ = 0; int intRotate = -1; if (bldInsert.btThis == BuildingTypes.MineshaftSection) { intRotate = 0; } else { for (int intDistance = 0; intRotate == -1 && intDistance < 10; intDistance++) { for (int intCheck = 0; intRotate == -1 && intCheck <= bldInsert.intSizeX; 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.intSizeX + intDistance, z1dest + intCheck) == 1) { intRotate = 2; } else if (CheckArea(intArea, x1dest + intCheck, z1dest + bldInsert.intSizeZ + intDistance) == 1) { intRotate = 3; } } } } if (intRotate == -1) { intRotate = RandomHelper.Next(4); } for (int x = 0; x < bldInsert.intSizeX; x++) { for (int z = 0; z < bldInsert.intSizeZ; z++) { switch (intRotate) { case 0: intSourceX = x; intSourceZ = z; break; case 1: intSourceX = (bldInsert.intSizeX - 1) - z; intSourceZ = x; break; case 2: intSourceX = z; intSourceZ = (bldInsert.intSizeZ - 1) - x; break; case 3: intSourceX = (bldInsert.intSizeX - 1) - x; intSourceZ = (bldInsert.intSizeZ - 1) - z; break; default: Debug.Fail("Invalid switch result"); break; } int intSourceEndY; if (bldInsert.btThis == BuildingTypes.MineshaftSection) { intSourceEndY = bldInsert.intSourceStartY + 4; } else { for (intSourceEndY = 128; intSourceEndY > 64; intSourceEndY--) { if (_bmSource.GetID(intSourceX + bldInsert.intSourceX, intSourceEndY, intSourceZ + bldInsert.intSourceZ) != BlockType.AIR) { break; } } } for (int ySource = bldInsert.intSourceStartY; ySource <= intSourceEndY; ySource++) { int yDest = ySource; if (bldInsert.btThis == BuildingTypes.MineshaftSection) { yDest = y1dest + (ySource - bldInsert.intSourceStartY); } if (bldInsert.btThis == BuildingTypes.MineshaftSection || ((yDest != 64 || bmDest.GetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest) == BlockType.AIR) && bmDest.GetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest) != BlockType.WOOD_PLANK)) { int intBlockID = _bmSource.GetID(intSourceX + bldInsert.intSourceX, ySource, intSourceZ + bldInsert.intSourceZ); int intBlockData = _bmSource.GetData(intSourceX + bldInsert.intSourceX, ySource, intSourceZ + bldInsert.intSourceZ); bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, intBlockID); bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, intBlockData); #region import paintings // todo: test for mineshaft features foreach (EntityPainting entPainting in _AllEntityPainting) { if (entPainting.TileX == intSourceX + bldInsert.intSourceX && entPainting.TileY == ySource && entPainting.TileZ == intSourceZ + bldInsert.intSourceZ) { EntityPainting entNewPainting = (EntityPainting)entPainting.Copy(); entNewPainting.TileX = intBlockStart + x + x1dest; entNewPainting.TileY = yDest; 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(); } } #endregion #region Rotation if (intRotate > 0) { switch (intBlockID) { case BlockType.PORTAL: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotatePortal(intBlockData, intRotate)); break; case BlockType.SIGN_POST: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateSignPost(intBlockData, intRotate)); break; case BlockType.STONE_BUTTON: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateButton(intBlockData, intRotate)); break; case BlockType.PUMPKIN: case BlockType.JACK_O_LANTERN: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotatePumpkin(intBlockData, intRotate)); break; case BlockType.IRON_DOOR: case BlockType.WOOD_DOOR: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateDoor(intBlockData, intRotate)); break; case BlockType.TRAPDOOR: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateTrapdoor(intBlockData, intRotate)); break; case BlockType.BED: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateBed(intBlockData, intRotate)); break; case BlockType.REDSTONE_TORCH_OFF: case BlockType.REDSTONE_TORCH_ON: case BlockType.TORCH: case BlockType.LEVER: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateTorchOrLever(intBlockData, intRotate)); break; case BlockType.WALL_SIGN: case BlockType.LADDER: case BlockType.DISPENSER: case BlockType.FURNACE: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateWallSignOrLadderOrFurnanceOrDispenser( intBlockData, intRotate)); break; case BlockType.COBBLESTONE_STAIRS: case BlockType.WOOD_STAIRS: bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockHelper.RotateStairs(intBlockData, intRotate)); break; // no need for a default - all other blocks are okay } } #endregion #region Handle entities switch (intBlockID) { case BlockType.SPONGE: bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockType.WOOL); bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, intRandomWoolColour); break; case BlockType.CHEST: TileEntityChest tec = (TileEntityChest)_bmSource.GetTileEntity( intSourceX + bldInsert.intSourceX, ySource, intSourceZ + bldInsert.intSourceZ); if (_booIncludeItemsInChests) { if (tec.Items[0] != null) { if (tec.Items[0].ID == ItemInfo.Paper.ID && tec.Items[0].Count == 3) { tec = MakeHouseChest(); } if (tec.Items[0].ID == ItemInfo.Paper.ID && tec.Items[0].Count == 4) { tec = MakeTreasureChest(); } } } else { tec.Items.ClearAllItems(); } bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tec); break; case BlockType.FURNACE: case BlockType.MONSTER_SPAWNER: case BlockType.NOTE_BLOCK: bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, _bmSource.GetTileEntity(intSourceX + bldInsert.intSourceX, ySource, intSourceZ + bldInsert.intSourceZ)); break; case BlockType.SIGN_POST: case BlockType.WALL_SIGN: #region Determine sign text int intUniqueType = 0; TileEntitySign tes = (TileEntitySign)_bmSource. GetTileEntity(intSourceX + bldInsert.intSourceX, ySource, 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 (tes.Text1.ToLower() == "commentsign" || tes.Text1.ToLower() == "comment sign") { // these exist to give advice to people in the resource world. // so we just remove them from the real world bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockType.AIR); bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, 0); } if (tes.Text1.ToLower() == "spawner" || tes.Text1.ToLower() == "gspawner") { if (!tes.Text2.ToLower().StartsWith("g") || tes.Text2.ToLower() == "[randomenemy]" || _booIncludeGhostdancerSpawners) { Spawner spawnerCurrent = new Spawner(); if (tes.Text2.ToLower() == "[randomenemy]") { if (_booIncludeGhostdancerSpawners) { spawnerCurrent.strEntityID = RandomHelper.RandomString("Creeper", "Skeleton", "Spider", "Zombie", "GGeist", "GGrim"); } else { spawnerCurrent.strEntityID = RandomHelper.RandomString("Creeper", "Skeleton", "Spider", "Zombie"); } } else { spawnerCurrent.strEntityID = tes.Text2; } if (tes.Text3.Split(' ').GetUpperBound(0) == 2) { spawnerCurrent.sy = yDest + Convert.ToInt32(tes.Text3.Split(' ')[1]); spawnerCurrent.sx = 0; spawnerCurrent.sz = 0; switch (intRotate) { case 0: spawnerCurrent.sx = intBlockStart + x + x1dest + (Convert.ToInt32(tes.Text3.Split(' ')[0])); spawnerCurrent.sz = intBlockStart + z + z1dest + (Convert.ToInt32(tes.Text3.Split(' ')[2])); break; case 1: spawnerCurrent.sx = intBlockStart + x + x1dest + (Convert.ToInt32(tes.Text3.Split(' ')[2])); spawnerCurrent.sz = intBlockStart + z + z1dest + (-1 * Convert.ToInt32(tes.Text3.Split(' ')[0])); break; case 2: spawnerCurrent.sx = intBlockStart + x + x1dest + (-1 * Convert.ToInt32(tes.Text3.Split(' ')[2])); spawnerCurrent.sz = intBlockStart + z + z1dest + (Convert.ToInt32(tes.Text3.Split(' ')[0])); break; case 3: spawnerCurrent.sx = intBlockStart + x + x1dest + (-1 * Convert.ToInt32(tes.Text3.Split(' ')[0])); spawnerCurrent.sz = intBlockStart + z + z1dest + (-1 * Convert.ToInt32(tes.Text3.Split(' ')[2])); break; } } else { spawnerCurrent.sx = intBlockStart + x + x1dest; spawnerCurrent.sy = yDest - 2; spawnerCurrent.sz = intBlockStart + z + z1dest; } if (tes.Text4.ToLower() == "no") { spawnerCurrent.booGrass = false; } else if (tes.Text4.Split(' ').GetUpperBound(0) == 2) { spawnerCurrent.gy = yDest + Convert.ToInt32(tes.Text4.Split(' ')[1]); switch (intRotate) { case 0: spawnerCurrent.gx = intBlockStart + x + x1dest + (Convert.ToInt32(tes.Text4.Split(' ')[0])); spawnerCurrent.gz = intBlockStart + z + z1dest + (Convert.ToInt32(tes.Text4.Split(' ')[2])); break; case 1: spawnerCurrent.gx = intBlockStart + x + x1dest + (-1 * Convert.ToInt32(tes.Text4.Split(' ')[2])); spawnerCurrent.gz = intBlockStart + z + z1dest + (Convert.ToInt32(tes.Text4.Split(' ')[0])); break; case 2: spawnerCurrent.gx = intBlockStart + x + x1dest + (Convert.ToInt32(tes.Text4.Split(' ')[2])); spawnerCurrent.gz = intBlockStart + z + z1dest + (-1 * Convert.ToInt32(tes.Text4.Split(' ')[0])); break; case 3: spawnerCurrent.gx = intBlockStart + x + x1dest + (-1 * Convert.ToInt32(tes.Text4.Split(' ')[0])); spawnerCurrent.gz = intBlockStart + z + z1dest + (-1 * Convert.ToInt32(tes.Text4.Split(' ')[2])); break; } spawnerCurrent.booGrass = true; } else { spawnerCurrent.gx = intBlockStart + x + x1dest; spawnerCurrent.gy = yDest - 1; spawnerCurrent.gz = intBlockStart + z + z1dest; spawnerCurrent.booGrass = true; } lstSpawners.Add(spawnerCurrent); } bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockType.AIR); bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, 0); } else 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; } 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 = Utils.TextToSign(Utils.ConvertStringToSignText(strSignText)); tes.Text1 = strRandomSign[0]; tes.Text2 = strRandomSign[1]; tes.Text3 = strRandomSign[2]; tes.Text4 = strRandomSign[3]; bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tes); } else { bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tes); } break; #endregion // no need for a default - all the other blocks are okay } #endregion } } } } foreach (Spawner spnAdd in lstSpawners) { bmDest.SetID(spnAdd.sx, spnAdd.sy, spnAdd.sz, BlockType.MONSTER_SPAWNER); TileEntityMobSpawner tems = new TileEntityMobSpawner(); tems.EntityID = spnAdd.strEntityID; bmDest.SetTileEntity(spnAdd.sx, spnAdd.sy, spnAdd.sz, tems); if (spnAdd.booGrass) { bmDest.SetID(spnAdd.gx, spnAdd.gy, spnAdd.gz, BlockType.GRASS); } } }
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 MakeDrawbridges(BlockManager bm, int intFarmLength, int intMapLength, bool booIncludeMoat, bool booIncludeWalls, bool booIncludeItemsInChests, int intWallMaterial, string strMoatType, string strCityName) { if (booIncludeWalls) { // drawbridge int intBridgeEnd = booIncludeMoat ? -2 : 5; if (strMoatType == "Lava" || strMoatType == "Fire") { BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 63, 63, intFarmLength + intBridgeEnd, intFarmLength + 13, BlockType.STONE, 2); } else { BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 63, 63, intFarmLength + intBridgeEnd, intFarmLength + 13, BlockType.WOOD_PLANK, 2); } BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 64, 64, intFarmLength + intBridgeEnd, intFarmLength + 13, BlockType.AIR, 2); // carve out the entrance/exit BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 64, 67, intFarmLength + 6, intFarmLength + 10, BlockType.AIR, 2); if (Utils.IsValidSign(strCityName)) { BlockHelper.MakeSign((intMapLength / 2) - 3, 65, intFarmLength + 5, Utils.ConvertStringToSignText(strCityName.Replace("City of ", "City of~")), intWallMaterial, 2); } // add the bottom of a portcullis BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 67, 67, intFarmLength + 6, intFarmLength + 6, BlockType.FENCE, 2); // add room for murder holes BlockShapes.MakeSolidBox((intMapLength / 2) - 2, (intMapLength / 2) + 2, 69, 71, intFarmLength + 8, intFarmLength + 9, BlockType.AIR, 2); BlockShapes.MakeSolidBox(intMapLength / 2, intMapLength / 2, 69, 72, intFarmLength + 8, intFarmLength + 9, BlockType.AIR, 2); BlockHelper.MakeLadder(intMapLength / 2, 69, 72, intFarmLength + 9, 2, intWallMaterial); BlockShapes.MakeSolidBox(intMapLength / 2, intMapLength / 2, 72, 72, intFarmLength + 8, intFarmLength + 8, intWallMaterial, 2); // murder holes BlockShapes.MakeSolidBox((intMapLength / 2) - 2, (intMapLength / 2) - 2, 68, 68, intFarmLength + 8, intFarmLength + 8, BlockType.AIR, 2); BlockShapes.MakeSolidBox(intMapLength / 2, intMapLength / 2, 68, 68, intFarmLength + 8, intFarmLength + 8, BlockType.AIR, 2); BlockShapes.MakeSolidBox((intMapLength / 2) + 2, (intMapLength / 2) + 2, 68, 68, intFarmLength + 8, intFarmLength + 8, BlockType.AIR, 2); // chests BlockShapes.MakeBlock((intMapLength / 2) - 4, 69, intFarmLength + 9, BlockType.GRAVEL, 2, 100, -1); BlockShapes.MakeBlock((intMapLength / 2) + 4, 69, intFarmLength + 9, BlockType.GRAVEL, 2, 100, -1); BlockShapes.MakeBlock((intMapLength / 2) - 3, 70, intFarmLength + 9, BlockType.AIR, 2, 100, -1); BlockShapes.MakeBlock((intMapLength / 2) + 3, 70, intFarmLength + 9, 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((intMapLength / 2) - 3, 69, intFarmLength + 9, BlockType.GRAVEL, tec, 2); // add torches BlockHelper.MakeTorch((intMapLength / 2) - 1, 70, intFarmLength + 9, intWallMaterial, 2); BlockHelper.MakeTorch((intMapLength / 2) + 1, 70, intFarmLength + 9, intWallMaterial, 2); // link to main roads //BlockShapes.MakeSolidBox((intMapLength / 2) - 1, (intMapLength / 2) + 1, 63, 63, // intFarmLength + 11, intFarmLength + 13, BlockType.DOUBLE_SLAB, 0); } else if (booIncludeMoat) { BlockShapes.MakeSolidBox((intMapLength / 2) - 2, intMapLength / 2, 63, 63, intFarmLength - 2, intFarmLength + 6, BlockType.STONE, 2); } }
public static void MakePlots(bool[,] booSewerEntrances) { Console.WriteLine("Making plots"); int intPlots = 1 + (((intMapSize - (intFarmSize + 20)) - (intFarmSize + 18)) / intPlotSize); for (int x = intFarmSize + 18; x < intMapSize - (intFarmSize + 20); x += intPlotSize) { for (int z = intFarmSize + 18; z < intMapSize - (intFarmSize + 20); z += intPlotSize) { if (booSewerEntrances[(x - (intFarmSize + 18)) / intPlotSize, (z - (intFarmSize + 18)) / intPlotSize]) { BlockShapes.MakeHollowBox(x + (intPlotSize / 2) - 2, x + (intPlotSize / 2) + 2, 63, 67, z + (intPlotSize / 2) - 2, z + (intPlotSize / 2) + 2, (int)BlockType.STONE); BlockShapes.MakeSolidBox(x + (intPlotSize / 2), x + (intPlotSize / 2), 64, 65, z + (intPlotSize / 2) - 2, z + (intPlotSize / 2) - 2, (int)BlockType.AIR); BlockShapes.MakeSolidBox(x + (intPlotSize / 2), x + (intPlotSize / 2), 55, 63, z + (intPlotSize / 2), z + (intPlotSize / 2), (int)BlockType.AIR); BlockShapes.MakeSolidBox(x + (intPlotSize / 2), x + (intPlotSize / 2), 52, 55, z + (intPlotSize / 2) + 1, z + (intPlotSize / 2) + 1, (int)BlockType.STONE); BlockShapes.MakeLadder(x + (intPlotSize / 2), 52, 63, z + (intPlotSize / 2), 2); bm.SetID(x + (intPlotSize / 2), 64, z + (intPlotSize / 2), 96); // hatch bm.SetData(x + (intPlotSize / 2), 64, z + (intPlotSize / 2), 2); bm.SetID(x + (intPlotSize / 2) + 1, 64, z + (intPlotSize / 2) + 1, (int)BlockType.CHEST); TileEntityChest tec = new TileEntityChest(); tec.Items[0] = MakeItem((int)BlockType.REDSTONE_TORCH_ON, 32); tec.Items[1] = MakeItem((int)BlockType.TORCH, 8); bm.SetTileEntity(x + (intPlotSize / 2) + 1, 64, z + (intPlotSize / 2) + 1, tec); MakeSign(x + (intPlotSize / 2), 66, z + (intPlotSize / 2) - 3, "Sewers||Currently|empty!", (int)BlockType.STONE); } else { int intRandBuilding = rand.Next(100); if (intRandBuilding >= 90) { BlockShapes.MakeHollowLayers(x + 3, x + 9, 63, 63, z + 3, z + 9, (int)BlockType.DOUBLE_SLAB); for (int a = 0; a <= 3; a++) { bm.SetID(x + 6, 63, z + a, (int)BlockType.DOUBLE_SLAB); } int x1 = x + rand.Next(5, 7); int z1 = z + rand.Next(5, 7); BlockShapes.MakeSolidBox(x1, x1 + 1, 63, 63, z1, z1 + 1, (int)BlockType.STATIONARY_WATER); int intFail = 0, intTrees = 10; bool blnValid = true; do { x1 = x + 1 + rand.Next(0, intPlotSize - 2); z1 = z + 1 + rand.Next(0, intPlotSize - 2); if (bm.GetID(x1, 63, z1) != (int)BlockType.DOUBLE_SLAB && bm.GetID(x1, 63, z1) != (int)BlockType.STATIONARY_WATER) { blnValid = true; for (int a = x1 - 4; a <= x1 + 4 && blnValid; a++) { for (int b = z1 - 4; b <= z1 + 4 && blnValid; b++) { if (bm.GetID(a, 64, b) == (int)BlockType.SAPLING) { blnValid = false; } } } if (blnValid) { bm.SetID(x1, 64, z1, (int)BlockType.SAPLING); bm.SetData(x1, 64, z1, 15); intTrees--; intFail = 0; } else { intFail++; } } } while (intTrees > 0 && intFail < 200); for (x1 = x + 1; x1 < x + intPlotSize - 1; x1++) { for (z1 = z + 1; z1 < z + intPlotSize - 1; z1++) { if (bm.GetID(x1, 63, z1) != (int)BlockType.STATIONARY_WATER && bm.GetID(x1, 64, z1) != (int)BlockType.SAPLING && bm.GetID(x1, 63, z1) != (int)BlockType.DOUBLE_SLAB) { int intRand = rand.Next(100); if (intRand > 66) { bm.SetID(x1, 64, z1, (int)BlockType.YELLOW_FLOWER); } else if (intRand > 33) { bm.SetID(x1, 64, z1, (int)BlockType.RED_ROSE); } } } } } else { BlockShapes.MakeHollowBox(x + 2, x + 10, 63, 67, z + 2, z + 10, (int)BlockType.WOOD_PLANK); for (int a = 0; a <= 4; a++) { BlockShapes.MakeSolidBox(x + 2, x + 10, 67 + a, 67 + a, z + 2 + a, z + 10 - a, (int)BlockType.WOOD); } BlockShapes.MakeSolidBox(x + 10, x + 10, 65, 65, z + 6, z + 8, (int)BlockType.GLASS); BlockShapes.MakeSolidBox(x + 2, x + 2, 65, 65, z + 4, z + 8, (int)BlockType.GLASS); BlockShapes.MakeSolidBox(x + 4, x + 8, 65, 65, z + 2, z + 2, (int)BlockType.GLASS); BlockShapes.MakeSolidBox(x + 4, x + 8, 65, 65, z + 10, z + 10, (int)BlockType.GLASS); bm.SetID(x + 10, 64, z + 4, (int)BlockType.WOOD_DOOR); bm.SetData(x + 10, 64, z + 4, 5); bm.SetID(x + 10, 65, z + 4, (int)BlockType.WOOD_DOOR); bm.SetData(x + 10, 65, z + 4, 13); } } BlockShapes.MakeHollowLayers(x, x + intPlotSize, 63, 63, z, z + intPlotSize, (int)BlockType.DOUBLE_SLAB); } } }
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 } } } } }
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); }