Jump to content

Custom - stop preloading custom models


Adam
 Share

Recommended Posts

A lot of customs nowadays have a 'raw' folder in their cache, and a preload method during client startup, caching thousands of models will heavily increase your memory usage.

 

First, remove the method your using to preload your models, this is usually found in Client.java and is usually called void preloadModels()

 

Next, go to Model.java and place the changes or methods yourself - WARNING THAT THIS IS ON A RUSE CLIENT AND VARIABLE NAMES AND/OR METHOD NAMES MAY BE DIFFERENT TO YOURS

 

public static Model fetchModel(int j) 
{
   if (modelHeader == null)
      return null;
   if (j == 0)
      return null;
   ModelHeader class21 = modelHeader[j];
   if (class21 == null) {
      File file = new File(signlink.findcachedir() + "data/raw/" + j + ".dat");
      if(file.exists()) {
         byte[] buffer = ReadFile(signlink.findcachedir() + "data/raw/" + j + ".dat");
         readFirstModelData(buffer, j);
         return new Model(j);
      }
      resourceManager.get(j);
      return null;
   } else {
      return new Model(j);
   }
}
public static boolean modelIsFetched(int i) {
   if (modelHeader == null)
      return false;
   ModelHeader class21 = modelHeader[i];
   if (class21 == null) {
      File file = new File(signlink.findcachedir() + "data/raw/" + i + ".dat");
      if(file.exists()) {
         byte[] buffer = ReadFile(signlink.findcachedir() + "data/raw/" + i + ".dat");
         readFirstModelData(buffer, i);
         return true;
      }
      resourceManager.get(i);
      return false;
   } else {
      return true;
   }
}

 

This will now only load the models as you need them.

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share