Search in sources :

Example 1 with Store

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

the class ObjExporterTest method testExport.

@Test
@Ignore
public void testExport() throws Exception {
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        TextureManager tm = new TextureManager(store);
        tm.load();
        ModelLoader loader = new ModelLoader();
        ModelDefinition model = loader.load(9638, Files.readAllBytes(new File("D:\\rs\\07\\cache\\models\\9638.model").toPath()));
        ObjExporter exporter = new ObjExporter(tm, model);
        try (PrintWriter objWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.obj")));
            PrintWriter mtlWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.mtl")))) {
            exporter.export(objWriter, mtlWriter);
        }
    }
}
Also used : TextureManager(net.runelite.cache.TextureManager) ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) FileWriter(java.io.FileWriter) ModelDefinition(net.runelite.cache.definitions.ModelDefinition) Store(net.runelite.cache.fs.Store) File(java.io.File) PrintWriter(java.io.PrintWriter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with Store

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

the class ItemSpriteFactoryTest method test.

@Test
@Ignore
public void test() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        ItemManager itemManager = new ItemManager(store);
        itemManager.load();
        ModelProvider modelProvider = new ModelProvider() {

            @Override
            public ModelDefinition provide(int modelId) throws IOException {
                Index models = store.getIndex(IndexType.MODELS);
                Archive archive = models.getArchive(modelId);
                byte[] data = archive.decompress(store.getStorage().loadArchive(archive));
                ModelDefinition inventoryModel = new ModelLoader().load(modelId, data);
                return inventoryModel;
            }
        };
        SpriteManager spriteManager = new SpriteManager(store);
        spriteManager.load();
        TextureManager textureManager = new TextureManager(store);
        textureManager.load();
        for (ItemDefinition itemDef : itemManager.getItems()) {
            if (itemDef.name == null || itemDef.name.equalsIgnoreCase("null")) {
                continue;
            }
            try {
                BufferedImage sprite = ItemSpriteFactory.createSprite(itemManager, modelProvider, spriteManager, textureManager, itemDef.id, 1, 1, 3153952, false);
                File out = new File(outDir, itemDef.id + ".png");
                BufferedImage img = sprite;
                ImageIO.write(img, "PNG", out);
                ++count;
            } catch (Exception ex) {
                log.warn("error dumping item {}", itemDef.id, ex);
            }
        }
    }
    log.info("Dumped {} item images to {}", count, outDir);
}
Also used : Archive(net.runelite.cache.fs.Archive) ItemManager(net.runelite.cache.ItemManager) ModelProvider(net.runelite.cache.definitions.providers.ModelProvider) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) SpriteManager(net.runelite.cache.SpriteManager) BufferedImage(java.awt.image.BufferedImage) IOException(java.io.IOException) ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) TextureManager(net.runelite.cache.TextureManager) ModelDefinition(net.runelite.cache.definitions.ModelDefinition) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Store

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

the class DisassemblerTest method test.

@Test
public void test() throws IOException {
    File outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CLIENTSCRIPT);
        ScriptLoader loader = new ScriptLoader();
        for (Archive archive : index.getArchives()) {
            byte[] contents = archive.decompress(storage.loadArchive(archive));
            if (contents == null) {
                continue;
            }
            ScriptDefinition script = loader.load(0, contents);
            File outFile = new File(outDir, archive.getArchiveId() + ".rs2asm");
            Disassembler disassembler = new Disassembler();
            String out = disassembler.disassemble(script);
            Files.write(out.getBytes(), outFile);
            ++count;
        }
    }
    logger.info("Dumped {} scripts to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ScriptDefinition(net.runelite.cache.definitions.ScriptDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) ScriptLoader(net.runelite.cache.definitions.loaders.ScriptLoader) Test(org.junit.Test)

Example 4 with Store

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

the class CacheClientTest method test.

@Test
@Ignore
public void test() throws Exception {
    try (Store store = new Store(new File("D:\\rs\\07\\temp\\cache"))) {
        store.load();
        CacheClient c = new CacheClient(store, CacheProperties.getRsVersion());
        c.connect();
        CompletableFuture<HandshakeResponseType> handshake = c.handshake();
        HandshakeResponseType result = handshake.get();
        logger.info("Handshake result: {}", result);
        Assert.assertEquals(HandshakeResponseType.RESPONSE_OK, result);
        c.download();
        c.close();
        store.save();
    }
}
Also used : HandshakeResponseType(net.runelite.protocol.api.login.HandshakeResponseType) Store(net.runelite.cache.fs.Store) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Store

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

the class CacheServerTest method testDownload.

@Test
@Ignore
public void testDownload() throws Exception {
    try (Store store = new Store(StoreLocation.LOCATION);
        CacheServer server = new CacheServer(store, REVISION)) {
        store.load();
        server.start();
        try (CacheClient client = new CacheClient(new Store(folder.newFolder()), HOST, REVISION)) {
            client.connect();
            client.handshake().get();
            client.download();
        }
    }
}
Also used : CacheClient(net.runelite.cache.client.CacheClient) Store(net.runelite.cache.fs.Store) Ignore(org.junit.Ignore) 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 Stopwatch (com.google.common.base.Stopwatch)1