Search in sources :

Example 1 with InventoryDefinition

use of net.runelite.cache.definitions.InventoryDefinition in project runelite by runelite.

the class InventoryManager method load.

public void load() throws IOException {
    InventoryLoader loader = new InventoryLoader();
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.INV.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile file : files.getFiles()) {
        InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
        inventories.add(inv);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Index(net.runelite.cache.fs.Index) InventoryLoader(net.runelite.cache.definitions.loaders.InventoryLoader) InventoryDefinition(net.runelite.cache.definitions.InventoryDefinition) FSFile(net.runelite.cache.fs.FSFile)

Example 2 with InventoryDefinition

use of net.runelite.cache.definitions.InventoryDefinition in project runelite by runelite.

the class InventoryLoader method load.

public InventoryDefinition load(int id, byte[] b) {
    InventoryDefinition def = new InventoryDefinition();
    def.id = id;
    InputStream is = new InputStream(b);
    while (true) {
        int opcode = is.readUnsignedByte();
        if (opcode == 0) {
            break;
        }
        if (opcode == 2) {
            def.size = is.readUnsignedShort();
        }
    }
    return def;
}
Also used : InputStream(net.runelite.cache.io.InputStream) InventoryDefinition(net.runelite.cache.definitions.InventoryDefinition)

Example 3 with InventoryDefinition

use of net.runelite.cache.definitions.InventoryDefinition in project runelite by runelite.

the class InventoryDumper method extract.

@Test
public void extract() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.INV.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            InventoryLoader loader = new InventoryLoader();
            InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
            Files.write(gson.toJson(inv), new File(outDir, inv.id + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} inventories to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) InventoryLoader(net.runelite.cache.definitions.loaders.InventoryLoader) InventoryDefinition(net.runelite.cache.definitions.InventoryDefinition) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Aggregations

InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)3 InventoryLoader (net.runelite.cache.definitions.loaders.InventoryLoader)2 Archive (net.runelite.cache.fs.Archive)2 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)2 FSFile (net.runelite.cache.fs.FSFile)2 Index (net.runelite.cache.fs.Index)2 Storage (net.runelite.cache.fs.Storage)2 File (java.io.File)1 Store (net.runelite.cache.fs.Store)1 InputStream (net.runelite.cache.io.InputStream)1 Test (org.junit.Test)1