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);
}
}
}
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);
}
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);
}
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();
}
}
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();
}
}
}
Aggregations