private static void Player_PickAmmo(On.Terraria.Player.orig_PickAmmo orig, Player self, Item sItem, ref int shoot, ref float speed, ref bool canShoot, ref int Damage, ref float KnockBack, bool dontConsume)
        {
            Item item = new Item();

            Item firstAmmo = self.inventory.OfType <BaseAmmoBag>().SelectMany(x => x.Handler.Items).FirstOrDefault(ammo => ammo.ammo == sItem.useAmmo && ammo.stack > 0);

            if (firstAmmo != null)
            {
                item     = firstAmmo;
                canShoot = true;
            }
            else
            {
                bool hasInAmmoSlots = false;

                for (int i = 54; i < 58; i++)
                {
                    if (self.inventory[i].ammo == sItem.useAmmo && self.inventory[i].stack > 0)
                    {
                        item           = self.inventory[i];
                        canShoot       = true;
                        hasInAmmoSlots = true;
                        break;
                    }
                }

                if (!hasInAmmoSlots)
                {
                    for (int j = 0; j < 54; j++)
                    {
                        if (self.inventory[j].ammo == sItem.useAmmo && self.inventory[j].stack > 0)
                        {
                            item     = self.inventory[j];
                            canShoot = true;
                            break;
                        }
                    }
                }
            }

            if (canShoot)
            {
                if (sItem.type == 1946)
                {
                    shoot = 338 + item.type - 771;
                    if (shoot > ProjectileID.RocketSnowmanIV)
                    {
                        shoot = ProjectileID.RocketSnowmanIV;
                    }
                }
                else if (sItem.useAmmo == AmmoID.Rocket)
                {
                    shoot += item.shoot;
                }
                else if (sItem.useAmmo == 780)
                {
                    shoot += item.shoot;
                }
                else if (item.shoot > 0)
                {
                    shoot = item.shoot;
                }

                if (sItem.type == 3019 && shoot == 1)
                {
                    shoot = 485;
                }
                if (sItem.type == 3052)
                {
                    shoot = 495;
                }
                if (sItem.type == 3245 && shoot == 21)
                {
                    shoot = 532;
                }
                if (shoot == 42)
                {
                    if (item.type == 370)
                    {
                        shoot   = 65;
                        Damage += 5;
                    }
                    else if (item.type == 408)
                    {
                        shoot   = 68;
                        Damage += 5;
                    }
                    else if (item.type == 1246)
                    {
                        shoot   = 354;
                        Damage += 5;
                    }
                }

                if (self.HeldItem.type == 2888 && shoot == 1)
                {
                    shoot = 469;
                }
                if (self.magicQuiver && (sItem.useAmmo == AmmoID.Arrow || sItem.useAmmo == AmmoID.Stake))
                {
                    KnockBack = (int)(KnockBack * 1.1);
                    speed    *= 1.1f;
                }

                speed += item.shootSpeed;
                if (item.ranged)
                {
                    if (item.damage > 0)
                    {
                        Damage += (int)(item.damage * self.rangedDamage);
                    }
                }
                else
                {
                    Damage += item.damage;
                }

                if (sItem.useAmmo == AmmoID.Arrow && self.archery)
                {
                    if (speed < 20f)
                    {
                        speed *= 1.2f;
                        if (speed > 20f)
                        {
                            speed = 20f;
                        }
                    }

                    Damage = (int)(Damage * 1.2);
                }

                KnockBack += item.knockBack;
                ItemLoader.PickAmmo(item, self, ref shoot, ref speed, ref Damage, ref KnockBack);
                bool dontConsumeAmmo = dontConsume;
                if (sItem.type == 3245)
                {
                    if (Main.rand.Next(3) == 0)
                    {
                        dontConsumeAmmo = true;
                    }
                    else if (self.thrownCost33 && Main.rand.Next(100) < 33)
                    {
                        dontConsumeAmmo = true;
                    }
                    else if (self.thrownCost50 && Main.rand.Next(100) < 50)
                    {
                        dontConsumeAmmo = true;
                    }
                }

                if (sItem.type == 3475 && Main.rand.Next(3) != 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 3540 && Main.rand.Next(3) != 0)
                {
                    dontConsumeAmmo = true;
                }
                if (self.magicQuiver && sItem.useAmmo == AmmoID.Arrow && Main.rand.Next(5) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (self.ammoBox && Main.rand.Next(5) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (self.ammoPotion && Main.rand.Next(5) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 1782 && Main.rand.Next(3) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 98 && Main.rand.Next(3) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 2270 && Main.rand.Next(2) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 533 && Main.rand.Next(2) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 1929 && Main.rand.Next(2) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 1553 && Main.rand.Next(2) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (sItem.type == 434 && self.itemAnimation < (int)(sItem.useAnimation / PlayerHooks.TotalMeleeSpeedMultiplier(self, sItem)) - 2)
                {
                    dontConsumeAmmo = true;
                }
                if (self.ammoCost80 && Main.rand.Next(5) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (self.ammoCost75 && Main.rand.Next(4) == 0)
                {
                    dontConsumeAmmo = true;
                }
                if (shoot == 85 && self.itemAnimation < self.itemAnimationMax - 6)
                {
                    dontConsumeAmmo = true;
                }
                if ((shoot == 145 || shoot == 146 || shoot == 147 || shoot == 148 || shoot == 149) && self.itemAnimation < self.itemAnimationMax - 5)
                {
                    dontConsumeAmmo = true;
                }
                dontConsumeAmmo |= !PlayerHooks.ConsumeAmmo(self, sItem, item) | !ItemLoader.ConsumeAmmo(sItem, item, self);
                if (!dontConsumeAmmo && item.consumable)
                {
                    Main.NewText(item);
                    PlayerHooks.OnConsumeAmmo(self, sItem, item);
                    ItemLoader.OnConsumeAmmo(sItem, item, self);
                    item.stack--;
                    if (item.stack <= 0)
                    {
                        item.active = false;
                        item.TurnToAir();
                    }
                }
            }
        }