Search in sources :

Example 1 with Replace

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

the class RSClientMixin method rl$runWidgetOnLoadListener.

@Replace("runWidgetOnLoadListener")
public static void rl$runWidgetOnLoadListener(int groupId) {
    rs$runWidgetOnLoadListener(groupId);
    RSWidget[][] widgets = client.getWidgets();
    boolean loaded = widgets != null && widgets[groupId] != null;
    if (loaded) {
        WidgetLoaded event = new WidgetLoaded();
        event.setGroupId(groupId);
        eventBus.post(event);
    }
}
Also used : WidgetLoaded(net.runelite.api.events.WidgetLoaded) Replace(net.runelite.api.mixins.Replace)

Example 2 with Replace

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

the class RSRegionMixin method rl$addItemPile.

@Replace("addItemPile")
public void rl$addItemPile(int plane, int x, int y, int hash, Renderable var5, int var6, Renderable var7, Renderable var8) {
    rs$addItemPile(plane, x, y, hash, var5, var6, var7, var8);
    Tile tile = getTiles()[plane][x][y];
    if (tile != null) {
        RSItemLayer itemLayer = (RSItemLayer) tile.getItemLayer();
        if (itemLayer != null) {
            itemLayer.setPlane(plane);
        }
    }
}
Also used : RSItemLayer(net.runelite.rs.api.RSItemLayer) Tile(net.runelite.api.Tile) Replace(net.runelite.api.mixins.Replace)

Example 3 with Replace

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

the class RSRegionMixin method rl$groundObjectSpawned.

@Replace("groundObjectSpawned")
public void rl$groundObjectSpawned(int plane, int x, int y, int hash, Renderable var5, int var6, int var7) {
    rs$groundObjectSpawned(plane, x, y, hash, var5, var6, var7);
    Tile tile = getTiles()[plane][x][y];
    if (tile != null) {
        RSGroundObject groundObject = (RSGroundObject) tile.getGroundObject();
        if (groundObject != null) {
            groundObject.setPlane(plane);
        }
    }
}
Also used : RSGroundObject(net.runelite.rs.api.RSGroundObject) Tile(net.runelite.api.Tile) Replace(net.runelite.api.mixins.Replace)

Example 4 with Replace

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

the class RSIndexDataBaseMixin method rl$getConfigData.

@Replace("getConfigData")
public byte[] rl$getConfigData(int archiveId, int fileId) {
    byte[] rsData = rs$getConfigData(archiveId, fileId);
    RSIndexData indexData = (RSIndexData) this;
    if (!OverlayIndex.hasOverlay(indexData.getIndex(), archiveId)) {
        return rsData;
    }
    InputStream in = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId);
    if (in == null) {
        log.warn("Missing overlay data for {}/{}", indexData.getIndex(), archiveId);
        return rsData;
    }
    InputStream in2 = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId + ".hash");
    if (rsData == null) {
        if (in2 != null) {
            log.warn("Hash file for non existing archive {}/{}", indexData.getIndex(), archiveId);
            return null;
        }
        log.debug("Adding archive {}/{}", indexData.getIndex(), archiveId);
        try {
            return ByteStreams.toByteArray(in);
        } catch (IOException ex) {
            log.warn("error loading archive replacement", ex);
        }
        return null;
    }
    if (in2 == null) {
        log.warn("Missing hash file for {}/{}", indexData.getIndex(), archiveId);
        return rsData;
    }
    HashCode rsDataHash = Hashing.sha256().hashBytes(rsData);
    String rsHash = BaseEncoding.base16().encode(rsDataHash.asBytes());
    try {
        String replaceHash = CharStreams.toString(new InputStreamReader(in2));
        if (replaceHash.equals(rsHash)) {
            log.debug("Replacing archive {}/{}", indexData.getIndex(), archiveId);
            return ByteStreams.toByteArray(in);
        }
        log.warn("Mismatch in overlaid cache archive hash for {}/{}: {} != {}", indexData.getIndex(), archiveId, replaceHash, rsHash);
    } catch (IOException ex) {
        log.warn("error checking hash", ex);
    }
    return rsData;
}
Also used : RSIndexData(net.runelite.rs.api.RSIndexData) HashCode(com.google.common.hash.HashCode) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOException(java.io.IOException) Replace(net.runelite.api.mixins.Replace)

Example 5 with Replace

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

the class RSRegionMixin method rl$addBoundaryDecoration.

@Replace("addBoundaryDecoration")
public void rl$addBoundaryDecoration(int plane, int x, int y, int hash, Renderable var5, Renderable var6, int var7, int var8, int var9, int var10, int var11, int var12) {
    rs$addBoundaryDecoration(plane, x, y, hash, var5, var6, var7, var8, var9, var10, var11, var12);
    Tile tile = getTiles()[plane][x][y];
    if (tile != null) {
        RSDecorativeObject object = (RSDecorativeObject) tile.getDecorativeObject();
        if (object != null) {
            object.setPlane(plane);
        }
    }
}
Also used : RSDecorativeObject(net.runelite.rs.api.RSDecorativeObject) Tile(net.runelite.api.Tile) Replace(net.runelite.api.mixins.Replace)

Aggregations

Replace (net.runelite.api.mixins.Replace)6 Tile (net.runelite.api.Tile)4 HashCode (com.google.common.hash.HashCode)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 WidgetLoaded (net.runelite.api.events.WidgetLoaded)1 RSDecorativeObject (net.runelite.rs.api.RSDecorativeObject)1 RSGroundObject (net.runelite.rs.api.RSGroundObject)1 RSIndexData (net.runelite.rs.api.RSIndexData)1 RSItemLayer (net.runelite.rs.api.RSItemLayer)1 RSWallObject (net.runelite.rs.api.RSWallObject)1