aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/api
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-07-16 23:30:07 +0800
committershedaniel <daniel@shedaniel.me>2020-07-16 23:30:07 +0800
commit687e6503f44b504db141ed777588c2bdfa2184ca (patch)
tree2337de861656d600ad713527868a066844fb364c /src/main/java/me/shedaniel/rei/api
parentbe6a2ca9f20059d19907230425ca258f908d5644 (diff)
downloadRoughlyEnoughItems-687e6503f44b504db141ed777588c2bdfa2184ca.tar.gz
RoughlyEnoughItems-687e6503f44b504db141ed777588c2bdfa2184ca.tar.bz2
RoughlyEnoughItems-687e6503f44b504db141ed777588c2bdfa2184ca.zip
Added FocusedStackProvider api.
Optimised item rendering. Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api')
-rw-r--r--src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java40
-rw-r--r--src/main/java/me/shedaniel/rei/api/OptimalEntryStack.java12
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java8
3 files changed, 59 insertions, 1 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java b/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java
new file mode 100644
index 000000000..ec13a37cc
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java
@@ -0,0 +1,40 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 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;
+
+import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.util.TypedActionResult;
+import org.jetbrains.annotations.NotNull;
+
+public interface FocusedStackProvider {
+ /**
+ * @return the priority of this handler, higher priorities will be called first.
+ */
+ default double getPriority() {
+ return 0d;
+ }
+
+ @NotNull
+ TypedActionResult<EntryStack> provide(Screen screen);
+}
diff --git a/src/main/java/me/shedaniel/rei/api/OptimalEntryStack.java b/src/main/java/me/shedaniel/rei/api/OptimalEntryStack.java
index a7a4a4f04..8f7c2bf39 100644
--- a/src/main/java/me/shedaniel/rei/api/OptimalEntryStack.java
+++ b/src/main/java/me/shedaniel/rei/api/OptimalEntryStack.java
@@ -24,15 +24,25 @@
package me.shedaniel.rei.api;
import me.shedaniel.math.Rectangle;
+import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public interface OptimalEntryStack {
+ static int groupingHashFrom(EntryStack stack) {
+ if (stack instanceof OptimalEntryStack) return ((OptimalEntryStack) stack).groupingHash();
+ return stack.getClass().hashCode();
+ }
+
+ default int groupingHash() {
+ return getClass().hashCode();
+ }
+
default void optimisedRenderStart(MatrixStack matrices, float delta) {
}
- default void optimisedRenderBase(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ default void optimisedRenderBase(MatrixStack matrices, VertexConsumerProvider.Immediate immediate, Rectangle bounds, int mouseX, int mouseY, float delta) {
}
default void optimisedRenderOverlay(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
index 04b699b5a..b46280a63 100644
--- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
@@ -27,12 +27,14 @@ import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
@@ -53,6 +55,12 @@ public interface RecipeHelper {
AutoTransferHandler registerAutoCraftingHandler(AutoTransferHandler handler);
+ void registerFocusedStackProvider(FocusedStackProvider provider);
+
+ @Nullable
+ @ApiStatus.Internal
+ EntryStack getScreenFocusedStack(Screen screen);
+
List<AutoTransferHandler> getSortedAutoCraftingHandler();
/**