net.runelite.api.GameObject Java Examples

The following examples show how to use net.runelite.api.GameObject. 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: WoodcuttingTreesOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void renderAxes(Graphics2D graphics)
{
	if (plugin.getSession() == null || !config.showRedwoodTrees())
	{
		return;
	}

	Axe axe = plugin.getAxe();
	if (axe == null)
	{
		return;
	}

	for (GameObject treeObject : plugin.getTreeObjects())
	{
		if (treeObject.getWorldLocation().distanceTo(client.getLocalPlayer().getWorldLocation()) <= 12)
		{
			OverlayUtil.renderImageLocation(client, graphics, treeObject.getLocalLocation(), itemManager.getImage(axe.getItemId()), 120);
		}
	}
}
 
Example #2
Source File: ZalcanoOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderRedSymbols(Graphics2D graphics)
{
	List<GameObject> symbolsToRender = util.getRedSymbols();

	if (symbolsToRender != null)
	{
		for (GameObject gameObject : symbolsToRender)
		{
			final LocalPoint loc = gameObject.getLocalLocation();
			final Polygon poly = Perspective.getCanvasTileAreaPoly(client, loc, 3);
			if (poly != null)
			{
				OverlayUtil.renderPolygon(graphics, poly, new Color(249, 47, 30));
			}
		}
	}
}
 
Example #3
Source File: BlastFurnaceClickBoxOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void renderObject(GameObject object, Graphics2D graphics, Color color)
{
	LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
	Point mousePosition = client.getMouseCanvasPosition();

	LocalPoint location = object.getLocalLocation();

	if (localLocation.distanceTo(location) <= MAX_DISTANCE)
	{
		Shape objectClickbox = object.getClickbox();
		if (objectClickbox != null)
		{
			if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
			{
				graphics.setColor(color.darker());
			}
			else
			{
				graphics.setColor(color);
			}
			graphics.draw(objectClickbox);
			graphics.setColor(new Color(0xFF, 0, 0, 20));
			graphics.fill(objectClickbox);
		}
	}
}
 
Example #4
Source File: BlastFurnacePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject gameObject = event.getGameObject();

	switch (gameObject.getId())
	{
		case CONVEYOR_BELT:
			conveyorBelt = gameObject;
			break;

		case BAR_DISPENSER:
			barDispenser = gameObject;
			break;
	}
}
 
Example #5
Source File: BlastFurnacePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event)
{
	GameObject gameObject = event.getGameObject();

	switch (gameObject.getId())
	{
		case CONVEYOR_BELT:
			conveyorBelt = null;
			break;

		case BAR_DISPENSER:
			barDispenser = null;
			break;
	}
}
 
Example #6
Source File: CannonPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject gameObject = event.getGameObject();

	Player localPlayer = client.getLocalPlayer();
	if (gameObject.getId() == CANNON_BASE && !cannonPlaced)
	{
		if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2
			&& localPlayer.getAnimation() == AnimationID.BURYING_BONES)
		{
			cannonPosition = gameObject.getWorldLocation();
			cannon = gameObject;
		}
	}
}
 
Example #7
Source File: MiningPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	if (client.getGameState() != GameState.LOGGED_IN || recentlyLoggedIn)
	{
		return;
	}

	GameObject object = event.getGameObject();
	Rock rock = Rock.getRock(object.getId());

	// Inverse timer to track daeyalt essence active duration
	if (rock == Rock.DAEYALT_ESSENCE)
	{
		final int region = client.getLocalPlayer().getWorldLocation().getRegionID();
		RockRespawn rockRespawn = new RockRespawn(rock, object.getWorldLocation(), Instant.now(), (int) rock.getRespawnTime(region).toMillis(), rock.getZOffset());
		respawns.add(rockRespawn);
	}
	// If the Lovakite ore respawns before the timer is up, remove it
	else if (rock == Rock.LOVAKITE)
	{
		final WorldPoint point = object.getWorldLocation();
		respawns.removeIf(rockRespawn -> rockRespawn.getWorldPoint().equals(point));
	}
}
 
