Exemplo n.º 1
0
        public virtual ItemStack FindMatchingRecipe(InventoryCrafting par1InventoryCrafting)
        {
            int       i          = 0;
            ItemStack itemstack  = null;
            ItemStack itemstack1 = null;

            for (int j = 0; j < par1InventoryCrafting.GetSizeInventory(); j++)
            {
                ItemStack itemstack2 = par1InventoryCrafting.GetStackInSlot(j);

                if (itemstack2 == null)
                {
                    continue;
                }

                if (i == 0)
                {
                    itemstack = itemstack2;
                }

                if (i == 1)
                {
                    itemstack1 = itemstack2;
                }

                i++;
            }

            if (i == 2 && itemstack.ItemID == itemstack1.ItemID && itemstack.StackSize == 1 && itemstack1.StackSize == 1 && Item.ItemsList[itemstack.ItemID].IsDamageable())
            {
                Item item = Item.ItemsList[itemstack.ItemID];
                int  l    = item.GetMaxDamage() - itemstack.GetItemDamageForDisplay();
                int  i1   = item.GetMaxDamage() - itemstack1.GetItemDamageForDisplay();
                int  j1   = l + i1 + (item.GetMaxDamage() * 10) / 100;
                int  k1   = item.GetMaxDamage() - j1;

                if (k1 < 0)
                {
                    k1 = 0;
                }

                return(new ItemStack(itemstack.ItemID, 1, k1));
            }

            for (int k = 0; k < Recipes.Count; k++)
            {
                IRecipe irecipe = (IRecipe)Recipes[k];

                if (irecipe.Matches(par1InventoryCrafting))
                {
                    return(irecipe.GetCraftingResult(par1InventoryCrafting));
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
        /// specified position.
        /// </summary>
        public virtual void RenderItemOverlayIntoGUI(FontRenderer par1FontRenderer, RenderEngineOld par2RenderEngine, ItemStack par3ItemStack, int par4, int par5)
        {
            if (par3ItemStack == null)
            {
                return;
            }

            if (par3ItemStack.StackSize > 1)
            {
                string s = (new StringBuilder()).Append("").Append(par3ItemStack.StackSize).ToString();
                //GL.Disable(EnableCap.Lighting);
                //GL.Disable(EnableCap.DepthTest);
                par1FontRenderer.DrawStringWithShadow(s, (par4 + 19) - 2 - (int)par1FontRenderer.GetStringWidth(s), par5 + 6 + 3, 0xffffff);
                //GL.Enable(EnableCap.Lighting);
                //GL.Enable(EnableCap.DepthTest);
            }

            if (par3ItemStack.IsItemDamaged())
            {
                int i = (int)Math.Round(13D - ((double)par3ItemStack.GetItemDamageForDisplay() * 13D) / (double)par3ItemStack.GetMaxDamage());
                int j = (int)Math.Round(255D - ((double)par3ItemStack.GetItemDamageForDisplay() * 255D) / (double)par3ItemStack.GetMaxDamage());
                //GL.Disable(EnableCap.Lighting);
                //GL.Disable(EnableCap.DepthTest);
                //GL.Disable(EnableCap.Texture2D);
                Tessellator tessellator = Tessellator.Instance;
                int         k           = 255 - j << 16 | j << 8;
                int         l           = (255 - j) / 4 << 16 | 0x3f00;
                RenderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
                RenderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, l);
                RenderQuad(tessellator, par4 + 2, par5 + 13, i, 1, k);
                //GL.Enable(EnableCap.Texture2D);
                //GL.Enable(EnableCap.Lighting);
                //GL.Enable(EnableCap.DepthTest);
                //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            }
        }