From 964b07206347be8729487fa5434be262da89a2a7 Mon Sep 17 00:00:00 2001 From: jordenjacobsen-ai <341741400+jordenjacobsen-ai@users.noreply.github.com> Date: Tue, 10 Nov 2026 23:29:10 -0500 Subject: [PATCH] Follow the True Tile Movement Animations model with the bar and tick number True Tile Movement Animations hides the player and draws its own model that follows the true tile, so the attack bar and the tick number (anchored to the hidden player) trail behind the visible character. Listen for the model location that plugin publishes as a PluginMessage and anchor both overlays to it while it is being published. Without that plugin, or when the location is stale, nothing changes. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01N4x6LN1VZySxxbTN4RuFHP --- .../attacktimer/AttackTimerBarOverlay.java | 2 +- .../AttackTimerMetronomePlugin.java | 72 +++++++++++++ .../AttackTimerMetronomeTileOverlay.java | 7 +- .../TrueTileModelLocationTest.java | 102 ++++++++++++++++++ 4 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/attacktimer/TrueTileModelLocationTest.java diff --git a/src/main/java/com/attacktimer/AttackTimerBarOverlay.java b/src/main/java/com/attacktimer/AttackTimerBarOverlay.java index 568d7e2..fe5b3b5 100644 --- a/src/main/java/com/attacktimer/AttackTimerBarOverlay.java +++ b/src/main/java/com/attacktimer/AttackTimerBarOverlay.java @@ -87,7 +87,7 @@ public Dimension render(Graphics2D graphics) } final int height = client.getLocalPlayer().getLogicalHeight() + config.heightOffset() + 5; - final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); + final LocalPoint localLocation = plugin.getLocalPlayerOverlayLocation(); if (localLocation == null) { return null; diff --git a/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java b/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java index 9270083..bf50489 100644 --- a/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java +++ b/src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java @@ -52,6 +52,7 @@ import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Tile; +import net.runelite.api.coords.LocalPoint; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.FakeXpDrop; import net.runelite.api.events.GameObjectDespawned; @@ -70,6 +71,7 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; +import net.runelite.client.events.PluginMessage; import net.runelite.client.game.ItemManager; import net.runelite.client.game.NPCManager; import net.runelite.client.plugins.Plugin; @@ -474,6 +476,76 @@ public void onGameTick(GameTick tick) ATTACK_SPEED.onTick(); } + // True Tile Movement Animations hides the player and draws its own model that follows the true tile. + // It publishes where that model is so overhead overlays can follow it instead of the hidden player. + private static final String TRUE_TILE_MOVEMENT_NAMESPACE = "true-tile-movement-animation"; + private static final String TRUE_TILE_MOVEMENT_MODEL_LOCATION = "local-player-model-location"; + private LocalPoint trueTileModelLocation = null; + private int trueTileModelTick = -1; + + @Subscribe + public void onPluginMessage(PluginMessage message) + { + if (!TRUE_TILE_MOVEMENT_NAMESPACE.equals(message.getNamespace()) + || !TRUE_TILE_MOVEMENT_MODEL_LOCATION.equals(message.getName())) + { + return; + } + + final Map data = message.getData(); + final Object x = data.get("x"); + final Object y = data.get("y"); + final Object worldView = data.get("worldView"); + if (Boolean.TRUE.equals(data.get("active")) + && x instanceof Integer && y instanceof Integer && worldView instanceof Integer) + { + trueTileModelLocation = new LocalPoint((Integer) x, (Integer) y, (Integer) worldView); + trueTileModelTick = client.getTickCount(); + } + else + { + trueTileModelLocation = null; + } + } + + /** + * Where True Tile Movement Animations is currently drawing the local player's model, or null when + * that plugin is not drawing one (not installed, turned off, or the real player is being shown). + */ + public LocalPoint getTrueTileModelLocation() + { + final LocalPoint modelLocation = trueTileModelLocation; + // The location is re-sent at least once per game tick, anything older is stale. + if (modelLocation == null || client.getTickCount() - trueTileModelTick > 2) + { + return null; + } + + final Player player = client.getLocalPlayer(); + final LocalPoint playerLocation = player == null ? null : player.getLocalLocation(); + if (playerLocation == null || playerLocation.getWorldView() != modelLocation.getWorldView()) + { + return null; + } + return modelLocation; + } + + /** + * Where overlays attached to the local player should be drawn: the True Tile Movement Animations + * model while that plugin is drawing one, otherwise the player itself. + */ + public LocalPoint getLocalPlayerOverlayLocation() + { + final LocalPoint modelLocation = getTrueTileModelLocation(); + if (modelLocation != null) + { + return modelLocation; + } + + final Player player = client.getLocalPlayer(); + return player == null ? null : player.getLocalLocation(); + } + @Override protected void startUp() throws Exception { diff --git a/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java b/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java index d5cb0b8..aa35783 100644 --- a/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java +++ b/src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java @@ -94,7 +94,8 @@ else if (config.fontType() == FontTypes.BOLD) graphics.setFont(new Font(config.fontType().toString(), Font.PLAIN, config.fontSize())); } - final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); + final LocalPoint modelLocation = plugin.getTrueTileModelLocation(); + final LocalPoint localLocation = modelLocation != null ? modelLocation : client.getLocalPlayer().getLocalLocation(); Point playerPoint = null; switch (config.ticksPosition()) @@ -108,7 +109,9 @@ else if (config.fontType() == FontTypes.BOLD) break; case BOTTOM: - playerPoint = player.getCanvasTextLocation(graphics, tickText, 10 + config.heightTickOffset()); + playerPoint = modelLocation != null + ? Perspective.getCanvasTextLocation(client, graphics, modelLocation, tickText, 10 + config.heightTickOffset()) + : player.getCanvasTextLocation(graphics, tickText, 10 + config.heightTickOffset()); break; case DEFAULT: diff --git a/src/test/java/com/attacktimer/TrueTileModelLocationTest.java b/src/test/java/com/attacktimer/TrueTileModelLocationTest.java new file mode 100644 index 0000000..dca39dd --- /dev/null +++ b/src/test/java/com/attacktimer/TrueTileModelLocationTest.java @@ -0,0 +1,102 @@ +package com.attacktimer; + +/* + * Copyright (c) 2026, jordenjacobsen-ai + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.mock; + +import java.util.HashMap; +import java.util.Map; +import net.runelite.api.Player; +import net.runelite.api.coords.LocalPoint; +import net.runelite.client.events.PluginMessage; +import org.junit.Test; + +public class TrueTileModelLocationTest extends IntegrationTests +{ + private static final int WORLD_VIEW = -1; + private static final LocalPoint PLAYER_LOCATION = new LocalPoint(6464, 6464, WORLD_VIEW); + private static final LocalPoint MODEL_LOCATION = new LocalPoint(6500, 6600, WORLD_VIEW); + + private static PluginMessage modelLocation(boolean active, LocalPoint location) + { + final Map data = new HashMap<>(); + data.put("active", active); + if (location != null) + { + data.put("x", location.getX()); + data.put("y", location.getY()); + data.put("worldView", location.getWorldView()); + } + return new PluginMessage("true-tile-movement-animation", "local-player-model-location", data); + } + + private void setTick(int tick) + { + lenient().when(mockedClient.getTickCount()).thenReturn(tick); + } + + @Test + public void overlaysFollowTheTrueTileModelOnlyWhileItIsPublished() + { + final Player player = mock(Player.class); + lenient().when(mockedClient.getLocalPlayer()).thenReturn(player); + lenient().when(player.getLocalLocation()).thenReturn(PLAYER_LOCATION); + setTick(100); + + // Without True Tile Movement Animations nothing changes + assertNull(underTest.getTrueTileModelLocation()); + assertEquals(PLAYER_LOCATION, underTest.getLocalPlayerOverlayLocation()); + + // Messages from other plugins are ignored + underTest.onPluginMessage(new PluginMessage("some-other-plugin", "local-player-model-location", modelLocation(true, MODEL_LOCATION).getData())); + assertNull(underTest.getTrueTileModelLocation()); + + // While the model is published the overlays follow it + underTest.onPluginMessage(modelLocation(true, MODEL_LOCATION)); + assertEquals(MODEL_LOCATION, underTest.getTrueTileModelLocation()); + assertEquals(MODEL_LOCATION, underTest.getLocalPlayerOverlayLocation()); + setTick(102); + assertEquals(MODEL_LOCATION, underTest.getLocalPlayerOverlayLocation()); + + // It is re-sent every game tick, so an old location means the other plugin stopped + setTick(103); + assertNull(underTest.getTrueTileModelLocation()); + assertEquals(PLAYER_LOCATION, underTest.getLocalPlayerOverlayLocation()); + + // Going back to the real player is announced explicitly + underTest.onPluginMessage(modelLocation(true, MODEL_LOCATION)); + assertEquals(MODEL_LOCATION, underTest.getLocalPlayerOverlayLocation()); + underTest.onPluginMessage(modelLocation(false, null)); + assertEquals(PLAYER_LOCATION, underTest.getLocalPlayerOverlayLocation()); + + // A model in another world view than the player is not used + underTest.onPluginMessage(modelLocation(true, new LocalPoint(6500, 6600, 3))); + assertEquals(PLAYER_LOCATION, underTest.getLocalPlayerOverlayLocation()); + } +}