Example #8
Source File: PohPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();

	if (!BURNER_LIT.contains(gameObject.getId()) && !BURNER_UNLIT.contains(gameObject.getId()))
	{
		if (PohIcons.getIcon(gameObject.getId()) != null)
		{
			pohObjects.put(gameObject, event.getTile());
		}

		return;
	}

	final double countdownTimer = 130.0; // Minimum amount of seconds a burner will light
	final double randomTimer = 30.0; // Minimum amount of seconds a burner will light
	incenseBurners.put(event.getTile(), new IncenseBurner(gameObject.getId(), countdownTimer, randomTimer, null));
}
 
Example #9
Source File: WoodcuttingTreesOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderAxes(Graphics2D graphics)
{
	if (plugin.getSession() == null || !config.showRedwoodTrees())
	{
		return;
	}

	Axe axe = plugin.getAxe();
	if (axe == null)
	{
		return;
	}

	for (GameObject treeObject : plugin.getTreeObjects())
	{
		if (treeObject.getWorldLocation().distanceTo(client.getLocalPlayer().getWorldLocation()) <= 12)
		{
			OverlayUtil.renderImageLocation(client, graphics, treeObject.getLocalLocation(), itemManager.getImage(axe.getItemId()), 120);
		}
	}
}
 
Example #10
Source File: BlastMinePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();
	BlastMineRockType blastMineRockType = BlastMineRockType.getRockType(gameObject.getId());
	if (blastMineRockType == null)
	{
		return;
	}

	final BlastMineRock newRock = new BlastMineRock(gameObject, blastMineRockType);
	final BlastMineRock oldRock = rocks.get(gameObject.getWorldLocation());

	if (oldRock == null || oldRock.getType() != newRock.getType())
	{
		rocks.put(gameObject.getWorldLocation(), newRock);
	}
}
 
Example #11
Source File: ZalcanoOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderRockToMine(Graphics2D graphics)
{
	GameObject glowingRock = util.getGlowingRock();

	if (glowingRock != null)
	{
		final Polygon poly = Perspective.getCanvasTileAreaPoly(client, glowingRock.getLocalLocation(), !util.projectileExists() ? 2 : 4);

		if (poly != null)
		{
			final Color green = new Color(140, 255, 60);
			OverlayUtil.renderPolygon(graphics, poly, !util.projectileExists() ? green : Color.RED);
			OverlayUtil.renderTextLocation(graphics, glowingRock.getCanvasLocation(), !util.projectileExists() ? ZalcanoUtil.mine : ZalcanoUtil.warning, !util.projectileExists() ? green : Color.RED);
		}
	}
}
 
Example #12
Source File: ZalcanoUtil.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
GameObject getGlowingRock()
{
	for (GameObject gameObject : getGameObjects())
	{
		if (gameObject != null)
		{
			if (gameObject.getId() == ObjectID.ROCK_FORMATION_GLOWING)
			{
				if (client.getLocalPlayer().getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= 2400)
				{
					Entity entity = gameObject.getEntity();
					if (entity instanceof DynamicObject)
					{
						if (((DynamicObject) entity).getAnimationID() == AnimationID.ZALCANO_ROCK_GLOWING)
						{
							return gameObject;
						}
					}
				}
			}
		}
	}
	return null;
}
 
Example #13
Source File: ZalcanoUtil.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
List<GameObject> getRedSymbols()
{
	List<GameObject> list = new ArrayList<>();
	for (GameObject gameObject : getGameObjects())
	{
		if (gameObject != null)
		{
			if (gameObject.getId() == ObjectID.DEMONIC_SYMBOL)
			{
				if (client.getLocalPlayer().getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= 2400)
				{
					Entity entity = gameObject.getEntity();
					if (entity instanceof DynamicObject)
					{
						list.add(gameObject);
					}
				}
			}
		}
	}
	return list.size() > 0 ? list : null;
}
 
