aboutsummaryrefslogtreecommitdiff
path: root/fabric/src
diff options
context:
space:
mode:
Diffstat (limited to 'fabric/src')
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java8
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CreativeModeTabCollectorImpl.java80
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java14
-rw-r--r--fabric/src/main/resources/error_notifier.json4
-rw-r--r--fabric/src/main/resources/fabric.mod.json2
-rw-r--r--fabric/src/main/resources/roughlyenoughitems.accessWidener11
6 files changed, 99 insertions, 20 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
index 3dff1f2e8..3561c9da5 100644
--- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
@@ -36,7 +36,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
-import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import org.apache.commons.lang3.tuple.Pair;
@@ -145,10 +145,10 @@ public class PluginDetectorImpl implements PluginDetector {
return () -> () -> {
loadPlugin(REIClientPlugin.class, ((PluginView<REIClientPlugin>) PluginManager.getClientInstance())::registerPlugin);
Supplier<Method> method = Suppliers.memoize(() -> {
- String methodName = FabricLoader.getInstance().isDevelopmentEnvironment() ? FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_437", "method_32635", "(Ljava/util/List;Lnet/minecraft/class_5632;)V")
- : "method_32635";
+ String methodName = FabricLoader.getInstance().isDevelopmentEnvironment() ? FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_332", "method_51442", "(Ljava/util/List;Lnet/minecraft/class_5632;)V")
+ : "method_51442";
try {
- Method declaredMethod = Screen.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class);
+ Method declaredMethod = GuiGraphics.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class);
if (declaredMethod != null) declaredMethod.setAccessible(true);
return declaredMethod;
} catch (NoSuchMethodException e) {
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CreativeModeTabCollectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CreativeModeTabCollectorImpl.java
new file mode 100644
index 000000000..7a76fd090
--- /dev/null
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CreativeModeTabCollectorImpl.java
@@ -0,0 +1,80 @@
+/*
+ * 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.impl.client.fabric;
+
+import me.shedaniel.rei.impl.common.InternalLogger;
+import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries;
+import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
+import net.minecraft.core.RegistryAccess;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.world.flag.FeatureFlagSet;
+import net.minecraft.world.flag.FeatureFlags;
+import net.minecraft.world.item.CreativeModeTab;
+import net.minecraft.world.item.CreativeModeTabs;
+import net.minecraft.world.item.ItemStack;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+public class CreativeModeTabCollectorImpl {
+ public static Map<CreativeModeTab, Collection<ItemStack>> collectTabs() {
+ Map<CreativeModeTab, Collection<ItemStack>> map = new LinkedHashMap<>();
+ FeatureFlagSet featureFlags = FeatureFlags.REGISTRY.allFlags();
+ CreativeModeTab.ItemDisplayParameters parameters = new CreativeModeTab.ItemDisplayParameters(featureFlags, true, RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY));
+
+ for (CreativeModeTab tab : CreativeModeTabs.allTabs()) {
+ if (tab.getType() != CreativeModeTab.Type.HOTBAR && tab.getType() != CreativeModeTab.Type.INVENTORY) {
+ try {
+ CreativeModeTab.ItemDisplayBuilder builder = new CreativeModeTab.ItemDisplayBuilder(tab, featureFlags);
+ ResourceKey<CreativeModeTab> resourceKey = BuiltInRegistries.CREATIVE_MODE_TAB
+ .getResourceKey(tab)
+ .orElseThrow(() -> new IllegalStateException("Unregistered creative tab: " + tab));
+ tab.displayItemsGenerator.accept(parameters, builder);
+ map.put(tab, postFabricEvents(tab, parameters, resourceKey, builder.tabContents));
+ } catch (Throwable throwable) {
+ InternalLogger.getInstance().error("Failed to collect creative tab: " + tab, throwable);
+ }
+ }
+ }
+
+ return map;
+ }
+
+ @SuppressWarnings("UnstableApiUsage")
+ private static Collection<ItemStack> postFabricEvents(CreativeModeTab tab, CreativeModeTab.ItemDisplayParameters parameters, ResourceKey<CreativeModeTab> resourceKey, Collection<ItemStack> tabContents) {
+ try {
+ // Sorry!
+ FabricItemGroupEntries entries = new FabricItemGroupEntries(parameters, new LinkedList<>(tabContents), new LinkedList<>());
+ ItemGroupEvents.modifyEntriesEvent(resourceKey).invoker().modifyEntries(entries);
+ ItemGroupEvents.MODIFY_ENTRIES_ALL.invoker().modifyEntries(tab, entries);
+ return entries.getDisplayStacks();
+ } catch (Throwable throwable) {
+ InternalLogger.getInstance().error("Failed to collect fabric's creative tab: " + tab, throwable);
+ return tabContents;
+ }
+ }
+}
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
index be099c741..ad6bedf4b 100644
--- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
@@ -23,11 +23,11 @@
package me.shedaniel.rei.impl.client.gui.fabric;
-import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
@@ -43,7 +43,7 @@ import java.util.stream.Stream;
public class ScreenOverlayImplFabric extends ScreenOverlayImpl {
@Override
- public void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) {
+ public void renderTooltipInner(Screen screen, GuiGraphics graphics, Tooltip tooltip, int mouseX, int mouseY) {
List<ClientTooltipComponent> lines = tooltip.entries().stream()
.flatMap(component -> {
if (component.isText()) {
@@ -72,15 +72,15 @@ public class ScreenOverlayImplFabric extends ScreenOverlayImpl {
}
}
}
- renderTooltipInner(matrices, lines, tooltip.getX(), tooltip.getY());
+ renderTooltipInner(graphics, lines, tooltip.getX(), tooltip.getY());
}
- public static void renderTooltipInner(PoseStack matrices, List<ClientTooltipComponent> lines, int mouseX, int mouseY) {
+ public static void renderTooltipInner(GuiGraphics graphics, List<ClientTooltipComponent> lines, int mouseX, int mouseY) {
if (lines.isEmpty()) {
return;
}
- matrices.pushPose();
- Minecraft.getInstance().screen.renderTooltipInternal(matrices, lines, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE);
- matrices.popPose();
+ graphics.pose().pushPose();
+ graphics.renderTooltipInternal(Minecraft.getInstance().font, lines, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE);
+ graphics.pose().popPose();
}
}
diff --git a/fabric/src/main/resources/error_notifier.json b/fabric/src/main/resources/error_notifier.json
index b95924c26..62ceb1414 100644
--- a/fabric/src/main/resources/error_notifier.json
+++ b/fabric/src/main/resources/error_notifier.json
@@ -12,14 +12,14 @@
"type": "depends",
"modId": "architectury",
"modName": "Architectury API",
- "versions": ">=8.0.0 <9.0.0",
+ "versions": ">=9.0.7 <10.0.0",
"url": "https://www.curseforge.com/minecraft/mc-mods/architectury-api/"
},
{
"type": "depends",
"modId": "cloth-config2",
"modName": "Cloth Config",
- "versions": ">=10.0.0 <11.0.0",
+ "versions": ">=11.0.0 <12.0.0",
"url": "https://www.curseforge.com/minecraft/mc-mods/cloth-config/"
}
]
diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json
index 70e6b0d83..e0c84f24a 100644
--- a/fabric/src/main/resources/fabric.mod.json
+++ b/fabric/src/main/resources/fabric.mod.json
@@ -119,6 +119,6 @@
}
},
"depends": {
- "minecraft": "~1.19-beta.1"
+ "minecraft": "~1.20-"
}
}
diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener
index 22dc526c1..84831b501 100644
--- a/fabric/src/main/resources/roughlyenoughitems.accessWidener
+++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener
@@ -20,8 +20,7 @@ accessible field net/minecraft/world/item/alchemy/PotionBrewing
accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix from Ljava/lang/Object;
accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix ingredient Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/alchemy/PotionBrewing$Mix to Ljava/lang/Object;
-accessible method net/minecraft/client/gui/GuiComponent innerBlit (Lorg/joml/Matrix4f;IIIIIFFFF)V
-accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
+accessible method net/minecraft/client/gui/GuiGraphics innerBlit (Lnet/minecraft/resources/ResourceLocation;IIIIIFFFF)V
accessible method net/minecraft/client/gui/screens/Screen init ()V
accessible method net/minecraft/client/gui/screens/Screen insertText (Ljava/lang/String;Z)V
accessible method net/minecraft/client/gui/screens/Screen isValidCharacterForName (Ljava/lang/String;CI)Z
@@ -31,15 +30,15 @@ extendable method net/minecraft/client/gui/screens/Screen
accessible method net/minecraft/client/gui/screens/Screen addRenderableWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
accessible method net/minecraft/client/gui/screens/Screen addRenderableOnly (Lnet/minecraft/client/gui/components/Renderable;)Lnet/minecraft/client/gui/components/Renderable;
accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
-accessible method net/minecraft/client/gui/screens/Screen renderTooltipInternal (Lcom/mojang/blaze3d/vertex/PoseStack;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V
+accessible method net/minecraft/client/gui/GuiGraphics renderTooltipInternal (Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V
accessible method net/minecraft/client/renderer/RenderType create (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;ILnet/minecraft/client/renderer/RenderType$CompositeState;)Lnet/minecraft/client/renderer/RenderType$CompositeRenderType;
accessible field net/minecraft/tags/TagEntry tag Z
accessible field net/minecraft/tags/TagEntry id Lnet/minecraft/resources/ResourceLocation;
-accessible field net/minecraft/world/item/crafting/LegacyUpgradeRecipe base Lnet/minecraft/world/item/crafting/Ingredient;
-accessible field net/minecraft/world/item/crafting/LegacyUpgradeRecipe addition Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTransformRecipe template Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTransformRecipe base Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTransformRecipe addition Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe template Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe base Lnet/minecraft/world/item/crafting/Ingredient;
-accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe addition Lnet/minecraft/world/item/crafting/Ingredient; \ No newline at end of file
+accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe addition Lnet/minecraft/world/item/crafting/Ingredient;
+accessible field net/minecraft/world/item/CreativeModeTab displayItemsGenerator Lnet/minecraft/world/item/CreativeModeTab$DisplayItemsGenerator;
+accessible class net/minecraft/world/item/CreativeModeTab$ItemDisplayBuilder \ No newline at end of file