Emberveil sourcetests/PetClientAssetsCheck.java
import java.io.*;import java.awt.*;import java.awt.image.BufferedImage;import javax.imageio.ImageIO;
/** Real client decoders, models, animation frames and rendered inventory icons. */
public class PetClientAssetsCheck {
static int checks;static void check(boolean b,String s){checks++;if(!b)throw new AssertionError(s);}
public static void main(String[] args)throws Exception {
String root="runtime/pets-stage/cache/";
try(RandomAccessFile dat=new RandomAccessFile(root+"main_file_cache.dat","r")){
RandomAccessFile[] idx=new RandomAccessFile[5];Decompressor[] stores=new Decompressor[5];try{
for(int i=0;i<5;i++){idx[i]=new RandomAccessFile(root+"main_file_cache.idx"+i,"r");stores[i]=new Decompressor(dat,idx[i],i+1);}
StreamLoader cfg=new StreamLoader(stores[0].decompress(2)),ver=new StreamLoader(stores[0].decompress(5));ItemDef.unpackConfig(cfg);EntityDef.unpackConfig(cfg);Animation.unpackConfig(cfg);Model.method459(65000,new OnDemandFetcher());Class36.method528(65535);
Stream mv=new Stream(ver.getDataForName("model_version"));for(int i=0;i<mv.buffer.length/2;i++)if(mv.readUnsignedWord()!=0)Model.method460(GodWarsAssetCheck.inflate(stores[1].decompress(i)),i);
Stream av=new Stream(ver.getDataForName("anim_version"));for(int i=0;i<av.buffer.length/2;i++)if(av.readUnsignedWord()!=0)Class36.method529(GodWarsAssetCheck.inflate(stores[2].decompress(i)));
StreamLoader textures=new StreamLoader(stores[0].decompress(6));Texture.method368(textures);Texture.method372(.8);
DrawingArea.initDrawingArea(340,800,new int[800*340]);Texture.method364();BufferedImage image=new BufferedImage(800,340,BufferedImage.TYPE_INT_RGB);Graphics2D g=image.createGraphics();g.setColor(new Color(27,29,24));g.fillRect(0,0,800,340);
for(int j=0;j<19;j++){
int item=14800+j,npc=3981+j;ItemDef d=ItemDef.forID(item);EntityDef n=EntityDef.forID(npc);check(d.name!=null,"item name "+item);check(n.name!=null,"pet NPC name "+npc);check(n.aByte68==1,"single tile pet "+npc);
for(int seq:new int[]{n.anInt77,n.anInt67}){check(seq>=20000&&seq<Animation.anims.length,"isolated pet sequence "+seq);for(int frame:Animation.anims[seq].anIntArray353)check(Class36.method531(frame)!=null,"loaded pet frame "+frame);}
Model model=n.method164(-1,Animation.anims[n.anInt77].anIntArray353[0],null);check(model!=null,"animated follower "+npc);
Sprite icon=ItemDef.getSprite(item,1,0);check(icon!=null,"real pet icon "+item);int pixels=0;for(int v:icon.pixels)if(v>1)pixels++;check(pixels>12,"nonempty icon "+item);
int x=(j%5)*160+64,y=(j/5)*82+8;for(int yy=0;yy<32;yy++)for(int xx=0;xx<32;xx++)if(icon.pixels[yy*32+xx]>1)image.setRGB(x+xx,y+yy,icon.pixels[yy*32+xx]);g.setColor(Color.WHITE);g.drawString(n.name,x-50,y+52);
}
for(int id:new int[]{9760,14996}){ItemDef d=ItemDef.forID(id);check(d.name!=null&&d.name.toLowerCase().contains("cape"),"cape name "+id);for(int gender=0;gender<2;gender++)check(d.method195(gender)&&d.method196(gender)!=null,"cape wearable "+id+" gender "+gender);check(ItemDef.getSprite(id,1,0)!=null,"cape icon "+id);}
g.dispose();ImageIO.write(image,"png",new File("runtime/pets-stage/pets-preview.png"));System.out.println("PASS "+checks+" real client pet/cape asset and animation checks");
}finally{for(RandomAccessFile f:idx)if(f!=null)f.close();}
}
}
}