Search in sources :

Example 26 with Store

use of net.runelite.cache.fs.Store in project runelite by runelite.

the class FrameDumper 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 frameIndex = store.getIndex(IndexType.FRAMES);
        Index framemapIndex = store.getIndex(IndexType.FRAMEMAPS);
        for (Archive archive : frameIndex.getArchives()) {
            List<FrameDefinition> frames = new ArrayList<>();
            byte[] archiveData = storage.loadArchive(archive);
            byte[] contents = archive.decompress(archiveData);
            int framemapArchiveId = (contents[0] & 0xff) << 8 | contents[1] & 0xff;
            Archive framemapArchive = framemapIndex.getArchives().get(framemapArchiveId);
            archiveData = storage.loadArchive(framemapArchive);
            byte[] framemapContents = framemapArchive.decompress(archiveData);
            FramemapLoader fmloader = new FramemapLoader();
            FramemapDefinition framemap = fmloader.load(0, framemapContents);
            FrameLoader frameLoader = new FrameLoader();
            FrameDefinition frame = frameLoader.load(framemap, contents);
            frames.add(frame);
            Files.write(gson.toJson(frames), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} frames to {}", count, outDir);
}
Also used : FrameDefinition(net.runelite.cache.definitions.FrameDefinition) Archive(net.runelite.cache.fs.Archive) ArrayList(java.util.ArrayList) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) FramemapLoader(net.runelite.cache.definitions.loaders.FramemapLoader) Storage(net.runelite.cache.fs.Storage) FrameLoader(net.runelite.cache.definitions.loaders.FrameLoader) File(java.io.File) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition)

Example 27 with Store

use of net.runelite.cache.fs.Store 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)

Example 28 with Store

use of net.runelite.cache.fs.Store in project runelite by runelite.

the class KitDumperTest method test.

@Test
public void test() throws IOException {
    File dumpDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.IDENTKIT.getId());
        KitLoader loader = new KitLoader();
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            byte[] b = file.getContents();
            KitDefinition def = loader.load(file.getFileId(), b);
            Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} kits to {}", count, dumpDir);
}
Also used : KitDefinition(net.runelite.cache.definitions.KitDefinition) 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) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) KitLoader(net.runelite.cache.definitions.loaders.KitLoader) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 29 with Store

use of net.runelite.cache.fs.Store in project runelite by runelite.

the class MapImageDumperTest method dumpRegions.

@Test
@Ignore
public void dumpRegions() throws Exception {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    try (Store store = new Store(base)) {
        store.load();
        RegionLoader regionLoader = new RegionLoader(store);
        regionLoader.loadRegions();
        MapImageDumper dumper = new MapImageDumper(store);
        dumper.load();
        int z = 0;
        for (Region region : regionLoader.getRegions()) {
            File imageFile = new File(outDir, "img-" + z + "-" + region.getRegionID() + ".png");
            BufferedImage image = dumper.drawRegion(region, z);
            ImageIO.write(image, "png", imageFile);
        }
    }
}
Also used : Store(net.runelite.cache.fs.Store) Region(net.runelite.cache.region.Region) File(java.io.File) RegionLoader(net.runelite.cache.region.RegionLoader) BufferedImage(java.awt.image.BufferedImage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 30 with Store

use of net.runelite.cache.fs.Store in project runelite by runelite.

the class NpcManagerTest method test.

@Test
public void test() throws IOException {
    File dumpDir = folder.newFolder(), javaDir = folder.newFolder();
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        NpcManager dumper = new NpcManager(store);
        dumper.load();
        dumper.dump(dumpDir);
        dumper.java(javaDir);
    }
    logger.info("Dumped to {}, java {}", dumpDir, javaDir);
}
Also used : Store(net.runelite.cache.fs.Store) File(java.io.File) Test(org.junit.Test)

Aggregations

Store (net.runelite.cache.fs.Store)38 File (java.io.File)34 Test (org.junit.Test)32 Archive (net.runelite.cache.fs.Archive)21 Index (net.runelite.cache.fs.Index)20 Storage (net.runelite.cache.fs.Storage)18 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)9 FSFile (net.runelite.cache.fs.FSFile)9 Ignore (org.junit.Ignore)7 BufferedImage (java.awt.image.BufferedImage)4 IOException (java.io.IOException)3 CacheClient (net.runelite.cache.client.CacheClient)3 ModelLoader (net.runelite.cache.definitions.loaders.ModelLoader)3 TextureManager (net.runelite.cache.TextureManager)2 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 ModelDefinition (net.runelite.cache.definitions.ModelDefinition)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 FileData (net.runelite.cache.index.FileData)2 HandshakeResponseType (net.runelite.protocol.api.login.HandshakeResponseType)2 RemoteCache (com.ostracker.cache.RemoteCache)1