mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-12-02 00:37:59 +01:00
Decluster this epic
This commit is contained in:
parent
cba69ae1f5
commit
e071242fd3
1 changed files with 14 additions and 8 deletions
|
@ -102,17 +102,23 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
|
||||||
*/
|
*/
|
||||||
private void loadSkinResource(@Nullable ResourceLocation res) {
|
private void loadSkinResource(@Nullable ResourceLocation res) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
inProgress.computeIfAbsent(res, r -> CompletableFuture.supplyAsync(new ImageLoader(r), executor).whenComplete((loc, t) -> {
|
if (!inProgress.containsKey(res)) {
|
||||||
if (loc != null) {
|
inProgress.put(res, scheduleConvertion(res));
|
||||||
converted.put(res, loc);
|
}
|
||||||
} else {
|
|
||||||
LogManager.getLogger().warn("Errored while processing {}. Using original.", res, t);
|
|
||||||
converted.put(res, res);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Future<ResourceLocation> scheduleConvertion(ResourceLocation res) {
|
||||||
|
return CompletableFuture.supplyAsync(new ImageLoader(res), executor).whenComplete((result, error) -> {
|
||||||
|
if (result == null) {
|
||||||
|
result = res;
|
||||||
|
LogManager.getLogger().warn("Errored while processing {}. Using original.", res, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
converted.put(res, result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Skin getSkin(GameProfile profile) {
|
private Skin getSkin(GameProfile profile) {
|
||||||
Skin skin = uuidSkins.get(profile.getId());
|
Skin skin = uuidSkins.get(profile.getId());
|
||||||
|
|
Loading…
Reference in a new issue