Java Code Examples for net.runelite.api.Client#getItemContainer()

The following examples show how to use net.runelite.api.Client#getItemContainer() . 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: EquipmentItemSetRequirement.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean meetsRequirements(Client client)
{
	ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	if (equipmentContainer == null)
	{
		return false;
	}
	Item[] equipedItems = equipmentContainer.getItems();

	return EquipmentHelper.wearsItemSet(equipedItems, this.itemSet);
}
 
Example 2
Source File: EquipmentItemRequirement.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean meetsRequirements(Client client)
{
	ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	if (equipmentContainer == null)
	{
		return false;
	}
	Item[] equipedItems = equipmentContainer.getItems();
	return EquipmentHelper.wearsItem(equipedItems, this.item);
}
 
Example 3
Source File: CastleWarsBandage.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StatsChanges calculate(Client client)
{
	final ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	final double percH = hasBracelet(equipmentContainer) ? BRACELET_HP_PERC : BASE_HP_PERC;
	final StatChange hitPoints = heal(HITPOINTS, perc(percH, 0)).effect(client);
	final StatChange runEnergy = heal(RUN_ENERGY, 30).effect(client);
	final StatsChanges changes = new StatsChanges(2);
	changes.setStatChanges(new StatChange[]{hitPoints, runEnergy});
	changes.setPositivity(Stream.of(changes.getStatChanges())
		.map(StatChange::getPositivity)
		.max(Comparator.comparing(Enum::ordinal)).get());

	return changes;
}
 
Example 4
Source File: PrayerPotion.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int heals(Client client)
{
	boolean hasHolyWrench = false;

	ItemContainer equipContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	if (equipContainer != null)
	{
		Item[] equip = equipContainer.getItems();
		final int ring = ItemUtil.safeGetItemIdAtIndex(equip, EquipmentInventorySlot.RING.getSlotIdx());
		final int cape = ItemUtil.safeGetItemIdAtIndex(equip, EquipmentInventorySlot.CAPE.getSlotIdx());

		hasHolyWrench = ring == ItemID.RING_OF_THE_GODS_I;
		hasHolyWrench |= HOLY_WRENCH_IDS.contains(cape);
	}
	if (!hasHolyWrench)
	{
		ItemContainer invContainer = client.getItemContainer(InventoryID.INVENTORY);
		if (invContainer != null)
		{
			hasHolyWrench = ItemUtil.containsAnyItemId(invContainer.getItems(), HOLY_WRENCH_IDS);
		}
	}

	double percent = hasHolyWrench ? perc + .02 : perc;
	int max = getStat().getMaximum(client);
	return (((int) (max * percent)) * (delta >= 0 ? 1 : -1)) + delta;
}
 
Example 5
Source File: CastleWarsBandage.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public StatsChanges calculate(Client client)
{
	final ItemContainer equipmentContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	final double percH = hasBracelet(equipmentContainer) ? BRACELET_HP_PERC : BASE_HP_PERC;
	final StatChange hitPoints = heal(HITPOINTS, perc(percH, 0)).effect(client);
	final StatChange runEnergy = heal(RUN_ENERGY, 30).effect(client);
	final StatsChanges changes = new StatsChanges(2);
	changes.setStatChanges(new StatChange[]{hitPoints, runEnergy});
	changes.setPositivity(Stream.of(changes.getStatChanges())
		.map(StatChange::getPositivity)
		.max(Comparator.comparing(Enum::ordinal)).get());

	return changes;
}
 
Example 6
Source File: PrayerPotion.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public int heals(Client client)
{
	boolean hasHolyWrench = false;

	ItemContainer equipContainer = client.getItemContainer(InventoryID.EQUIPMENT);
	if (equipContainer != null)
	{
		Item cape = equipContainer.getItem(CAPE_SLOT);
		Item ring = equipContainer.getItem(RING_SLOT);

		hasHolyWrench = ring != null && ring.getId() == ItemID.RING_OF_THE_GODS_I;
		if (cape != null)
		{
			int capeId = cape.getId();
			hasHolyWrench |= capeId == ItemID.PRAYER_CAPE;
			hasHolyWrench |= capeId == ItemID.PRAYER_CAPET;
			hasHolyWrench |= capeId == ItemID.PRAYER_CAPE_10643; // No idea what this is
			hasHolyWrench |= capeId == ItemID.MAX_CAPE;
			hasHolyWrench |= capeId == ItemID.MAX_CAPE_13282; // Or these
			hasHolyWrench |= capeId == ItemID.MAX_CAPE_13342;
		}
	}
	if (!hasHolyWrench)
	{
		ItemContainer invContainer = client.getItemContainer(InventoryID.INVENTORY);
		if (invContainer != null)
		{
			for (Item itemStack : invContainer.getItems())
			{
				int item = itemStack.getId();
				hasHolyWrench = item == ItemID.HOLY_WRENCH;
				hasHolyWrench |= item == ItemID.PRAYER_CAPE;
				hasHolyWrench |= item == ItemID.PRAYER_CAPET;
				hasHolyWrench |= item == ItemID.PRAYER_CAPE_10643;
				hasHolyWrench |= item == ItemID.MAX_CAPE;
				hasHolyWrench |= item == ItemID.MAX_CAPE_13282;
				hasHolyWrench |= item == ItemID.MAX_CAPE_13342;

				if (hasHolyWrench)
				{
					break;
				}
			}
		}
	}

	double percent = hasHolyWrench ? perc + .02 : perc;
	int max = getStat().getMaximum(client);
	return (((int) (max * percent)) * (delta >= 0 ? 1 : -1)) + delta;
}