use of net.runelite.cache.definitions.ItemDefinition 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.definitions.ItemDefinition in project runelite by runelite.
the class ItemManager method java.
public void java(File java) throws IOException {
System.setProperty("line.separator", "\n");
java.mkdirs();
File targ = new File(java, "ItemID.java");
try (PrintWriter fw = new PrintWriter(targ)) {
fw.println("/* This file is automatically generated. Do not edit. */");
fw.println("package net.runelite.api;");
fw.println("");
fw.println("public final class ItemID");
fw.println("{");
for (ItemDefinition def : items.values()) {
if (def.name.equalsIgnoreCase("NULL")) {
continue;
}
String name = namer.name(def.name, def.id);
if (name == null) {
continue;
}
fw.println(" public static final int " + name + " = " + def.id + ";");
}
fw.println("}");
}
}
use of net.runelite.cache.definitions.ItemDefinition in project runelite by runelite.
the class ItemManager method export.
public void export(File out) throws IOException {
out.mkdirs();
for (ItemDefinition def : items.values()) {
ItemExporter exporter = new ItemExporter(def);
File targ = new File(out, def.id + ".json");
exporter.exportTo(targ);
}
}
use of net.runelite.cache.definitions.ItemDefinition in project ostracker by OSTracker.
the class ItemRasterizer method rasterize.
public BufferedImage rasterize(int itemId) {
ItemDefinition definition = getItemDefinitionForId(itemId);
if (definition.placeholderTemplateId == -1 && definition.boughtTemplateId == -1) {
SpritePixels sprite = createItemSprite(definition, false, true);
if (sprite != null) {
try {
BufferedImage image = new BufferedImage(sprite.width, sprite.height, BufferedImage.TYPE_INT_ARGB);
for (int i = 0; i < sprite.width; ++i) {
for (int j = 0; j < sprite.height; ++j) {
int pixel = sprite.image[j * sprite.width + i];
if ((pixel & 0xFF000000) == 0 && (pixel & 0xFFFFFF) != 0) {
pixel |= 0xFF000000;
}
image.setRGB(i, j, pixel);
}
}
return image;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return null;
}
use of net.runelite.cache.definitions.ItemDefinition in project runelite by runelite.
the class ItemLoader method load.
public ItemDefinition load(int id, byte[] b) {
ItemDefinition def = new ItemDefinition(id);
InputStream is = new InputStream(b);
while (true) {
int opcode = is.readUnsignedByte();
if (opcode == 0) {
break;
}
this.decodeValues(opcode, def, is);
}
return def;
}
Aggregations