From 6caf6ec08c0d069d6b09917452840f864ce4a86e Mon Sep 17 00:00:00 2001 From: TheStonedTurtle <29030969+TheStonedTurtle@users.noreply.github.com> Date: Thu, 6 Dec 2018 11:45:53 -0800 Subject: [PATCH] ground items: fix "only show loot" Look up ground item based on item location instead of npc location --- .../main/java/net/runelite/client/game/ItemStack.java | 2 ++ .../main/java/net/runelite/client/game/LootManager.java | 4 ++-- .../client/plugins/grounditems/GroundItemsPlugin.java | 9 ++++----- .../client/plugins/loottracker/LootTrackerPlugin.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/ItemStack.java b/runelite-client/src/main/java/net/runelite/client/game/ItemStack.java index bc455e2cf8..0e708a5839 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ItemStack.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ItemStack.java @@ -25,10 +25,12 @@ package net.runelite.client.game; import lombok.Value; +import net.runelite.api.coords.LocalPoint; @Value public class ItemStack { private final int id; private final int quantity; + private final LocalPoint location; } diff --git a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java index c13e84ab65..3369f76aef 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java @@ -160,7 +160,7 @@ public class LootManager final Tile tile = itemSpawned.getTile(); final LocalPoint location = tile.getLocalLocation(); final int packed = location.getSceneX() << 8 | location.getSceneY(); - itemSpawns.put(packed, new ItemStack(item.getId(), item.getQuantity())); + itemSpawns.put(packed, new ItemStack(item.getId(), item.getQuantity(), location)); log.debug("Item spawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location); } @@ -186,7 +186,7 @@ public class LootManager return; } - itemSpawns.put(packed, new ItemStack(item.getId(), diff)); + itemSpawns.put(packed, new ItemStack(item.getId(), diff, location)); } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index a5a5cb4680..947587623f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -270,22 +270,21 @@ public class GroundItemsPlugin extends Plugin public void onNpcLootReceived(NpcLootReceived npcLootReceived) { Collection items = npcLootReceived.getItems(); - WorldPoint location = npcLootReceived.getNpc().getWorldLocation(); - lootReceived(items, location); + lootReceived(items); } @Subscribe public void onPlayerLootReceived(PlayerLootReceived playerLootReceived) { Collection items = playerLootReceived.getItems(); - WorldPoint location = playerLootReceived.getPlayer().getWorldLocation(); - lootReceived(items, location); + lootReceived(items); } - private void lootReceived(Collection items, WorldPoint location) + private void lootReceived(Collection items) { for (ItemStack itemStack : items) { + WorldPoint location = WorldPoint.fromLocal(client, itemStack.getLocation()); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location); GroundItem groundItem = collectedGroundItems.get(groundItemKey); if (groundItem != null) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index f5d835da1a..70ce6cc247 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -127,7 +127,7 @@ public class LootTrackerPlugin extends Plugin } if (quantity > 0) { - list.add(new ItemStack(item.getId(), item.getQuantity() + quantity)); + list.add(new ItemStack(item.getId(), item.getQuantity() + quantity, item.getLocation())); } else { @@ -241,7 +241,7 @@ public class LootTrackerPlugin extends Plugin // Convert container items to array of ItemStack final Collection items = Arrays.stream(container.getItems()) .filter(item -> item.getId() > 0) - .map(item -> new ItemStack(item.getId(), item.getQuantity())) + .map(item -> new ItemStack(item.getId(), item.getQuantity(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); if (!items.isEmpty())