ground items: fix "only show loot"

Look up ground item based on item location instead of npc location
This commit is contained in:
TheStonedTurtle
2018-12-06 11:45:53 -08:00
committed by Adam
parent cb9038a69a
commit 6caf6ec08c
4 changed files with 10 additions and 9 deletions

View File

@@ -25,10 +25,12 @@
package net.runelite.client.game; package net.runelite.client.game;
import lombok.Value; import lombok.Value;
import net.runelite.api.coords.LocalPoint;
@Value @Value
public class ItemStack public class ItemStack
{ {
private final int id; private final int id;
private final int quantity; private final int quantity;
private final LocalPoint location;
} }

View File

@@ -160,7 +160,7 @@ public class LootManager
final Tile tile = itemSpawned.getTile(); final Tile tile = itemSpawned.getTile();
final LocalPoint location = tile.getLocalLocation(); final LocalPoint location = tile.getLocalLocation();
final int packed = location.getSceneX() << 8 | location.getSceneY(); 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); log.debug("Item spawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location);
} }
@@ -186,7 +186,7 @@ public class LootManager
return; return;
} }
itemSpawns.put(packed, new ItemStack(item.getId(), diff)); itemSpawns.put(packed, new ItemStack(item.getId(), diff, location));
} }
@Subscribe @Subscribe

View File

@@ -270,22 +270,21 @@ public class GroundItemsPlugin extends Plugin
public void onNpcLootReceived(NpcLootReceived npcLootReceived) public void onNpcLootReceived(NpcLootReceived npcLootReceived)
{ {
Collection<ItemStack> items = npcLootReceived.getItems(); Collection<ItemStack> items = npcLootReceived.getItems();
WorldPoint location = npcLootReceived.getNpc().getWorldLocation(); lootReceived(items);
lootReceived(items, location);
} }
@Subscribe @Subscribe
public void onPlayerLootReceived(PlayerLootReceived playerLootReceived) public void onPlayerLootReceived(PlayerLootReceived playerLootReceived)
{ {
Collection<ItemStack> items = playerLootReceived.getItems(); Collection<ItemStack> items = playerLootReceived.getItems();
WorldPoint location = playerLootReceived.getPlayer().getWorldLocation(); lootReceived(items);
lootReceived(items, location);
} }
private void lootReceived(Collection<ItemStack> items, WorldPoint location) private void lootReceived(Collection<ItemStack> items)
{ {
for (ItemStack itemStack : items) for (ItemStack itemStack : items)
{ {
WorldPoint location = WorldPoint.fromLocal(client, itemStack.getLocation());
GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location); GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location);
GroundItem groundItem = collectedGroundItems.get(groundItemKey); GroundItem groundItem = collectedGroundItems.get(groundItemKey);
if (groundItem != null) if (groundItem != null)

View File

@@ -127,7 +127,7 @@ public class LootTrackerPlugin extends Plugin
} }
if (quantity > 0) if (quantity > 0)
{ {
list.add(new ItemStack(item.getId(), item.getQuantity() + quantity)); list.add(new ItemStack(item.getId(), item.getQuantity() + quantity, item.getLocation()));
} }
else else
{ {
@@ -241,7 +241,7 @@ public class LootTrackerPlugin extends Plugin
// Convert container items to array of ItemStack // Convert container items to array of ItemStack
final Collection<ItemStack> items = Arrays.stream(container.getItems()) final Collection<ItemStack> items = Arrays.stream(container.getItems())
.filter(item -> item.getId() > 0) .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()); .collect(Collectors.toList());
if (!items.isEmpty()) if (!items.isEmpty())