aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-05-25 22:07:13 +0100
committerisXander <xandersmith2008@gmail.com>2023-05-25 22:07:13 +0100
commitf40bd6fef7d5a6a718f89014149da80f201787f3 (patch)
tree4a1c1d158db78b1f65035aabbe5e01675ac81101 /common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java
parentc3f1e6836ea0fbbe5944125a121606aad849d9b4 (diff)
downloadYetAnotherConfigLib-f40bd6fef7d5a6a718f89014149da80f201787f3.tar.gz
YetAnotherConfigLib-f40bd6fef7d5a6a718f89014149da80f201787f3.tar.bz2
YetAnotherConfigLib-f40bd6fef7d5a6a718f89014149da80f201787f3.zip
Synchronously generate ImageRenderer off-thread
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java')
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java b/common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java
index 26aacb7..25be791 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/ImageRenderer.java
@@ -3,6 +3,7 @@ package dev.isxander.yacl.gui;
import com.mojang.blaze3d.Blaze3D;
import com.mojang.blaze3d.platform.NativeImage;
import com.twelvemonkeys.imageio.plugins.webp.WebPImageReaderSpi;
+import dev.isxander.yacl.impl.utils.YACLConstants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.texture.DynamicTexture;
@@ -38,7 +39,7 @@ public interface ImageRenderer {
Map<ResourceLocation, CompletableFuture<Optional<ImageRenderer>>> CACHE = new ConcurrentHashMap<>();
static CompletableFuture<Optional<ImageRenderer>> getOrMakeAsync(ResourceLocation id, Supplier<Optional<ImageRenderer>> factory) {
- return CACHE.computeIfAbsent(id, key -> CompletableFuture.supplyAsync(factory));
+ return CACHE.computeIfAbsent(id, key -> CompletableFuture.supplyAsync(factory, YACLConstants.SINGLE_THREAD_EXECUTOR));
}
static CompletableFuture<Optional<ImageRenderer>> getOrMakeSync(ResourceLocation id, Supplier<Optional<ImageRenderer>> factory) {