Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/ClientCacheHandler.java
T

28 lines
1.2 KiB
Java
Raw Normal View History

2023-05-30 23:41:37 -05:00
package noppes.npcs.client;
2023-06-02 04:22:00 -04:00
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.renderer.ImageData;
2023-06-03 17:23:40 -04:00
import noppes.npcs.config.ConfigClient;
2023-05-30 23:41:37 -05:00
import noppes.npcs.util.CacheHashMap;
public class ClientCacheHandler {
2023-06-03 17:23:40 -04:00
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>((long) ConfigClient.CacheLife * 60 * 1000);
2023-05-30 23:41:37 -05:00
public static ImageData getImageData(String directory) {
synchronized (imageDataCache) {
if (!imageDataCache.containsKey(directory)) {
imageDataCache.put(directory, new CacheHashMap.CachedObject<>(new ImageData(directory)));
}
return imageDataCache.get(directory).getObject();
2023-05-30 23:41:37 -05:00
}
}
2023-06-02 04:22:00 -04:00
public static ImageData getNPCTexture(String directory, boolean x64, ResourceLocation resource) {
synchronized (imageDataCache) {
if (!imageDataCache.containsKey(resource.getResourcePath())) {
imageDataCache.put(resource.getResourcePath(), new CacheHashMap.CachedObject<>(new ImageData(directory, x64, resource)));
}
return imageDataCache.get(resource.getResourcePath()).getObject();
}
}
2023-05-30 23:41:37 -05:00
}