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;
}
use of net.runelite.cache.definitions.ItemDefinition in project runelite by runelite.
the class ItemSpriteFactory method createSpritePixels.
private static final SpritePixels createSpritePixels(ItemProvider itemProvider, ModelProvider modelProvider, SpriteProvider spriteProvider, TextureProvider textureProvider, int itemId, int quantity, int border, int shadowColor, boolean noted) throws IOException {
ItemDefinition item = itemProvider.provide(itemId);
if (quantity > 1 && item.countObj != null) {
int stackItemID = -1;
for (int i = 0; i < 10; ++i) {
if (quantity >= item.countCo[i] && item.countCo[i] != 0) {
stackItemID = item.countObj[i];
}
}
if (stackItemID != -1) {
item = itemProvider.provide(stackItemID);
}
}
if (item.notedTemplate != -1) {
item.updateNote(itemProvider.provide(item.notedTemplate), itemProvider.provide(item.notedID));
}
Model itemModel = getModel(modelProvider, item);
if (itemModel == null) {
return null;
}
SpritePixels auxSpritePixels = null;
if (item.notedTemplate != -1) {
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider, item.notedID, 10, 1, 0, true);
if (auxSpritePixels == null) {
return null;
}
} else if (item.boughtTemplateId != -1) {
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider, item.boughtId, quantity, border, shadowColor, false);
if (auxSpritePixels == null) {
return null;
}
} else if (item.placeholderTemplateId != -1) {
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider, item.placeholderId, quantity, 0, 0, false);
if (auxSpritePixels == null) {
return null;
}
}
RSTextureProvider rsTextureProvider = new RSTextureProvider(textureProvider, spriteProvider);
SpritePixels spritePixels = new SpritePixels(36, 32);
Graphics3D graphics = new Graphics3D(rsTextureProvider);
graphics.setBrightness(0.6d);
graphics.setRasterBuffer(spritePixels.pixels, 36, 32);
graphics.reset();
graphics.setRasterClipping();
graphics.setOffset(16, 16);
graphics.rasterGouraudLowRes = false;
if (item.placeholderTemplateId != -1) {
auxSpritePixels.drawAtOn(graphics, 0, 0);
}
int zoom2d = item.zoom2d;
if (noted) {
zoom2d = (int) ((double) zoom2d * 1.5D);
} else if (border == 2) {
zoom2d = (int) ((double) zoom2d * 1.04D);
}
int var17 = zoom2d * Graphics3D.SINE[item.xan2d] >> 16;
int var18 = zoom2d * Graphics3D.COSINE[item.xan2d] >> 16;
itemModel.calculateBoundsCylinder();
itemModel.rotateAndProject(graphics, 0, item.yan2d, item.zan2d, item.xan2d, item.xOffset2d, itemModel.modelHeight / 2 + var17 + item.yOffset2d, var18 + item.yOffset2d);
if (item.boughtTemplateId != -1) {
auxSpritePixels.drawAtOn(graphics, 0, 0);
}
if (border >= 1) {
spritePixels.drawBorder(1);
}
if (border >= 2) {
spritePixels.drawBorder(0xffffff);
}
if (shadowColor != 0) {
spritePixels.drawShadow(shadowColor);
}
graphics.setRasterBuffer(spritePixels.pixels, 36, 32);
if (item.notedTemplate != -1) {
auxSpritePixels.drawAtOn(graphics, 0, 0);
}
graphics.setRasterBuffer(graphics.graphicsPixels, graphics.graphicsPixelsWidth, graphics.graphicsPixelsHeight);
graphics.setRasterClipping();
graphics.rasterGouraudLowRes = true;
return spritePixels;
}
use of net.runelite.cache.definitions.ItemDefinition in project runelite by runelite.
the class CacheController method getItem.
@RequestMapping("item/{itemId}")
public ItemDefinition getItem(@PathVariable int itemId) throws IOException {
ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM);
ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
if (archiveFiles == null) {
throw new NotFoundException();
}
FSFile file = archiveFiles.findFile(itemId);
if (file == null) {
throw new NotFoundException();
}
ItemDefinition itemdef = new ItemLoader().load(itemId, file.getContents());
return itemdef;
}
use of net.runelite.cache.definitions.ItemDefinition in project runelite by runelite.
the class ItemManager method load.
public void load() throws IOException {
ItemLoader loader = new ItemLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.ITEM.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles()) {
ItemDefinition def = loader.load(f.getFileId(), f.getContents());
items.put(f.getFileId(), def);
}
}
Aggregations