public TileEntityChest(TileEntity te) : base(te) { TileEntityChest tec = te as TileEntityChest; if (tec != null) { _items = tec._items.Copy(); } else { _items = new ItemCollection(_CAPACITY); } }
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(BlockType.LADDER, 64); tec.Items[5] = BlockHelper.MakeItem(BlockType.DIRT, 64); tec.Items[6] = BlockHelper.MakeItem(BlockType.SAND, 64); tec.Items[7] = BlockHelper.MakeItem(BlockType.CRAFTING_TABLE, 64); tec.Items[8] = BlockHelper.MakeItem(BlockType.FURNACE, 64); tec.Items[9] = BlockHelper.MakeItem(ItemInfo.Bread.ID, 64); tec.Items[10] = BlockHelper.MakeItem(BlockType.TORCH, 64); tec.Items[11] = BlockHelper.MakeItem(BlockType.STONE, 64); tec.Items[12] = BlockHelper.MakeItem(BlockType.CHEST, 64); tec.Items[13] = BlockHelper.MakeItem(BlockType.GLASS, 64); tec.Items[14] = BlockHelper.MakeItem(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(BlockType.IRON_BLOCK, 64); tec.Items[18] = BlockHelper.MakeItem(BlockType.DIAMOND_BLOCK, 64); tec.Items[19] = BlockHelper.MakeItem(BlockType.GOLD_BLOCK, 64); bm.SetID(x, y, z, BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
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 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 MakeGuardChest(BlockManager bm, int x, int y, int z, bool booIncludeItemsInChests) { TileEntityChest tec = new TileEntityChest(); if (booIncludeItemsInChests) { 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++) { // random armour tec.Items[a] = BlockHelper.MakeItem(intArmourStartID + RandomHelper.Next(4), 1); } } bm.SetID(x, y, z, BlockType.CHEST); bm.SetTileEntity(x, y, z, tec); }
static void FasterProcessChunk(RegionChunkManager rcm, int dimnumber, Dictionary<string,string> ReplaceList) { int currentchunk = 0; int chunktotal = 0; Stack<string> _TEList = new Stack<string>(); foreach (ChunkRef chunk in rcm) { chunktotal++; } foreach (ChunkRef chunk in rcm) { Stopwatch sw = new Stopwatch(); sw.Start(); currentchunk++; char[] metadata = {':'}; string blockOutput = ""; string tileOutput = ""; // You could hardcode your dimensions, but maybe some day they // won't always be 16. Also the CLR is a bit stupid and has // trouble optimizing repeated calls to Chunk.Blocks.xx, so we // cache them in locals int xdim = chunk.Blocks.XDim; int ydim = chunk.Blocks.YDim; int zdim = chunk.Blocks.ZDim; // x, z, y is the most efficient order to scan blocks (not that // you should care about internal detail) for (int x = 0; x < xdim; x++) { for (int z = 0; z < zdim; z++) { for (int y = 0; y < ydim; y++) { int currentID = chunk.Blocks.GetID(x,y,z); int currentData = chunk.Blocks.GetData(x,y,z); TileEntity TE = chunk.Blocks.GetTileEntity(x, y, z); TileEntityCleaner TC = new TileEntityCleaner(); if (TE != null) { if (TC.getDeleteList().Contains(TE.ID)) { chunk.Blocks.ClearTileEntity(x,y,z); Console.WriteLine("Tile Entity {0} found, cleared at {1},{2},{3}", TE.ID, x, y, z); } //if (TE != null) // Console.WriteLine(TE.ID.ToString()); //_TEList.Push(TE.ID); if (TE.ID == "factory_barrel") { Console.WriteLine("breakpoint"); FactoryBarrel barrel = new FactoryBarrel(TE) as FactoryBarrel; //Console.WriteLine(test.Item.ID.ToString()); //Console.ReadLine(); if (barrel.Item != null) { string _tmpBarrelItem = barrel.Item.ID.ToString() + ":" + barrel.Item.Damage.ToString(); if (ReplaceList.TryGetValue(_tmpBarrelItem,out tileOutput)) { string[] _strKey = tileOutput.Split(metadata); barrel.Item.ID = Convert.ToInt32(_strKey.GetValue(0)); barrel.Item.Damage = Convert.ToInt32(_strKey.GetValue(1)); chunk.Blocks.SetTileEntity(x,y,z,barrel); } } } if (IronChest.ChestTypes.Contains(TE.ID)) { //IronChest.ChestList.Push(TE); var temp = IronChest.getChestType(TE); for (int i = 0; i <= temp.Items.Capacity; i++) { Item item = temp.Items[i]; if (item != null) { string _tmpChestItem = item.ID.ToString() + ":" + item.Damage.ToString(); //Console.WriteLine(_tmpChestItem); if (ReplaceList.TryGetValue(_tmpChestItem,out tileOutput)) { string[] _strKey = tileOutput.Split(metadata); temp.Items[i].ID = Convert.ToInt32(_strKey.GetValue(0)); temp.Items[i].Damage = Convert.ToInt32(_strKey.GetValue(1)); } } } switch (currentData) { case 0: IronChest.SetTileEntity("IRON"); break; case 1: IronChest.SetTileEntity("GOLD"); break; case 2: IronChest.SetTileEntity("DIAMOND"); break; case 3: IronChest.SetTileEntity("COPPER"); break; case 4: IronChest.SetTileEntity("SILVER"); break; case 5: IronChest.SetTileEntity("CRYSTAL"); break; default: IronChest.SetTileEntity("IRON"); break; } chunk.Blocks.SetTileEntity(x,y,z,temp); } if (TE.ID == "Chest") { TileEntityChest temp = new TileEntityChest(TE); for (int i = 0; i <= temp.Items.Capacity; i++) { Item item = temp.Items[i]; if (item != null) { string _tmpChestItem = item.ID.ToString() + ":" + item.Damage.ToString(); //Console.WriteLine(_tmpChestItem); if (ReplaceList.TryGetValue(_tmpChestItem,out tileOutput)) { string[] _strKey = tileOutput.Split(metadata); temp.Items[i].ID = Convert.ToInt32(_strKey.GetValue(0)); temp.Items[i].Damage = Convert.ToInt32(_strKey.GetValue(1)); } } } chunk.Blocks.SetTileEntity(x,y,z, temp); } } string currentBlock = currentID.ToString() + ":" + currentData.ToString(); if (currentBlock == "750") { if (currentData >= 4096) { string _temp = currentBlock + ":" + currentData.ToString(); _TEList.Push(_temp); } } if (ReplaceList.TryGetValue(currentBlock, out blockOutput)) { string[] _strKey = blockOutput.Split(metadata); chunk.Blocks.SetID(x,y,z,(Convert.ToInt32(_strKey.GetValue(0)))); chunk.Blocks.SetData(x,y,z,(Convert.ToInt32(_strKey.GetValue(1)))); // Console.WriteLine("Block changed from ID {0}:{1} to {2}:{3} at {4},{5},{6}", // currentID, // currentData, // _strKey.GetValue(0), // _strKey.GetValue(1), // x, y, z); } } } } //ProcessModBlocks(); // Save the chunk rcm.Save(); sw.Stop(); switch (dimnumber) { case Dimension.DEFAULT: Console.WriteLine("Processed Chunk {0},{1}\t\t({2} of {3} in Overworld (DIM{4})", chunk.X, chunk.Z, currentchunk, chunktotal, Dimension.DEFAULT); break; case Dimension.NETHER: Console.WriteLine("Processed Chunk {0},{1}\t\t({2} of {3} in Nether (DIM{4})", chunk.X, chunk.Z, currentchunk, chunktotal, Dimension.NETHER); break; case Dimension.THE_END: Console.WriteLine("Processed Chunk {0},{1}\t\t({2} of {3} in The End (DIM{4})", chunk.X, chunk.Z, currentchunk, chunktotal, Dimension.THE_END); break; default: Console.WriteLine("Processed Chunk {0},{1}\t\t({2} of {3} in Mystcraft Age {4}) in {5}.{6}", chunk.X, chunk.Z, currentchunk, chunktotal, dimnumber, sw.Elapsed.Seconds.ToString(),sw.Elapsed.Milliseconds.ToString()); break; } //Console.WriteLine(sw.ElapsedMilliseconds.ToString()); //Console.ReadLine(); } switch (dimnumber) { case Dimension.DEFAULT: Console.WriteLine("Overworld (DIM{0}) completed.",Dimension.DEFAULT); break; case Dimension.NETHER: Console.WriteLine("Nether (DIM{0}) completed.",Dimension.DEFAULT); break; case Dimension.THE_END: Console.WriteLine("The End (DIM{0}) completed.",Dimension.THE_END); break; default: Console.WriteLine("Mystcraft Age {0} (DIM{0}) completed.", dimnumber); break; } foreach (string s in _TEList) { Console.WriteLine(s); } }
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); }
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 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); } } }