diff options
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java | 2 | ||||
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java index 013a770..7e9b9ab 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java @@ -40,6 +40,8 @@ public interface ImageRenderer { void close(); + default void tick() {} + Map<ResourceLocation, CompletableFuture<Optional<ImageRenderer>>> CACHE = new ConcurrentHashMap<>(); static CompletableFuture<Optional<ImageRenderer>> getOrMakeAsync(ResourceLocation id, Supplier<Optional<ImageRenderer>> factory) { diff --git a/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java index 63371d6..4fb937c 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java @@ -18,6 +18,7 @@ import net.minecraft.util.Mth; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Optional; import java.util.function.Supplier; public class OptionDescriptionWidget extends AbstractWidget { @@ -148,6 +149,12 @@ public class OptionDescriptionWidget extends AbstractWidget { } public void tick() { + if (description != null) { + description.description().image() + .getNow(Optional.empty()) + .ifPresent(ImageRenderer::tick); + } + float pxPerTick = AUTO_SCROLL_SPEED / 20f * font.lineHeight; if (maxScrollAmount > 0 && currentTimeMS() - lastInteractionTime > AUTO_SCROLL_TIMER) { if (scrollingBackward) { |