Java Code Examples for net.runelite.api.GameObject#getSceneMaxLocation()

The following examples show how to use net.runelite.api.GameObject#getSceneMaxLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WoodcuttingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameObjectDespawned(final GameObjectDespawned event)
{
	final GameObject object = event.getGameObject();

	Tree tree = Tree.findTree(object.getId());
	if (tree != null)
	{
		if (tree.getRespawnTime() != null && !recentlyLoggedIn && currentPlane == object.getPlane())
		{
			Point max = object.getSceneMaxLocation();
			Point min = object.getSceneMinLocation();
			int lenX = max.getX() - min.getX();
			int lenY = max.getY() - min.getY();
			log.debug("Adding respawn timer for {} tree at {}", tree, object.getLocalLocation());

			final int region = client.getLocalPlayer().getWorldLocation().getRegionID();
			TreeRespawn treeRespawn = new TreeRespawn(tree, lenX, lenY, WorldPoint.fromScene(client, min.getX(), min.getY(), client.getPlane()), Instant.now(), (int) tree.getRespawnTime(region).toMillis());
			respawns.add(treeRespawn);
		}

		if (tree == Tree.REDWOOD)
		{
			treeObjects.remove(event.getGameObject());
		}
	}
}
 
Example 2
Source File: WoodcuttingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameObjectDespawned(final GameObjectDespawned event)
{
	final GameObject object = event.getGameObject();

	Tree tree = Tree.findTree(object.getId());
	if (tree != null)
	{
		if (tree.getRespawnTime() != null && !recentlyLoggedIn && currentPlane == object.getPlane())
		{
			Point max = object.getSceneMaxLocation();
			Point min = object.getSceneMinLocation();
			int lenX = max.getX() - min.getX();
			int lenY = max.getY() - min.getY();
			log.debug("Adding respawn timer for {} tree at {}", tree, object.getLocalLocation());

			final int region = client.getLocalPlayer().getWorldLocation().getRegionID();
			TreeRespawn treeRespawn = new TreeRespawn(tree, lenX, lenY, WorldPoint.fromScene(client, min.getX(), min.getY(), client.getPlane()), Instant.now(), (int) tree.getRespawnTime(region).toMillis());
			respawns.add(treeRespawn);
		}

		if (tree == Tree.REDWOOD)
		{
			treeObjects.remove(event.getGameObject());
		}
	}
}