Search in sources :

Example 6 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSClientMixin method cachedNPCsChanged.

@FieldHook("cachedNPCs")
@Inject
public static void cachedNPCsChanged(int idx) {
    RSNPC[] cachedNPCs = client.getCachedNPCs();
    if (idx < 0 || idx >= cachedNPCs.length) {
        return;
    }
    RSNPC npc = cachedNPCs[idx];
    if (npc != null) {
        npc.setIndex(idx);
    }
}
Also used : RSNPC(net.runelite.rs.api.RSNPC) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 7 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSClientMixin method settingsChanged.

@FieldHook("clientVarps")
@Inject
public static void settingsChanged(int idx) {
    VarbitChanged varbitChanged = new VarbitChanged();
    eventBus.post(varbitChanged);
}
Also used : VarbitChanged(net.runelite.api.events.VarbitChanged) Inject(net.runelite.api.mixins.Inject) FieldHook(net.runelite.api.mixins.FieldHook)

Example 8 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSClientMixin method getMenuEntries.

@Inject
@Override
public MenuEntry[] getMenuEntries() {
    int count = getMenuOptionCount();
    String[] menuOptions = getMenuOptions();
    String[] menuTargets = getMenuTargets();
    int[] menuIdentifiers = getMenuIdentifiers();
    int[] menuTypes = getMenuTypes();
    int[] params0 = getMenuActionParams0();
    int[] params1 = getMenuActionParams1();
    MenuEntry[] entries = new MenuEntry[count];
    for (int i = 0; i < count; ++i) {
        MenuEntry entry = entries[i] = new MenuEntry();
        entry.setOption(menuOptions[i]);
        entry.setTarget(menuTargets[i]);
        entry.setIdentifier(menuIdentifiers[i]);
        entry.setType(menuTypes[i]);
        entry.setParam0(params0[i]);
        entry.setParam1(params1[i]);
    }
    return entries;
}
Also used : MenuEntry(net.runelite.api.MenuEntry) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 9 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSClientMixin method getSkillExperience.

/**
 * Returns the local player's current experience in the specified
 * {@link Skill}.
 *
 * @param skill the {@link Skill} to retrieve the experience for
 * @return the local player's current experience in the specified
 * {@link Skill}, or -1 if the {@link Skill} isn't valid
 */
@Inject
@Override
public int getSkillExperience(Skill skill) {
    int[] experiences = getSkillExperiences();
    if (skill == Skill.OVERALL) {
        int totalExperience = 0;
        for (int experience : experiences) {
            totalExperience += experience;
        }
        return totalExperience;
    }
    int idx = skill.ordinal();
    // to hold something else that's not reported it'll save us from an ArrayIndexOutOfBoundsException.
    if (idx >= experiences.length) {
        return -1;
    }
    return experiences[idx];
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 10 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSClientMixin method getLocalDestinationLocation.

@Inject
@Override
@Nullable
public LocalPoint getLocalDestinationLocation() {
    int regionX = getDestinationX();
    int regionY = getDestinationY();
    if (regionX != 0 && regionY != 0) {
        return LocalPoint.fromRegion(regionX, regionY);
    }
    return null;
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject) Nullable(javax.annotation.Nullable)

Aggregations

Inject (net.runelite.api.mixins.Inject)57 Point (net.runelite.api.Point)20 FieldHook (net.runelite.api.mixins.FieldHook)20 ArrayList (java.util.ArrayList)14 LocalPoint (net.runelite.api.coords.LocalPoint)10 RSWidget (net.runelite.rs.api.RSWidget)6 Vertex (net.runelite.api.model.Vertex)5 Widget (net.runelite.api.widgets.Widget)5 Node (net.runelite.api.Node)4 RSNode (net.runelite.rs.api.RSNode)4 WidgetNode (net.runelite.api.WidgetNode)3 Triangle (net.runelite.api.model.Triangle)3 Polygon (java.awt.Polygon)2 MenuEntry (net.runelite.api.MenuEntry)2 Model (net.runelite.api.Model)2 NPC (net.runelite.api.NPC)2 Player (net.runelite.api.Player)2 Skill (net.runelite.api.Skill)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2 RSCombatInfoList (net.runelite.rs.api.RSCombatInfoList)2