Example #14
Source File: DevToolsOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void renderGameObjects(Graphics2D graphics, Tile tile, Player player)
{
	GameObject[] gameObjects = tile.getGameObjects();
	if (gameObjects != null)
	{
		for (GameObject gameObject : gameObjects)
		{
			if (gameObject != null)
			{
				if (player.getLocalLocation().distanceTo(gameObject.getLocalLocation()) <= MAX_DISTANCE)
				{
					OverlayUtil.renderTileOverlay(graphics, gameObject, "ID: " + gameObject.getId(), GREEN);
				}

				// Draw a polygon around the convex hull
				// of the model vertices
				Shape p = gameObject.getConvexHull();
				if (p != null)
				{
					graphics.draw(p);
				}
			}
		}
	}
}
 
Example #15
Source File: PohPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();

	if (!BURNER_LIT.contains(gameObject.getId()) && !BURNER_UNLIT.contains(gameObject.getId()))
	{
		if (PohIcons.getIcon(gameObject.getId()) != null)
		{
			pohObjects.put(gameObject, event.getTile());
		}

		return;
	}

	final double countdownTimer = 130.0; // Minimum amount of seconds a burner will light
	final double randomTimer = 30.0; // Minimum amount of seconds a burner will light
	incenseBurners.put(event.getTile(), new IncenseBurner(gameObject.getId(), countdownTimer, randomTimer, null));
}
 
Example #16
Source File: MotherlodePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectChanged(GameObjectChanged event)
{
	if (!inMlm)
	{
		return;
	}

	GameObject previous = event.getPrevious();
	GameObject gameObject = event.getGameObject();

	rocks.remove(previous);
	if (ROCK_OBSTACLES.contains(gameObject.getId()))
	{
		rocks.add(gameObject);
	}

}
 
Example #17
Source File: BatsLocatorPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject gameObject = event.getGameObject();
	switch (gameObject.getId())
	{
		case TROUGH:
			batsLocator.troughSpawnEvent(gameObject);
			break;
		case CLOSED:
		case OPENED_POISON_OR_BATS:
		case OPENED_WITHOUT_GRUBS:
		case OPENED_WITH_GRUBS:
			batsLocator.chestSpawnEvent(gameObject);
			break;
	}
}
 
Example #18
Source File: BarrowsOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderLadders(Graphics2D graphics, GameObject ladder)
{
	net.runelite.api.Point minimapLocation = ladder.getMinimapLocation();

	if (minimapLocation == null)
	{
		return;
	}

	ObjectDefinition objectComp = client.getObjectDefinition(ladder.getId());

	if (objectComp.getImpostorIds() != null && objectComp.getImpostor() != null)
	{
		graphics.setColor(Color.orange);
		graphics.fillRect(minimapLocation.getX(), minimapLocation.getY(), 6, 6);
	}
}
 
Example #19
Source File: PyramidPlunderPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject object = event.getGameObject();

	if (SPEARTRAP_ID == object.getId())
	{
		tilesToHighlight.put(object, event.getTile());
	}
	else if (URN_IDS.contains(object.getId())
		|| GRAND_GOLD_CHEST_ID == object.getId()
		|| SARCOPHAGUS_ID == object.getId())
	{
		objectsToHighlight.add(object);
	}
}
 
Example #20
Source File: DriftNetPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event)
{
	GameObject object = event.getGameObject();
	if (object == annette)
	{
		annette = null;
	}

	for (DriftNet net : NETS)
	{
		if (net.getObjectId() == object.getId())
		{
			net.setNet(null);
		}
	}
}
 
Example #21
Source File: BlastFurnaceClickBoxOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderObject(GameObject object, Graphics2D graphics, Color color)
{
	LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
	Point mousePosition = client.getMouseCanvasPosition();

	LocalPoint location = object.getLocalLocation();

	if (localLocation.distanceTo(location) <= MAX_DISTANCE)
	{
		Shape objectClickbox = object.getClickbox();
		if (objectClickbox != null)
		{
			if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
			{
				graphics.setColor(color.darker());
			}
			else
			{
				graphics.setColor(color);
			}
			graphics.draw(objectClickbox);
			graphics.setColor(new Color(0xFF, 0, 0, 20));
			graphics.fill(objectClickbox);
		}
	}
}
 
