aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java7
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java39
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java4
-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
-rw-r--r--forge/build.gradle4
-rw-r--r--forge/src/main/java/me/shedaniel/rei/impl/client/forge/CommandSenderImpl.java60
-rw-r--r--gradle.properties2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java27
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/NoFilteringEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/RecipeScreenTypeEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/SearchFilterSyntaxHighlightingEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/TitleTextEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java3
32 files changed, 214 insertions, 72 deletions
diff --git a/.gitignore b/.gitignore
index 104a492ae..38a7c293e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,10 @@
# Compiled nonsense that does not belong in *source* control
-*/build
+**/build
/build
/bin
-*/bin
+**/bin
/.gradle
-*/.gradle
+**/.gradle
/minecraft
*/minecraft
/out
@@ -31,4 +31,4 @@ private.properties
# Files from bad operating systems :^)
Thumbs.db
.DS_Store
-/.architectury-transformer/debug.log
+/.architectury-transformer/debug.log \ No newline at end of file
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java
index 7ce6d1b1d..fdba2503a 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/ClientHelper.java
@@ -32,7 +32,6 @@ import me.shedaniel.rei.impl.ClientInternals;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.ChatFormatting;
-import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -108,7 +107,7 @@ public interface ClientHelper {
default Component getFormattedModFromItem(Item item) {
String mod = getModFromItem(item);
if (mod.isEmpty())
- return NarratorChatListener.NO_TITLE;
+ return Component.empty();
return Component.literal(mod).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC);
}
@@ -121,7 +120,7 @@ public interface ClientHelper {
default Component getFormattedModFromIdentifier(ResourceLocation identifier) {
String mod = getModFromIdentifier(identifier);
if (mod.isEmpty())
- return NarratorChatListener.NO_TITLE;
+ return Component.empty();
return Component.literal(mod).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC);
}
@@ -134,7 +133,7 @@ public interface ClientHelper {
default Component getFormattedModFromModId(String modId) {
String mod = getModFromModId(modId);
if (mod.isEmpty())
- return NarratorChatListener.NO_TITLE;
+ return Component.empty();
return Component.literal(mod).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC);
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java
new file mode 100644
index 000000000..e0ae0ba1e
--- /dev/null
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java
@@ -0,0 +1,39 @@
+/*
+ * 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.plugin.client.favorites;
+
+import dev.architectury.platform.Platform;
+
+import java.lang.reflect.InvocationTargetException;
+
+class CommandSender {
+ static void sendCommand(String command) {
+ try {
+ Class.forName("me.shedaniel.rei.impl.client.%s.CommandSenderImpl".formatted(Platform.isForge() ? "forge" : "fabric"))
+ .getDeclaredMethod("sendCommand", String.class).invoke(null, command);
+ } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
index fba8a6ab2..1024fb190 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
@@ -147,7 +147,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry {
if (mode == null) {
mode = GameType.byId(Minecraft.getInstance().gameMode.getPlayerMode().getId() + 1 % 4);
}
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", mode.name().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", mode.name().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
return true;
}
@@ -275,7 +275,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry {
public boolean mouseClicked(double mouseX, double mouseY, int button) {
boolean disabled = this.minecraft.gameMode.getPlayerMode() == gameMode;
if (!disabled && rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
index 7fc6c03e5..39bbc96a9 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
@@ -181,7 +181,7 @@ public class TimeFavoriteEntry extends FavoriteEntry {
if (time == null) {
time = nextTime();
}
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
return true;
}
@@ -303,7 +303,7 @@ public class TimeFavoriteEntry extends FavoriteEntry {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
index 989549922..c59abec80 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
@@ -154,7 +154,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry {
public boolean doAction(int button) {
if (button == 0) {
if (weather != null) {
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
return true;
@@ -312,7 +312,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- Minecraft.getInstance().player.command(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
+ CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
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);
+ }
+ }
+}
diff --git a/forge/build.gradle b/forge/build.gradle
index ad391f305..ed0e98229 100644
--- a/forge/build.gradle
+++ b/forge/build.gradle
@@ -219,7 +219,7 @@ unifiedPublishing {
project {
displayName = "[Forge $rootProject.supported_version] v$project.version"
releaseType = "beta"
- gameVersions = ["1.19"]
+ gameVersions = ["1.19", "1.19.1"]
gameLoaders = ["forge"]
changelog = rootProject.releaseChangelog
@@ -259,7 +259,7 @@ unifiedPublishing {
project {
displayName = "[Forge $rootProject.supported_version] v$project.version"
releaseType = "beta"
- gameVersions = ["1.19"]
+ gameVersions = ["1.19", "1.19.1"]
gameLoaders = ["forge"]
changelog = rootProject.releaseChangelog
diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/forge/CommandSenderImpl.java b/forge/src/main/java/me/shedaniel/rei/impl/client/forge/CommandSenderImpl.java
new file mode 100644
index 000000000..83253fc9c
--- /dev/null
+++ b/forge/src/main/java/me/shedaniel/rei/impl/client/forge/CommandSenderImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.forge;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.player.LocalPlayer;
+import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
+
+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;
+ Method method = null;
+ try {
+ // 1.19
+ method = ObfuscationReflectionHelper.findMethod(LocalPlayer.class, "m_234156_", String.class);
+ } catch (ObfuscationReflectionHelper.UnableToFindMethodException ignored) {
+ }
+ if (method == null) {
+ try {
+ // 1.19.1
+ method = ObfuscationReflectionHelper.findMethod(LocalPlayer.class, "m_242614_", String.class);
+ } catch (ObfuscationReflectionHelper.UnableToFindMethodException ignored) {
+ }
+ }
+ if (method == null) {
+ throw new RuntimeException("Unable to find method");
+ }
+
+ try {
+ method.invoke(player, command);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index b31b646e4..867b6701a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx6G
base_version=9.1
unstable=false
-supported_version=1.19
+supported_version=1.19(.1)
minecraft_version=1.19
forgeEnabled=true
forge_version=41.0.94
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
index 641f8a7bd..8acb6c09e 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
@@ -70,6 +70,7 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
+import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Supplier;
@@ -184,27 +185,27 @@ public class ClientHelperImpl implements ClientHelper {
}
@Override
- public boolean tryCheatingEntry(EntryStack<?> e) {
- if (e.getType() != VanillaEntryTypes.ITEM)
+ public boolean tryCheatingEntry(EntryStack<?> stack) {
+ if (stack.getType() != VanillaEntryTypes.ITEM)
return false;
- EntryStack<ItemStack> entry = (EntryStack<ItemStack>) e;
+ EntryStack<ItemStack> entry = (EntryStack<ItemStack>) stack;
if (Minecraft.getInstance().player == null) return false;
if (Minecraft.getInstance().player.getInventory() == null) return false;
ItemStack cheatedStack = entry.getValue().copy();
if (ConfigObject.getInstance().isGrabbingItems() && Minecraft.getInstance().screen instanceof CreativeModeInventoryScreen) {
AbstractContainerMenu menu = Minecraft.getInstance().player.containerMenu;
- EntryStack<ItemStack> stack = entry.copy();
- if (!menu.getCarried().isEmpty() && EntryStacks.equalsExact(EntryStacks.of(menu.getCarried()), stack)) {
- stack.getValue().setCount(Mth.clamp(stack.getValue().getCount() + menu.getCarried().getCount(), 1, stack.getValue().getMaxStackSize()));
+ EntryStack<ItemStack> copy = entry.copy();
+ if (!menu.getCarried().isEmpty() && EntryStacks.equalsExact(EntryStacks.of(menu.getCarried()), copy)) {
+ copy.getValue().setCount(Mth.clamp(copy.getValue().getCount() + menu.getCarried().getCount(), 1, copy.getValue().getMaxStackSize()));
} else if (!menu.getCarried().isEmpty()) {
return false;
}
- menu.setCarried(stack.getValue().copy());
+ menu.setCarried(copy.getValue().copy());
return true;
} else if (ClientHelperImpl.getInstance().canUsePackets()) {
AbstractContainerMenu menu = Minecraft.getInstance().player.containerMenu;
- EntryStack<ItemStack> stack = entry.copy();
- if (!menu.getCarried().isEmpty() && !EntryStacks.equalsExact(EntryStacks.of(menu.getCarried()), stack)) {
+ EntryStack<ItemStack> copy = entry.copy();
+ if (!menu.getCarried().isEmpty() && !EntryStacks.equalsExact(EntryStacks.of(menu.getCarried()), copy)) {
return false;
}
try {
@@ -225,7 +226,13 @@ public class ClientHelperImpl implements ClientHelper {
madeUpCommand = og.replaceAll("\\{player_name}", Minecraft.getInstance().player.getScoreboardName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", "").replaceAll("\\{count}", String.valueOf(cheatedStack.getCount()));
Minecraft.getInstance().player.displayClientMessage(Component.translatable("text.rei.too_long_nbt"), false);
}
- Minecraft.getInstance().player.command(StringUtils.removeStart(madeUpCommand, "/"));
+ try {
+ Class.forName("me.shedaniel.rei.impl.client.%s.CommandSenderImpl".formatted(Platform.isForge() ? "forge" : "fabric"))
+ .getDeclaredMethod("sendCommand", String.class)
+ .invoke(null, StringUtils.removeStart(madeUpCommand, "/"));
+ } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
return true;
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
index b3aeca310..8062b1ea0 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java
@@ -30,7 +30,6 @@ import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.impl.client.config.addon.ConfigAddonsScreen;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.events.GuiEventListener;
@@ -45,13 +44,13 @@ import java.util.Optional;
@ApiStatus.Internal
public class ConfigAddonsEntry extends AbstractConfigListEntry<Unit> {
private int width;
- private AbstractWidget buttonWidget = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> {
+ private AbstractWidget buttonWidget = new Button(0, 0, 0, 20, Component.empty(), button -> {
Minecraft.getInstance().setScreen(new ConfigAddonsScreen(Minecraft.getInstance().screen));
});
private List<AbstractWidget> children = ImmutableList.of(buttonWidget);
public ConfigAddonsEntry(int width) {
- super(NarratorChatListener.NO_TITLE, false);
+ super(Component.empty(), false);
this.width = width;
this.buttonWidget.setMessage(REIRuntime.getInstance().getPreviousContainerScreen() != null && Minecraft.getInstance().getConnection() != null
&& Minecraft.getInstance().getConnection().getRecipeManager() != null ? Component.translatable("text.rei.addons")
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringEntry.java
index deaeb2484..52171b53a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringEntry.java
@@ -32,7 +32,6 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.entry.filtering.FilteringRule;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.events.GuiEventListener;
@@ -61,7 +60,7 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack<?>>>
private final List<AbstractWidget> children = ImmutableList.of(buttonWidget);
public FilteringEntry(int width, List<EntryStack<?>> configFiltered, List<FilteringRule<?>> rules, List<EntryStack<?>> defaultValue, Consumer<List<EntryStack<?>>> saveConsumer, Consumer<List<FilteringRule<?>>> rulesSaveConsumer) {
- super(NarratorChatListener.NO_TITLE, false);
+ super(Component.empty(), false);
this.width = width;
this.configFiltered = new TreeSet<>(Comparator.comparing(EntryStacks::hashExact));
this.configFiltered.addAll(configFiltered);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/NoFilteringEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/NoFilteringEntry.java
index 8003a3f9c..95249d260 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/