Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/attacktimer/AttackTimerBarOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/attacktimer/AttackTimerMetronomePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String, Object> 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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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:
Expand Down
102 changes: 102 additions & 0 deletions src/test/java/com/attacktimer/TrueTileModelLocationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.attacktimer;

/*
* Copyright (c) 2026, jordenjacobsen-ai <https://github.com/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<String, Object> 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());
}
}