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

The following examples show how to use net.runelite.api.GameObject#getWorldLocation() . 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: MiningPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private 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 2
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 3
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 4
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 5
Source File: HunterTrap.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor for a HunterTrap object
 *
 * @param gameObject The gameobject thats corresponds with this trap.
 */
HunterTrap(final GameObject gameObject)
{
	this.state = State.OPEN;
	this.placedOn = Instant.now();
	this.objectId = gameObject.getId();
	this.worldLocation = gameObject.getWorldLocation();
}
 
Example 6
Source File: TitheFarmPlant.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
TitheFarmPlant(final TitheFarmPlantState state, final TitheFarmPlantType type, final GameObject gameObject)
{
	this.planted = Instant.now();
	this.state = state;
	this.type = type;
	this.gameObject = gameObject;
	this.worldLocation = gameObject.getWorldLocation();
}
 
Example 7
Source File: TitheFarmPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private TitheFarmPlant getPlantFromCollection(GameObject gameObject)
{
	WorldPoint gameObjectLocation = gameObject.getWorldLocation();
	for (TitheFarmPlant plant : plants)
	{
		if (gameObjectLocation.equals(plant.getWorldLocation()))
		{
			return plant;
		}
	}
	return null;
}
 
Example 8
Source File: BatsLocator.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
public void chestSpawnEvent(GameObject chestObject)
{
	WorldPoint chestLocation = chestObject.getWorldLocation();
	Chest chest = chests.get(chestLocation);
	if (chest == null)
	{
		chest = new Chest(chestLocation);
		chests.put(chestLocation, chest);
		switch (chestObject.getId())
		{
			case OPENED_POISON_OR_BATS:
				poisonBatsChests.add(chest);
				break;
			case OPENED_WITHOUT_GRUBS:
			case OPENED_WITH_GRUBS:
				grubsChests.add(chest);
				break;
		}
		//This code is repeated at the trough spawn event since the room type may not have been set when the last chest spawns, same goes for the rotation.
		assignChestNumbersAndGenerateSolutionSets();
	}
	else
	{
		switch (chestObject.getId())
		{
			case OPENED_POISON_OR_BATS:
				poisonBatsChests.add(chest);
				openChest(chest, Chest.State.POISON);
				break;
			case OPENED_WITHOUT_GRUBS:
			case OPENED_WITH_GRUBS:
				grubsChests.add(chest);
				openChest(chest, Chest.State.GRUBS);
				break;
		}
	}
}
 
Example 9
Source File: HunterTrap.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Constructor for a HunterTrap object
 *
 * @param gameObject The gameobject thats corresponds with this trap.
 */
HunterTrap(GameObject gameObject)
{
	this.state = State.OPEN;
	this.placedOn = Instant.now();
	this.objectId = gameObject.getId();
	this.worldLocation = gameObject.getWorldLocation();
}
 
Example 10
Source File: TitheFarmPlant.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
TitheFarmPlant(TitheFarmPlantState state, TitheFarmPlantType type, GameObject gameObject)
{
	this.planted = Instant.now();
	this.state = state;
	this.type = type;
	this.gameObject = gameObject;
	this.worldLocation = gameObject.getWorldLocation();
}
 
Example 11
Source File: TitheFarmPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private TitheFarmPlant getPlantFromCollection(GameObject gameObject)
{
	WorldPoint gameObjectLocation = gameObject.getWorldLocation();
	for (TitheFarmPlant plant : plants)
	{
		if (gameObjectLocation.equals(plant.getWorldLocation()))
		{
			return plant;
		}
	}
	return null;
}