diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-10-21 23:32:36 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-10-21 23:32:36 +0800 |
| commit | 068a78b6cfd88fec8af0d9a4edb81ad026ffabb2 (patch) | |
| tree | 2958a9345a54e94091a2dbf43d890eade2dce29e | |
| parent | a93dd5e110f30d8af7149d023e4168c027255229 (diff) | |
| download | RoughlyEnoughItems-068a78b6cfd88fec8af0d9a4edb81ad026ffabb2.tar.gz RoughlyEnoughItems-068a78b6cfd88fec8af0d9a4edb81ad026ffabb2.tar.bz2 RoughlyEnoughItems-068a78b6cfd88fec8af0d9a4edb81ad026ffabb2.zip | |
Fix shedaniel/REIPluginCompatibilities-Issues#15
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java index cba9a4bb1..67296e755 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.impl.client.gui.widget; +import com.google.common.base.Suppliers; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix4f; import me.shedaniel.math.Point; @@ -54,6 +55,7 @@ import org.jetbrains.annotations.ApiStatus; import java.util.Collection; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.function.Supplier; @ApiStatus.Internal @@ -68,9 +70,14 @@ public final class InternalWidgets { AutoCraftingEvaluator.evaluateAutoCrafting(true, Screen.hasShiftDown(), displaySupplier.get(), idsSupplier); }); return new DelegateWidget(autoCraftingButton) { + final Supplier<AutoCraftingEvaluator.AutoCraftingResult> result = Suppliers.memoizeWithExpiration( + () -> AutoCraftingEvaluator.evaluateAutoCrafting(false, false, displaySupplier.get(), idsSupplier), + 1000, TimeUnit.MILLISECONDS + ); + @Override public void render(PoseStack poses, int mouseX, int mouseY, float delta) { - AutoCraftingEvaluator.AutoCraftingResult result = AutoCraftingEvaluator.evaluateAutoCrafting(false, false, displaySupplier.get(), idsSupplier); + AutoCraftingEvaluator.AutoCraftingResult result = this.result.get(); autoCraftingButton.setEnabled(result.successful); autoCraftingButton.setTint(result.tint); |
