Search in sources :

Example 1 with RSVarbit

use of net.runelite.rs.api.RSVarbit in project runelite by runelite.

the class VarbitMixin method getSetting.

@Inject
@Override
public int getSetting(Varbits varbit) {
    int varbitId = varbit.getId();
    RSVarbit v = varbitCache.getIfPresent(varbitId);
    if (v == null) {
        // load varbit into cache
        client.getVarbit(varbitId);
        RSNodeCache varbits = client.getVarbitCache();
        // get from cache
        v = (RSVarbit) varbits.get(varbitId);
        varbitCache.put(varbitId, v);
    }
    int[] varps = getVarps();
    int value = varps[v.getIndex()];
    int lsb = v.getLeastSignificantBit();
    int msb = v.getMostSignificantBit();
    int mask = (1 << ((msb - lsb) + 1)) - 1;
    return (value >> lsb) & mask;
}
Also used : RSVarbit(net.runelite.rs.api.RSVarbit) RSNodeCache(net.runelite.rs.api.RSNodeCache) Inject(net.runelite.api.mixins.Inject)

Aggregations

Inject (net.runelite.api.mixins.Inject)1 RSNodeCache (net.runelite.rs.api.RSNodeCache)1 RSVarbit (net.runelite.rs.api.RSVarbit)1