aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-10-21 23:53:12 +0800
committershedaniel <daniel@shedaniel.me>2022-10-21 23:53:12 +0800
commitbb7920e447d599d23abfac3b67d8823cf24f8150 (patch)
treec94708d81898bce63233d2f76a6a3cc49e65a254
parent22e1bf58aeb4204bed30200b28da60284f384f88 (diff)
downloadRoughlyEnoughItems-bb7920e447d599d23abfac3b67d8823cf24f8150.tar.gz
RoughlyEnoughItems-bb7920e447d599d23abfac3b67d8823cf24f8150.tar.bz2
RoughlyEnoughItems-bb7920e447d599d23abfac3b67d8823cf24f8150.zip
Fix merge conflicts
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingButtonWidget.java20
2 files changed, 18 insertions, 10 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
index 66d297f1b..36b450751 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
@@ -49,9 +49,7 @@ import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.impl.client.ClientHelperImpl;
-import me.shedaniel.rei.impl.client.REIRuntimeImpl;
-import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
-import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget;
+import me.shedaniel.rei.impl.client.gui.DisplayScreenStack;
import me.shedaniel.rei.impl.display.DisplaySpec;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
@@ -386,8 +384,8 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis
if (super.keyPressed(keyCode, scanCode, modifiers) || (getOverlay().keyPressed(keyCode, scanCode, modifiers) && handleFocuses()))
return true;
if (ConfigObject.getInstance().getPreviousScreenKeybind().matchesKey(keyCode, scanCode)) {
- if (REIRuntimeImpl.getInstance().hasLastDisplayScreen()) {
- minecraft.setScreen(REIRuntimeImpl.getInstance().getLastDisplayScreen());
+ if (DisplayScreenStack.hasLastDisplayScreen()) {
+ minecraft.setScreen(DisplayScreenStack.getLastDisplayScreen());
} else {
minecraft.setScreen(REIRuntime.getInstance().getPreviousScreen());
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingButtonWidget.java
index 9dc8675c7..cad46cbef 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingButtonWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/AutoCraftingButtonWidget.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 me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
@@ -43,7 +44,9 @@ import net.minecraft.resources.ResourceLocation;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
+import java.util.stream.Stream;
public class AutoCraftingButtonWidget {
public static Widget create(Rectangle displayBounds, Rectangle rectangle, Component text,
@@ -57,13 +60,20 @@ public class AutoCraftingButtonWidget {
.get();
});
return new DelegateWidget(autoCraftingButton) {
+ final Supplier<AutoCraftingEvaluator.Result>[] result = Stream.of(true, false).map(
+ bool -> Suppliers.memoizeWithExpiration(
+ () -> ClientInternals.getAutoCraftingEvaluator(displaySupplier.get())
+ .buildRenderer()
+ .buildTooltipRenderer(bool)
+ .ids(idsSupplier == null ? null : idsSupplier.get())
+ .get(),
+ 1000, TimeUnit.MILLISECONDS
+ )
+ ).toArray(Supplier[]::new);
+
@Override
public void render(PoseStack poses, int mouseX, int mouseY, float delta) {
- AutoCraftingEvaluator.Result result = ClientInternals.getAutoCraftingEvaluator(displaySupplier.get())
- .buildRenderer()
- .buildTooltipRenderer(autoCraftingButton.isFocused() || containsMouse(mouseX, mouseY))
- .ids(idsSupplier == null ? null : idsSupplier.get())
- .get();
+ AutoCraftingEvaluator.Result result = this.result[(autoCraftingButton.isFocused() || containsMouse(mouseX, mouseY)) ? 1 : 0].get();
autoCraftingButton.setEnabled(result.isSuccessful());
autoCraftingButton.setTint(result.getTint());