aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java13
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java79
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java25
4 files changed, 116 insertions, 4 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
index 45d66c860..02afcd7f4 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
@@ -272,6 +272,9 @@ public interface ConfigObject {
boolean doesCacheEntryRendering();
+ @ApiStatus.Experimental
+ boolean doesCacheDisplayLookup();
+
boolean doDebugRenderTimeRequired();
boolean doMergeDisplayUnderOne();
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java
index 49b63e1f5..70db769e3 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayDecider.java
@@ -89,6 +89,19 @@ public interface OverlayDecider extends Comparable<OverlayDecider> {
}
/**
+ * Returns the provider for rendering the overlay.
+ * Return {@code null} to pass the rendering to the next decider.
+ *
+ * @return the provider for rendering the overlay
+ * @see OverlayRendererProvider for more information
+ * @since 8.3
+ */
+ @ApiStatus.Experimental
+ default OverlayRendererProvider getRendererProvider() {
+ return null;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java
new file mode 100644
index 000000000..e690218b7
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/screen/OverlayRendererProvider.java
@@ -0,0 +1,79 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.api.client.registry.screen;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
+import org.jetbrains.annotations.ApiStatus;
+
+/**
+ * The provider for a renderer provider.
+ * <p>
+ * {@link #onApplied(Sink)} is called when this provider is selected for a screen,
+ * and {@link #onRemoved()} is called when this provider is removed from a screen,
+ * for example if the screen is now no longer applicable for this provider, or
+ * the screen is closed.
+ * <p>
+ * {@link Sink} is given to the provider to allow the provider to render the overlay,
+ * whatever it deems necessary.
+ */
+@ApiStatus.Experimental
+public interface OverlayRendererProvider {
+ default void onApplied(Sink sink) {
+ }
+
+ default void onRemoved() {
+ }
+
+ @ApiStatus.NonExtendable
+ interface Sink {
+ /**
+ * Renders the overlay.
+ *
+ * @param matrices the matrices
+ * @param mouseX the mouse x
+ * @param mouseY the mouse y
+ * @param delta the delta
+ */
+ void render(PoseStack matrices, int mouseX, int mouseY, float delta);
+
+ /**
+ * Renders the overlay components that are supposed to be rendered last,
+ * for example, menu entries, or tooltips.
+ *
+ * @param matrices the matrices
+ * @param mouseX the mouse x
+ * @param mouseY the mouse y
+ * @param delta the delta
+ */
+ void lateRender(PoseStack matrices, int mouseX, int mouseY, float delta);
+
+ /**
+ * Returns the overlay.
+ *
+ * @return the overlay
+ */
+ ScreenOverlay getOverlay();
+ }
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
index eb0449f48..bd8376e53 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
@@ -23,12 +23,10 @@
package me.shedaniel.rei.api.common.util;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.collect.UnmodifiableIterator;
+import com.google.common.collect.*;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import me.shedaniel.rei.api.common.entry.EntryStack;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -550,4 +548,23 @@ public class CollectionUtils {
return size;
}
}
+
+ public static <T> Iterable<T> distinctReferenceOf(Iterable<T> iterable) {
+ return () -> new AbstractIterator<T>() {
+ private final Set<T> set = new ReferenceOpenHashSet<>();
+ private final Iterator<T> iterator = iterable.iterator();
+
+ @Override
+ protected T computeNext() {
+ while (iterator.hasNext()) {
+ T next = iterator.next();
+ if (set.add(next)) {
+ return next;
+ }
+ }
+
+ return endOfData();
+ }
+ };
+ }
}