aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-07-31 22:45:17 +0800
committershedaniel <daniel@shedaniel.me>2022-07-31 22:45:17 +0800
commit0b4e0878df5d670c49567d5fb90d6cfbdaa05bad (patch)
treede96df0be757717cf6a5003fbb92de198301c856 /fabric
parenta4ae82d568c029d8c0034a6a8802e61ae6521ae8 (diff)
downloadRoughlyEnoughItems-0b4e0878df5d670c49567d5fb90d6cfbdaa05bad.tar.gz
RoughlyEnoughItems-0b4e0878df5d670c49567d5fb90d6cfbdaa05bad.tar.bz2
RoughlyEnoughItems-0b4e0878df5d670c49567d5fb90d6cfbdaa05bad.zip
Support 1.19.1, Fix #1041
Diffstat (limited to 'fabric')
-rw-r--r--fabric/build.gradle2
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java3
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CommandSenderImpl.java55
3 files changed, 58 insertions, 2 deletions
diff --git a/fabric/build.gradle b/fabric/build.gradle
index 56a3944f7..504ca2ec4 100644
--- a/fabric/build.gradle
+++ b/fabric/build.gradle
@@ -104,7 +104,7 @@ unifiedPublishing {
project {
displayName = "[Fabric $rootProject.supported_version] v$project.version"
releaseType = "release"
- gameVersions = ["1.19"]
+ gameVersions = ["1.19", "1.19.1"]
gameLoaders = ["fabric"]
changelog = rootProject.releaseChangelog
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 07ba9c366..ab4d33e8e 100644
--- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
@@ -145,7 +145,8 @@ public class PluginDetectorImpl implements PluginDetector {
return () -> () -> {
loadPlugin(REIClientPlugin.class, ((PluginView<REIClientPlugin>) PluginManager.getClientInstance())::registerPlugin);
Supplier<Method> method = Suppliers.memoize(() -> {
- String methodName = FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_437", "method_32635", "(Ljava/util/List;Lnet/minecraft/class_5632;)V");
+ 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";
try {
Method declaredMethod = Screen.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class);
if (declaredMethod != null) declaredMethod.setAccessible(true);
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CommandSenderImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CommandSenderImpl.java
new file mode 100644
index 000000000..84212209e
--- /dev/null
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CommandSenderImpl.java
@@ -0,0 +1,55 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022 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 dev.architectury.platform.Platform;
+import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.player.LocalPlayer;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class CommandSenderImpl {
+ public static void sendCommand(String command) {
+ LocalPlayer player = Minecraft.getInstance().player;
+ if (player == null) return;
+ String methodName = "method_44099";
+ if (Platform.isDevelopmentEnvironment()) {
+ // 1.19.1 with boolean return
+ methodName = FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_746", "method_44099", "(Ljava/lang/String;)Z");
+ if (methodName.equals("method_44099")) {
+ // 1.19 with void return
+ methodName = FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_746", "method_44099", "(Ljava/lang/String;)V");
+ }
+ }
+ try {
+ Method declaredMethod = LocalPlayer.class.getDeclaredMethod(methodName, String.class);
+ if (declaredMethod != null) declaredMethod.setAccessible(true);
+ declaredMethod.invoke(player, command);
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}