aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl3/impl
diff options
context:
space:
mode:
authorisxander <xander@isxander.dev>2023-12-08 19:59:09 +0000
committerisxander <xander@isxander.dev>2023-12-08 19:59:09 +0000
commit450dbad49b72b37cdeef9b1358a59da1d66076c9 (patch)
treef2d99e7740b96d9660c405a2f92c2f7342751971 /common/src/main/java/dev/isxander/yacl3/impl
parentf54989903c4697fe14bdc6f1998f4a88757cdd0c (diff)
downloadYetAnotherConfigLib-450dbad49b72b37cdeef9b1358a59da1d66076c9.tar.gz
YetAnotherConfigLib-450dbad49b72b37cdeef9b1358a59da1d66076c9.tar.bz2
YetAnotherConfigLib-450dbad49b72b37cdeef9b1358a59da1d66076c9.zip
extreme image preloading hackery
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl3/impl')
-rw-r--r--common/src/main/java/dev/isxander/yacl3/impl/OptionDescriptionImpl.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/impl/OptionDescriptionImpl.java b/common/src/main/java/dev/isxander/yacl3/impl/OptionDescriptionImpl.java
index 3a3008c..67fa6a6 100644
--- a/common/src/main/java/dev/isxander/yacl3/impl/OptionDescriptionImpl.java
+++ b/common/src/main/java/dev/isxander/yacl3/impl/OptionDescriptionImpl.java
@@ -88,7 +88,13 @@ public record OptionDescriptionImpl(Component text, CompletableFuture<Optional<I
public Builder webpImage(ResourceLocation image) {
Validate.isTrue(imageUnset, "Image already set!");
- this.image = ImageRendererManager.registerImage(image, AnimatedDynamicTextureImage.createWEBPFromTexture(image)).thenApply(Optional::of);
+ Optional<ImageRenderer> completedImage = ImageRendererManager.getImage(image);
+ if (completedImage.isPresent()) {
+ this.image = CompletableFuture.completedFuture(completedImage);
+ } else {
+ this.image = ImageRendererManager.registerImage(image, AnimatedDynamicTextureImage.createWEBPFromTexture(image)).thenApply(Optional::of);
+ }
+
imageUnset = false;
return this;
}