From 0b4e0878df5d670c49567d5fb90d6cfbdaa05bad Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 31 Jul 2022 22:45:17 +0800 Subject: Support 1.19.1, Fix #1041 --- .gitignore | 8 +-- .../me/shedaniel/rei/api/client/ClientHelper.java | 7 ++- .../rei/plugin/client/favorites/CommandSender.java | 39 ++++++++++++++ .../client/favorites/GameModeFavoriteEntry.java | 4 +- .../plugin/client/favorites/TimeFavoriteEntry.java | 4 +- .../client/favorites/WeatherFavoriteEntry.java | 4 +- fabric/build.gradle | 2 +- .../shedaniel/rei/fabric/PluginDetectorImpl.java | 3 +- .../rei/impl/client/fabric/CommandSenderImpl.java | 55 ++++++++++++++++++++ forge/build.gradle | 4 +- .../rei/impl/client/forge/CommandSenderImpl.java | 60 ++++++++++++++++++++++ gradle.properties | 2 +- .../rei/impl/client/ClientHelperImpl.java | 27 ++++++---- .../client/config/entries/ConfigAddonsEntry.java | 5 +- .../impl/client/config/entries/FilteringEntry.java | 3 +- .../client/config/entries/NoFilteringEntry.java | 3 +- .../config/entries/RecipeScreenTypeEntry.java | 3 +- .../client/config/entries/ReloadPluginsEntry.java | 7 ++- .../SearchFilterSyntaxHighlightingEntry.java | 3 +- .../impl/client/config/entries/TitleTextEntry.java | 3 +- .../rei/impl/client/gui/credits/CreditsScreen.java | 5 +- .../rei/impl/client/gui/error/ErrorsScreen.java | 3 +- .../gui/performance/entry/PerformanceEntry.java | 5 +- .../gui/screen/AbstractDisplayViewingScreen.java | 3 +- .../gui/screen/CompositeDisplayViewingScreen.java | 3 +- .../client/gui/screen/ConfigReloadingScreen.java | 3 +- .../gui/screen/DefaultDisplayViewingScreen.java | 3 +- .../gui/screen/UncertainDisplayViewingScreen.java | 3 +- .../client/gui/screen/WarningAndErrorScreen.java | 3 +- .../impl/client/gui/widget/ConfigButtonWidget.java | 3 +- .../gui/widget/CraftableFilterButtonWidget.java | 3 +- .../widget/entrylist/PaginatedEntryListWidget.java | 3 +- 32 files changed, 214 insertions(+), 72 deletions(-) create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java create mode 100644 fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/CommandSenderImpl.java create mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/forge/CommandSenderImpl.java 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) PluginManager.getClientInstance())::registerPlugin); Supplier 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 entry = (EntryStack) e; + EntryStack entry = (EntryStack) 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 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 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 stack = entry.copy(); - if (!menu.getCarried().isEmpty() && !EntryStacks.equalsExact(EntryStacks.of(menu.getCarried()), stack)) { + EntryStack 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 { 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 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>> private final List children = ImmutableList.of(buttonWidget); public FilteringEntry(int width, List> configFiltered, List> rules, List> defaultValue, Consumer>> saveConsumer, Consumer>> 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/client/config/entries/NoFilteringEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/NoFilteringEntry.java @@ -29,7 +29,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; import me.shedaniel.rei.api.common.entry.EntryStack; 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; @@ -51,7 +50,7 @@ public class NoFilteringEntry extends AbstractConfigListEntry private final List children = ImmutableList.of(buttonWidget); public NoFilteringEntry(int width, List> configFiltered, List> defaultValue, Consumer>> saveConsumer) { - super(NarratorChatListener.NO_TITLE, false); + super(Component.empty(), false); this.width = width; this.configFiltered = configFiltered; this.defaultValue = defaultValue; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/RecipeScreenTypeEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/RecipeScreenTypeEntry.java index 98060aa30..d1ee26970 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/RecipeScreenTypeEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/RecipeScreenTypeEntry.java @@ -30,7 +30,6 @@ import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry; import me.shedaniel.rei.api.client.gui.config.DisplayScreenType; import me.shedaniel.rei.impl.client.gui.screen.UncertainDisplayViewingScreen; 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; @@ -47,7 +46,7 @@ public class RecipeScreenTypeEntry extends TooltipListEntry { private DisplayScreenType type; private DisplayScreenType defaultValue; private Consumer save; - private final AbstractWidget buttonWidget = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> { + private final AbstractWidget buttonWidget = new Button(0, 0, 0, 20, Component.empty(), button -> { Minecraft.getInstance().setScreen(new UncertainDisplayViewingScreen(getConfigScreen(), type, false, original -> { Minecraft.getInstance().setScreen(getConfigScreen()); type = original ? DisplayScreenType.ORIGINAL : DisplayScreenType.COMPOSITE; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java index ba0194978..5988b43f3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java @@ -33,7 +33,6 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.impl.client.gui.screen.ConfigReloadingScreen; import me.shedaniel.rei.impl.client.search.argument.Argument; 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; @@ -49,7 +48,7 @@ import java.util.Optional; @ApiStatus.Internal public class ReloadPluginsEntry extends AbstractConfigListEntry { private int width; - private AbstractWidget reloadPluginsButton = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> { + private AbstractWidget reloadPluginsButton = new Button(0, 0, 0, 20, Component.empty(), button -> { RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.clear(); RoughlyEnoughItemsCoreClient.reloadPlugins(null, null); }) { @@ -63,13 +62,13 @@ public class ReloadPluginsEntry extends AbstractConfigListEntry { } } }; - private AbstractWidget reloadSearchButton = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> { + private AbstractWidget reloadSearchButton = new Button(0, 0, 0, 20, Component.empty(), button -> { Argument.SEARCH_CACHE.clear(); }); private List children = ImmutableList.of(reloadPluginsButton, reloadSearchButton); public ReloadPluginsEntry(int width) { - super(NarratorChatListener.NO_TITLE, false); + super(Component.empty(), false); this.width = width; reloadPluginsButton.setMessage(Component.translatable("text.rei.reload_config")); reloadSearchButton.setMessage(Component.translatable("text.rei.reload_search")); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/SearchFilterSyntaxHighlightingEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/SearchFilterSyntaxHighlightingEntry.java index ed44ee5a8..3cd747776 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/SearchFilterSyntaxHighlightingEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/SearchFilterSyntaxHighlightingEntry.java @@ -29,7 +29,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry; import me.shedaniel.rei.api.client.gui.config.SyntaxHighlightingMode; 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,7 +44,7 @@ public class SearchFilterSyntaxHighlightingEntry extends TooltipListEntry save; - private final AbstractWidget buttonWidget = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, $ -> { + private final AbstractWidget buttonWidget = new Button(0, 0, 0, 20, Component.empty(), $ -> { type = SyntaxHighlightingMode.values()[(type.ordinal() + 1) % SyntaxHighlightingMode.values().length]; }) { @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/TitleTextEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/TitleTextEntry.java index 3e2bdc48a..295141579 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/TitleTextEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/TitleTextEntry.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.config.entries; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.network.chat.Component; @@ -42,7 +41,7 @@ public class TitleTextEntry extends AbstractConfigListEntry { private Component text; public TitleTextEntry(Component text) { - super(NarratorChatListener.NO_TITLE, false); + super(Component.empty(), false); this.text = text; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java index c9fa8b330..830bcae36 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsScreen.java @@ -30,7 +30,6 @@ import me.shedaniel.rei.impl.client.gui.credits.CreditsEntryListWidget.TextCredi import me.shedaniel.rei.impl.client.gui.credits.CreditsEntryListWidget.TranslationCreditsItem; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; @@ -122,11 +121,11 @@ public class CreditsScreen extends Screen { } } } else entryListWidget.creditsAddEntry(new TextCreditsItem(Component.literal(line))); - entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); + entryListWidget.creditsAddEntry(new TextCreditsItem(Component.empty())); entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(Component.literal("Visit the project at GitHub."), "https://www.github.com/shedaniel/RoughlyEnoughItems", entryListWidget.getItemWidth(), false)); entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(Component.literal("Visit the project page at CurseForge."), "https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items", entryListWidget.getItemWidth(), false)); entryListWidget.creditsAddEntry(new CreditsEntryListWidget.LinkItem(Component.literal("Support the project via Patreon!"), "https://patreon.com/shedaniel", entryListWidget.getItemWidth(), true)); - entryListWidget.creditsAddEntry(new TextCreditsItem(NarratorChatListener.NO_TITLE)); + entryListWidget.creditsAddEntry(new TextCreditsItem(Component.empty())); addRenderableWidget(buttonDone = new Button(width / 2 - 100, height - 26, 200, 20, Component.translatable("gui.done"), button -> openPrevious())); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java index b86b7edf6..706a89b7d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.gui.error; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.rei.impl.client.gui.error.ErrorsEntryListWidget.TextEntry; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.GenericDirtMessageScreen; @@ -78,7 +77,7 @@ public class ErrorsScreen extends Screen { listWidget._addEntry(((Function) component).apply(listWidget.getItemWidth())); } } - listWidget._addEntry(new TextEntry(NarratorChatListener.NO_TITLE, listWidget.getItemWidth())); + listWidget._addEntry(new TextEntry(Component.empty(), listWidget.getItemWidth())); if (quitable) { addRenderableWidget(doneButton = new Button(width / 2 - 100, height - 26, 200, 20, Component.translatable("gui.done"), button -> Minecraft.getInstance().setScreen(parent))); } else { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java index 38e7909d0..c52630bba 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java @@ -29,7 +29,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; import me.shedaniel.rei.impl.client.gui.performance.PerformanceScreen; 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; @@ -44,13 +43,13 @@ import java.util.Optional; @ApiStatus.Internal public class PerformanceEntry extends AbstractConfigListEntry { 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 PerformanceScreen(Minecraft.getInstance().screen)); }); private List children = ImmutableList.of(buttonWidget); public PerformanceEntry(int width) { - super(NarratorChatListener.NO_TITLE, false); + super(Component.empty(), false); this.width = width; buttonWidget.setMessage(Component.translatable("text.rei.performance")); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java index 7d8c9c072..c9707a275 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java @@ -53,7 +53,6 @@ import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget; import me.shedaniel.rei.impl.display.DisplaySpec; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; @@ -82,7 +81,7 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Dis protected Rectangle bounds; protected AbstractDisplayViewingScreen(Map, List> categoryMap, @Nullable CategoryIdentifier category, int tabsPerPage) { - super(NarratorChatListener.NO_TITLE); + super(Component.empty()); this.categoryMap = categoryMap; this.categories = Lists.newArrayList(categoryMap.keySet()); this.tabsPerPage = tabsPerPage; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java index 7bd7426ed..881b90ecf 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java @@ -51,7 +51,6 @@ import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets; import me.shedaniel.rei.impl.client.gui.widget.TabWidget; import me.shedaniel.rei.impl.display.DisplaySpec; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.network.chat.Component; @@ -180,7 +179,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen int finalIndex = index; DisplayRenderer displayRenderer; displayRenderers.add(displayRenderer = getCurrentCategoryView(recipeDisplay.provideInternalDisplay()).getDisplayRenderer(recipeDisplay.provideInternalDisplay())); - buttonList.add(Widgets.createButton(new Rectangle(bounds.x + 5, 0, displayRenderer.getWidth(), displayRenderer.getHeight()), NarratorChatListener.NO_TITLE) + buttonList.add(Widgets.createButton(new Rectangle(bounds.x + 5, 0, displayRenderer.getWidth(), displayRenderer.getHeight()), Component.empty()) .onClick(button -> { selectedRecipeIndex = finalIndex; CompositeDisplayViewingScreen.this.init(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java index 3d3895880..eeb1a1852 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.gui.screen; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.Util; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; @@ -39,7 +38,7 @@ public class ConfigReloadingScreen extends Screen { private Runnable parent; public ConfigReloadingScreen(Component title, BooleanSupplier predicate, Runnable parent) { - super(NarratorChatListener.NO_TITLE); + super(Component.empty()); this.title = title; this.predicate = predicate; this.parent = parent; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java index 4b64f1144..5f4a99bd9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java @@ -62,7 +62,6 @@ import me.shedaniel.rei.impl.client.gui.widget.basewidgets.PanelWidget; import me.shedaniel.rei.impl.display.DisplaySpec; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.ConfirmScreen; import net.minecraft.client.gui.screens.Screen; @@ -229,7 +228,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen { page = getCurrentTotalPages() - 1; DefaultDisplayViewingScreen.this.init(); }).tooltipLine(Component.translatable("text.rei.previous_page"))); - this.widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 21), NarratorChatListener.NO_TITLE, label -> { + this.widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 21), Component.empty(), label -> { if (!Screen.hasShiftDown()) { page = 0; DefaultDisplayViewingScreen.this.init(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java index 1558f5d8c..05e476504 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java @@ -48,7 +48,6 @@ import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; @@ -129,7 +128,7 @@ public class UncertainDisplayViewingScreen extends Screen { public void init() { this.children().clear(); this.widgets.clear(); - this._children().add(button = Widgets.createButton(new Rectangle(width / 2 - 100, height - 40, 200, 20), NarratorChatListener.NO_TITLE) + this._children().add(button = Widgets.createButton(new Rectangle(width / 2 - 100, height - 40, 200, 20), Component.empty()) .onRender((matrices, button) -> { button.setEnabled(isSet); if (scroll.target() != 0 && allModsUsingJEI != null) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java index 6fa69ad76..56a7ae15e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/WarningAndErrorScreen.java @@ -31,7 +31,6 @@ import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; -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.narration.NarratableEntry; @@ -62,7 +61,7 @@ public class WarningAndErrorScreen extends Screen { private Consumer onContinue; public WarningAndErrorScreen(String action, List> warnings, List> errors, Consumer onContinue) { - super(NarratorChatListener.NO_TITLE); + super(Component.empty()); this.action = action; this.warnings = warnings; this.errors = errors; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java index 14cd14d84..12ce8865c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java @@ -46,7 +46,6 @@ import me.shedaniel.rei.impl.client.gui.modules.MenuAccess; import me.shedaniel.rei.impl.client.gui.modules.MenuEntry; import me.shedaniel.rei.impl.client.gui.modules.entries.*; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -60,7 +59,7 @@ public class ConfigButtonWidget { public static Widget create(ScreenOverlayImpl overlay) { Rectangle bounds = getConfigButtonBounds(); MenuAccess access = overlay.menuAccess(); - Button configButton = Widgets.createButton(bounds, NarratorChatListener.NO_TITLE) + Button configButton = Widgets.createButton(bounds, Component.empty()) .onClick(button -> { if (Screen.hasShiftDown() || Screen.hasControlDown()) { ClientHelper.getInstance().setCheating(!ClientHelper.getInstance().isCheating()); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java index fa4e01c52..bef9eaa02 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java @@ -45,7 +45,6 @@ import me.shedaniel.rei.impl.client.gui.modules.entries.ToggleMenuEntry; import me.shedaniel.rei.impl.client.gui.screen.ConfigReloadingScreen; import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.network.chat.Component; @@ -66,7 +65,7 @@ public class CraftableFilterButtonWidget { MenuAccess access = overlay.menuAccess(); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ItemStack icon = new ItemStack(Blocks.CRAFTING_TABLE); - Button filterButton = Widgets.createButton(bounds, NarratorChatListener.NO_TITLE) + Button filterButton = Widgets.createButton(bounds, Component.empty()) .focusable(false) .onClick(button -> { ConfigManager.getInstance().toggleCraftableOnly(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java index eee5c08b3..2a0de75b0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/PaginatedEntryListWidget.java @@ -47,7 +47,6 @@ import me.shedaniel.rei.impl.client.gui.widget.DefaultDisplayChoosePageWidget; import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; @@ -242,7 +241,7 @@ public class PaginatedEntryListWidget extends CollapsingEntryListWidget { matrices.popPose(); helper.setBlitOffset(helper.getBlitOffset() - 1); })); - this.additionalWidgets.add(Widgets.createClickableLabel(new Point(overlayBounds.x + ((overlayBounds.width - 18) / 2), overlayBounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), NarratorChatListener.NO_TITLE, label -> { + this.additionalWidgets.add(Widgets.createClickableLabel(new Point(overlayBounds.x + ((overlayBounds.width - 18) / 2), overlayBounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), Component.empty(), label -> { if (!Screen.hasShiftDown()) { setPage(0); updateEntriesPosition(); -- cgit