File tree Expand file tree Collapse file tree
runelite-client/src/main/java/net/runelite/client/plugins/microbot/SulphurNaguaAIO Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package net .runelite .client .plugins .microbot .SulphurNaguaAIO ;
22
33import net .runelite .api .Skill ;
4+ import java .util .List ;
5+ import net .runelite .client .plugins .microbot .util .inventory .Rs2ItemModel ;
46import net .runelite .api .coords .WorldPoint ;
57import net .runelite .client .plugins .microbot .Microbot ;
68import net .runelite .client .plugins .microbot .Script ;
@@ -386,11 +388,20 @@ private boolean anyPotionOnGround() {
386388 }
387389
388390 private void drinkMoonlightPotion () {
389- for (int potionId : MOONLIGHT_POTION_IDS ) {
390- if (Rs2Inventory .hasItem (potionId )) {
391- if (Rs2Inventory .interact (potionId , "Drink" )) {
392- lastPotionDrinkTime = System .currentTimeMillis ();
393- break ;
391+ // 1. Get a list of all inventory items. The new API uses 'Rs2ItemModel'.
392+ List <Rs2ItemModel > inventoryItems = Rs2Inventory .all ();
393+
394+ // 2. Loop through the items in the order of the inventory slots.
395+ for (net .runelite .client .plugins .microbot .util .inventory .Rs2ItemModel item : inventoryItems ) {
396+ if (item != null ) {
397+ // 3. Check if the item is a moonlight potion using 'item.id' (the new way).
398+ if (MOONLIGHT_POTION_IDS .contains (item .getId ())) {
399+
400+ // 4. Drink the first one found and then stop.
401+ if (Rs2Inventory .interact (item .getId (), "Drink" )) {
402+ lastPotionDrinkTime = System .currentTimeMillis ();
403+ break ; // This stops the loop so you only drink one.
404+ }
394405 }
395406 }
396407 }
You can’t perform that action at this time.
0 commit comments