From c43b986a04c781c51f8f51b507122e49388b1c15 Mon Sep 17 00:00:00 2001 From: JMorris0n <87609077+JMorris0n@users.noreply.github.com> Date: Thu, 16 Jul 2026 14:32:44 -0800 Subject: [PATCH] Update RootEvent.java Replaced sleepUntil(() -> !Rs2Player.isInteracting(), 40000); with sleepUntil(() -> !Rs2Player.isAnimating() || !this.validate(), 40000); This ensures the loop blocks until the chopping animation stops or the root disappears. --- .../woodcutting/Forestry/RootEvent.java | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/runelite/client/plugins/microbot/woodcutting/Forestry/RootEvent.java b/src/main/java/net/runelite/client/plugins/microbot/woodcutting/Forestry/RootEvent.java index 490ddb7614..58e73f22b3 100644 --- a/src/main/java/net/runelite/client/plugins/microbot/woodcutting/Forestry/RootEvent.java +++ b/src/main/java/net/runelite/client/plugins/microbot/woodcutting/Forestry/RootEvent.java @@ -1,7 +1,6 @@ package net.runelite.client.plugins.microbot.woodcutting.Forestry; import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Actor; import net.runelite.api.gameval.ItemID; import net.runelite.api.gameval.ObjectID; import net.runelite.client.plugins.microbot.BlockingEvent; @@ -16,17 +15,19 @@ import net.runelite.client.plugins.microbot.woodcutting.enums.ForestryEvents; import static net.runelite.client.plugins.microbot.util.Global.sleepUntil; + @Slf4j public class RootEvent implements BlockingEvent { private final AutoWoodcuttingPlugin plugin; + public RootEvent(AutoWoodcuttingPlugin plugin) { this.plugin = plugin; } @Override public boolean validate() { - try{ + try { if (plugin == null || !Microbot.isPluginEnabled(plugin)) return false; if (Microbot.getClient() == null || !Microbot.isLoggedIn()) return false; var root = plugin.rs2TileObjectCache.query().where(x -> x.getId() == ObjectID.GATHERING_EVENT_RISING_ROOTS).nearest(); @@ -45,7 +46,6 @@ public boolean validate() { log.error("RootEvent: Exception in validate method", e); return false; } - } @Override @@ -65,35 +65,19 @@ public boolean execute() { // If special root is present if (specialRoot != null) { - - // Check if the player is already interacting with the special root - if (Rs2Player.isInteracting() && Rs2Player.getInteracting() != null) { - Actor interactingNpc = Microbot.getClient().getLocalPlayer().getInteracting(); - if (interactingNpc.getWorldLocation().equals(specialRoot.getWorldLocation())) { - continue; - } - } // Interact with the special root Microbot.log("RootEvent: Interacting with special root at " + specialRoot.getWorldLocation()); specialRoot.click("Chop down"); Rs2Player.waitForAnimation(5000); - sleepUntil(() -> !Rs2Player.isInteracting(), 40000); + sleepUntil(() -> !Rs2Player.isAnimating() || !this.validate(), 40000); } // If regular root is present else if (root != null) { - - // Check if the player is already interacting with the root - if (Rs2Player.isInteracting() && Rs2Player.getInteracting() != null) { - Actor interactingNpc = Microbot.getClient().getLocalPlayer().getInteracting(); - if (interactingNpc.getWorldLocation().equals(root.getWorldLocation())) { - continue; - } - } // Interact with the regular root Microbot.log("RootEvent: Interacting with regular root at " + root.getWorldLocation()); root.click("Chop down"); Rs2Player.waitForAnimation(5000); - sleepUntil(() -> !Rs2Player.isInteracting(), 40000); + sleepUntil(() -> !Rs2Player.isAnimating() || !this.validate(), 40000); } } plugin.incrementForestryEventCompleted();