Example #22
Source File: BlastFurnacePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject gameObject = event.getGameObject();

	switch (gameObject.getId())
	{
		case CONVEYOR_BELT:
			conveyorBelt = gameObject;
			break;

		case BAR_DISPENSER:
			barDispenser = gameObject;
			break;
	}
}
 
Example #23
Source File: BlastFurnacePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectDespawned(GameObjectDespawned event)
{
	GameObject gameObject = event.getGameObject();

	switch (gameObject.getId())
	{
		case CONVEYOR_BELT:
			conveyorBelt = null;
			break;

		case BAR_DISPENSER:
			barDispenser = null;
			break;
	}
}
 
Example #24
Source File: ThievingPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectDespawned(GameObjectDespawned event)
{
	if (client.getGameState() != GameState.LOGGED_IN || recentlyLoggedIn)
	{
		return;
	}

	final GameObject object = event.getGameObject();

	Chest chest = Chest.of(object.getId());
	if (chest != null)
	{
		ChestRespawn chestRespawn = new ChestRespawn(chest, object.getWorldLocation(), Instant.now().plus(chest.getRespawnTime()), client.getWorld());
		respawns.add(chestRespawn);
	}
}
 
Example #25
Source File: BlastMinePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event)
{
	final GameObject gameObject = event.getGameObject();
	BlastMineRockType blastMineRockType = BlastMineRockType.getRockType(gameObject.getId());
	if (blastMineRockType == null)
	{
		return;
	}

	final BlastMineRock newRock = new BlastMineRock(gameObject, blastMineRockType);
	final BlastMineRock oldRock = rocks.get(gameObject.getWorldLocation());

	if (oldRock == null || oldRock.getType() != newRock.getType())
	{
		rocks.put(gameObject.getWorldLocation(), newRock);
	}
}
 
Example #26
Source File: DriftNetPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject object = event.getGameObject();
	if (object.getId() == ObjectID.ANNETTE)
	{
		annette = object;
	}

	for (DriftNet net : NETS)
	{
		if (net.getObjectId() == object.getId())
		{
			net.setNet(object);
		}
	}
}
 
Example #27
Source File: ExtUtils.java    From ExternalPlugins with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
public TileObject findNearestObject(int... ids)
{
	GameObject gameObject = findNearestGameObject(ids);

	if (gameObject != null)
	{
		return gameObject;
	}

	WallObject wallObject = findNearestWallObject(ids);

	if (wallObject != null)
	{
		return wallObject;
	}
	DecorativeObject decorativeObject = findNearestDecorObject(ids);

	if (decorativeObject != null)
	{
		return decorativeObject;
	}

	return findNearestGroundObject(ids);
}
 
Example #28
Source File: DriftNetPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject object = event.getGameObject();

	if (object.getId() == ObjectID.ANNETTE)
	{
		annette = object;
	}

	for (DriftNet net : NETS)
	{
		if (net.getObjectId() == object.getId())
		{
			net.setNet(object);
		}
	}
}
 
Example #29
Source File: MotherlodePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameObjectChanged(GameObjectChanged event)
{
	if (!inMlm)
	{
		return;
	}

	GameObject previous = event.getPrevious();
	GameObject gameObject = event.getGameObject();

	rocks.remove(previous);
	if (ROCK_OBSTACLES.contains(gameObject.getId()))
	{
		rocks.add(gameObject);
	}

}
 
Example #30
Source File: PyramidPlunderPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event)
{
	GameObject object = event.getGameObject();

	if (SPEARTRAP_ID == object.getId())
	{
		tilesToHighlight.put(object, event.getTile());
	}
	else if (URN_IDS.contains(object.getId())
		|| GRAND_GOLD_CHEST_ID == object.getId()
		|| SARCOPHAGUS_ID == object.getId())
	{
		objectsToHighlight.add(object);
	}
}