Decluster this epic

This commit is contained in:
Sollace 2018-07-21 15:32:55 +02:00
parent d755639544
commit 94c6f3cb78

View file

@ -102,15 +102,19 @@ 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) -> { inProgress.computeIfAbsent(res, r -> scheduleConvertion(res, r));
if (loc != null) {
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, ResourceLocation r) {
return CompletableFuture.supplyAsync(new ImageLoader(r), 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