private static void ItemSlotText(ILContext il) { ILCursor cursor = new ILCursor(il); if (cursor.TryGotoNext(i => i.MatchLdloc(1), i => i.MatchLdfld <Item>("fishingPole"), i => i.MatchLdcI4(0))) { cursor.Emit(OpCodes.Ldloc, 1); cursor.Emit(OpCodes.Ldloc, 35); cursor.EmitDelegate <Func <Item, int, int> >((weapon, ammoCount) => { foreach (BaseAmmoBag bag in GetAmmoBags(Main.LocalPlayer)) { ItemStorage storage = bag.GetItemStorage(); ammoCount += storage.Where(item => !item.IsAir && ItemLoader.CanChooseAmmo(weapon, item, Main.LocalPlayer)).Sum(item => item.stack); } return(ammoCount); }); cursor.Emit(OpCodes.Stloc, 35); } if (cursor.TryGotoNext(i => i.MatchLdloc(1), i => i.MatchLdfld <Item>("tileWand"), i => i.MatchLdcI4(0))) { cursor.Emit(OpCodes.Ldloc, 35); cursor.EmitDelegate <Func <int, int> >(bait => { foreach (FishingBelt bag in GetFishingBelts(Main.LocalPlayer)) { ItemStorage storage = bag.GetItemStorage(); bait += storage.Where(item => !item.IsAir && item.bait > 0).Sum(item => item.stack); } return(bait); }); cursor.Emit(OpCodes.Stloc, 35); } }