Exemplo n.º 1
0
        /// <summary>
        /// Executes the enchantment modifier on the ItemStack passed.
        /// </summary>
        private static void ApplyEnchantmentModifier(IEnchantmentModifier par0IEnchantmentModifier, ItemStack par1ItemStack)
        {
            if (par1ItemStack == null)
            {
                return;
            }

            NBTTagList nbttaglist = par1ItemStack.GetEnchantmentTagList();

            if (nbttaglist == null)
            {
                return;
            }

            for (int i = 0; i < nbttaglist.TagCount(); i++)
            {
                short word0 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("id");
                short word1 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("lvl");

                if (Enchantment.EnchantmentsList[word0] != null)
                {
                    par0IEnchantmentModifier.CalculateModifier(Enchantment.EnchantmentsList[word0], word1);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the level of enchantment on the ItemStack passed.
        /// </summary>
        public static int GetEnchantmentLevel(int par0, ItemStack par1ItemStack)
        {
            if (par1ItemStack == null)
            {
                return(0);
            }

            NBTTagList nbttaglist = par1ItemStack.GetEnchantmentTagList();

            if (nbttaglist == null)
            {
                return(0);
            }

            for (int i = 0; i < nbttaglist.TagCount(); i++)
            {
                short word0 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("id");
                short word1 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("lvl");

                if (word0 == par0)
                {
                    return(word1);
                }
            }

            return(0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// gets a list of strings representing the item name and successive extra data, eg Enchantments and potion effects
        /// </summary>
        public List <string> GetItemNameandInformation()
        {
            List <string> arraylist = new List <string>();
            Item          item      = Item.ItemsList[ItemID];

            arraylist.Add(item.GetItemDisplayName(this));
            item.AddInformation(this, arraylist);

            if (HasTagCompound())
            {
                NBTTagList nbttaglist = GetEnchantmentTagList();

                if (nbttaglist != null)
                {
                    for (int i = 0; i < nbttaglist.TagCount(); i++)
                    {
                        short word0 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("id");
                        short word1 = ((NBTTagCompound)nbttaglist.TagAt(i)).GetShort("lvl");

                        if (Enchantment.EnchantmentsList[word0] != null)
                        {
                            arraylist.Add(Enchantment.EnchantmentsList[word0].GetTranslatedName(word1));
                        }
                    }
                }
            }

            return(arraylist);
        }
Exemplo n.º 4
0
        /// <summary>
        /// (abstract) Protected helper method to read subclass entity data from NBT.
        /// </summary>
        public override void ReadEntityFromNBT(NBTTagCompound par1NBTTagCompound)
        {
            MinecartType = par1NBTTagCompound.GetInteger("Type");

            if (MinecartType == 2)
            {
                PushX = (float)par1NBTTagCompound.GetDouble("PushX");
                PushZ = (float)par1NBTTagCompound.GetDouble("PushZ");
                Fuel  = par1NBTTagCompound.GetShort("Fuel");
            }
            else if (MinecartType == 1)
            {
                NBTTagList nbttaglist = par1NBTTagCompound.GetTagList("Items");
                CargoItems = new ItemStack[GetSizeInventory()];

                for (int i = 0; i < nbttaglist.TagCount(); i++)
                {
                    NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.TagAt(i);
                    int            j = nbttagcompound.GetByte("Slot") & 0xff;

                    if (j >= 0 && j < CargoItems.Length)
                    {
                        CargoItems[j] = ItemStack.LoadItemStackFromNBT(nbttagcompound);
                    }
                }
            }
        }
        /// <summary>
        /// Reads a tile entity from NBT.
        /// </summary>
        public override void ReadFromNBT(NBTTagCompound par1NBTTagCompound)
        {
            base.ReadFromNBT(par1NBTTagCompound);
            NBTTagList nbttaglist = par1NBTTagCompound.GetTagList("Items");

            DispenserContents = new ItemStack[GetSizeInventory()];

            for (int i = 0; i < nbttaglist.TagCount(); i++)
            {
                NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.TagAt(i);
                int            j = nbttagcompound.GetByte("Slot") & 0xff;

                if (j >= 0 && j < DispenserContents.Length)
                {
                    DispenserContents[j] = ItemStack.LoadItemStackFromNBT(nbttagcompound);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reads a tile entity from NBT.
        /// </summary>
        public override void ReadFromNBT(NBTTagCompound par1NBTTagCompound)
        {
            base.ReadFromNBT(par1NBTTagCompound);
            NBTTagList nbttaglist = par1NBTTagCompound.GetTagList("Items");

            BrewingItemStacks = new ItemStack[GetSizeInventory()];

            for (int i = 0; i < nbttaglist.TagCount(); i++)
            {
                NBTTagCompound nbttagcompound = (NBTTagCompound)nbttaglist.TagAt(i);
                byte           byte0          = nbttagcompound.GetByte("Slot");

                if (byte0 >= 0 && byte0 < BrewingItemStacks.Length)
                {
                    BrewingItemStacks[byte0] = ItemStack.LoadItemStackFromNBT(nbttagcompound);
                }
            }

            BrewTime = par1NBTTagCompound.GetShort("BrewTime");
        }
Exemplo n.º 7
0
        private Chunk Func_48444_a(World par1World, NBTTagCompound par2NBTTagCompound)
        {
            int   i     = par2NBTTagCompound.GetInteger("xPos");
            int   j     = par2NBTTagCompound.GetInteger("zPos");
            Chunk chunk = new Chunk(par1World, i, j);

            chunk.HeightMap          = par2NBTTagCompound.Func_48182_l("HeightMap");
            chunk.IsTerrainPopulated = par2NBTTagCompound.Getbool("TerrainPopulated");
            NBTTagList nbttaglist = par2NBTTagCompound.GetTagList("Sections");
            sbyte      byte0      = 16;

            ExtendedBlockStorage[] aextendedblockstorage = new ExtendedBlockStorage[byte0];

            for (int k = 0; k < nbttaglist.TagCount(); k++)
            {
                NBTTagCompound       nbttagcompound       = (NBTTagCompound)nbttaglist.TagAt(k);
                byte                 byte1                = nbttagcompound.GetByte("Y");
                ExtendedBlockStorage extendedblockstorage = new ExtendedBlockStorage(byte1 << 4);
                extendedblockstorage.SetBlockLSBArray(nbttagcompound.GetByteArray("Blocks"));

                if (nbttagcompound.HasKey("Add"))
                {
                    extendedblockstorage.SetBlockMSBArray(new NibbleArray(nbttagcompound.GetByteArray("Add"), 4));
                }

                extendedblockstorage.SetBlockMetadataArray(new NibbleArray(nbttagcompound.GetByteArray("Data"), 4));
                extendedblockstorage.SetSkylightArray(new NibbleArray(nbttagcompound.GetByteArray("SkyLight"), 4));
                extendedblockstorage.SetBlocklightArray(new NibbleArray(nbttagcompound.GetByteArray("BlockLight"), 4));
                extendedblockstorage.Func_48708_d();
                aextendedblockstorage[byte1] = extendedblockstorage;
            }

            chunk.SetStorageArrays(aextendedblockstorage);

            if (par2NBTTagCompound.HasKey("Biomes"))
            {
                chunk.SetBiomeArray(par2NBTTagCompound.GetByteArray("Biomes"));
            }

            NBTTagList nbttaglist1 = par2NBTTagCompound.GetTagList("Entities");

            if (nbttaglist1 != null)
            {
                for (int l = 0; l < nbttaglist1.TagCount(); l++)
                {
                    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist1.TagAt(l);
                    Entity         entity          = EntityList.CreateEntityFromNBT(nbttagcompound1, par1World);
                    chunk.HasEntities = true;

                    if (entity != null)
                    {
                        chunk.AddEntity(entity);
                    }
                }
            }

            NBTTagList nbttaglist2 = par2NBTTagCompound.GetTagList("TileEntities");

            if (nbttaglist2 != null)
            {
                for (int i1 = 0; i1 < nbttaglist2.TagCount(); i1++)
                {
                    NBTTagCompound nbttagcompound2 = (NBTTagCompound)nbttaglist2.TagAt(i1);
                    TileEntity     tileentity      = TileEntity.CreateAndLoadEntity(nbttagcompound2);

                    if (tileentity != null)
                    {
                        chunk.AddTileEntity(tileentity);
                    }
                }
            }

            if (par2NBTTagCompound.HasKey("TileTicks"))
            {
                NBTTagList nbttaglist3 = par2NBTTagCompound.GetTagList("TileTicks");

                if (nbttaglist3 != null)
                {
                    for (int j1 = 0; j1 < nbttaglist3.TagCount(); j1++)
                    {
                        NBTTagCompound nbttagcompound3 = (NBTTagCompound)nbttaglist3.TagAt(j1);
                        par1World.ScheduleBlockUpdateFromLoad(nbttagcompound3.GetInteger("x"), nbttagcompound3.GetInteger("y"), nbttagcompound3.GetInteger("z"), nbttagcompound3.GetInteger("i"), nbttagcompound3.GetInteger("t"));
                    }
                }
            }

            return(chunk);
        }
        /// <summary>
        /// Load the server list from servers.dat
        /// </summary>
        private void LoadServerList()
        {
            try
            {
                NBTTagCompound nbttagcompound = CompressedStreamTools.Read(System.IO.Path.Combine(Mc.McDataDir, "servers.dat"));
                NBTTagList     nbttaglist     = nbttagcompound.GetTagList("servers");
                ServerList.Clear();

                for (int i = 0; i < nbttaglist.TagCount(); i++)
                {
                    ServerList.Add(ServerNBTStorage.CreateServerNBTStorage((NBTTagCompound)nbttaglist.TagAt(i)));
                }
            }
            catch (Exception exception)
            {
                Utilities.LogException(exception);
            }
        }