Exemple #1
0
        public virtual void Func_40219_x_()
        {
            ItemStack itemstack = InventorySlots.GetSlot(0).GetStack();

            if (!ItemStack.AreItemStacksEqual(itemstack, Field_40222_o))
            {
                Field_40222_o = itemstack;

                do
                {
                    Field_40226_k += Field_40230_x.Next(4) - Field_40230_x.Next(4);
                }while (Field_40229_i <= Field_40226_k + 1.0F && Field_40229_i >= Field_40226_k - 1.0F);
            }

            Field_40227_h++;
            Field_40225_j = Field_40229_i;
            Field_40221_n = Field_40224_m;
            bool flag = false;

            for (int i = 0; i < 3; i++)
            {
                if (ContainerEnchantment.EnchantLevels[i] != 0)
                {
                    flag = true;
                }
            }

            if (flag)
            {
                Field_40224_m += 0.2F;
            }
            else
            {
                Field_40224_m -= 0.2F;
            }

            if (Field_40224_m < 0.0F)
            {
                Field_40224_m = 0.0F;
            }

            if (Field_40224_m > 1.0F)
            {
                Field_40224_m = 1.0F;
            }

            float f  = (Field_40226_k - Field_40229_i) * 0.4F;
            float f1 = 0.2F;

            if (f < -f1)
            {
                f = -f1;
            }

            if (f > f1)
            {
                f = f1;
            }

            Field_40223_l += (f - Field_40223_l) * 0.9F;
            Field_40229_i  = Field_40229_i + Field_40223_l;
        }
Exemple #2
0
        protected override void HandleMouseClick(Slot par1Slot, int par2, int par3, bool par4)
        {
            if (par1Slot != null)
            {
                if (par1Slot.Inventory == Inventory)
                {
                    InventoryPlayer inventoryplayer = Mc.ThePlayer.Inventory;
                    ItemStack       itemstack1      = inventoryplayer.GetItemStack();
                    ItemStack       itemstack4      = par1Slot.GetStack();

                    if (itemstack1 != null && itemstack4 != null && itemstack1.ItemID == itemstack4.ItemID)
                    {
                        if (par3 == 0)
                        {
                            if (par4)
                            {
                                itemstack1.StackSize = itemstack1.GetMaxStackSize();
                            }
                            else if (itemstack1.StackSize < itemstack1.GetMaxStackSize())
                            {
                                itemstack1.StackSize++;
                            }
                        }
                        else if (itemstack1.StackSize <= 1)
                        {
                            inventoryplayer.SetItemStack(null);
                        }
                        else
                        {
                            itemstack1.StackSize--;
                        }
                    }
                    else if (itemstack1 != null)
                    {
                        inventoryplayer.SetItemStack(null);
                    }
                    else if (itemstack4 == null)
                    {
                        inventoryplayer.SetItemStack(null);
                    }
                    else if (itemstack1 == null || itemstack1.ItemID != itemstack4.ItemID)
                    {
                        inventoryplayer.SetItemStack(ItemStack.CopyItemStack(itemstack4));
                        ItemStack itemstack2 = inventoryplayer.GetItemStack();

                        if (par4)
                        {
                            itemstack2.StackSize = itemstack2.GetMaxStackSize();
                        }
                    }
                }
                else
                {
                    InventorySlots.SlotClick(par1Slot.SlotNumber, par3, par4, Mc.ThePlayer);
                    ItemStack itemstack = InventorySlots.GetSlot(par1Slot.SlotNumber).GetStack();
                    Mc.PlayerController.SendSlotPacket(itemstack, (par1Slot.SlotNumber - InventorySlots.InventorySlots.Count) + 9 + 36);
                }
            }
            else
            {
                InventoryPlayer inventoryplayer1 = Mc.ThePlayer.Inventory;

                if (inventoryplayer1.GetItemStack() != null)
                {
                    if (par3 == 0)
                    {
                        Mc.ThePlayer.DropPlayerItem(inventoryplayer1.GetItemStack());
                        Mc.PlayerController.Func_35639_a(inventoryplayer1.GetItemStack());
                        inventoryplayer1.SetItemStack(null);
                    }

                    if (par3 == 1)
                    {
                        ItemStack itemstack3 = inventoryplayer1.GetItemStack().SplitStack(1);
                        Mc.ThePlayer.DropPlayerItem(itemstack3);
                        Mc.PlayerController.Func_35639_a(itemstack3);

                        if (inventoryplayer1.GetItemStack().StackSize == 0)
                        {
                            inventoryplayer1.SetItemStack(null);
                        }
                    }
                }
            }
        }