Beispiel #1
0
        private static void MakeChestItems(BlockManager bm, int x, int y, int z, int[] intResourceChances, string[] strResourceNames)
        {
            string strResource = strResourceNames[RNG.RandomWeightedNumber(intResourceChances)];
            string strAmount;

            _dictResourceAmounts.TryGetValue(strResource.ToLower(), out strAmount);
            strAmount = strAmount ?? "1,1";
            int    intAmount = RNG.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);
        }