aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java14
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/FireworkRocketRecipeFiller.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java8
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java5
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/SuspiciousStewRecipeFiller.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java10
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ConfigUtils.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java12
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java20
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java20
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/selection/CustomCollapsibleEntrySelectionScreen.java19
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/ConfigButtonWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CraftableFilterButtonWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabContainerWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/collapsed/CollapsibleEntryRegistryImpl.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java6
20 files changed, 71 insertions, 86 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index 98fc53f73..239b95e2e 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -160,19 +160,19 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
@Override
public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) {
- registry.group(new ResourceLocation("roughlyenoughitems", "enchanted_book"), new TranslatableComponent("item.minecraft.enchanted_book"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.ENCHANTED_BOOK));
- registry.group(new ResourceLocation("roughlyenoughitems", "potion"), new TranslatableComponent("item.minecraft.potion"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "potion"), Component.translatable("item.minecraft.potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.POTION));
- registry.group(new ResourceLocation("roughlyenoughitems", "splash_potion"), new TranslatableComponent("item.minecraft.splash_potion"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "splash_potion"), Component.translatable("item.minecraft.splash_potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.SPLASH_POTION));
- registry.group(new ResourceLocation("roughlyenoughitems", "lingering_potion"), new TranslatableComponent("item.minecraft.lingering_potion"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "lingering_potion"), Component.translatable("item.minecraft.lingering_potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.LINGERING_POTION));
- registry.group(new ResourceLocation("roughlyenoughitems", "spawn_egg"), new TranslatableComponent("text.rei.spawn_egg"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "spawn_egg"), Component.translatable("text.rei.spawn_egg"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().getItem() instanceof SpawnEggItem);
- registry.group(new ResourceLocation("roughlyenoughitems", "tipped_arrow"), new TranslatableComponent("item.minecraft.tipped_arrow"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "tipped_arrow"), Component.translatable("item.minecraft.tipped_arrow"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.TIPPED_ARROW));
- registry.group(new ResourceLocation("roughlyenoughitems", "music_disc"), new TranslatableComponent("text.rei.music_disc"),
+ registry.group(new ResourceLocation("roughlyenoughitems", "music_disc"), Component.translatable("text.rei.music_disc"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().getItem() instanceof RecordItem);
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/FireworkRocketRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/FireworkRocketRecipeFiller.java
index 90357ca88..d4a689df1 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/FireworkRocketRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/FireworkRocketRecipeFiller.java
@@ -31,7 +31,7 @@ import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay;
import net.minecraft.nbt.CompoundTag;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.FireworkRocketRecipe;
@@ -72,7 +72,7 @@ public class FireworkRocketRecipeFiller implements CraftingRecipeFiller<Firework
@Override
public void registerCategories(CategoryRegistry registry) {
registerExtension(registry, (bounds, widgets, display) -> {
- widgets.add(createInfoWidget(bounds, display, new TranslatableComponent("text.rei.crafting.firework.gunpowder.amount")));
+ widgets.add(createInfoWidget(bounds, display, Component.translatable("text.rei.crafting.firework.gunpowder.amount")));
});
}
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
index 34a892e69..f5771ce5b 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/MapExtendingRecipeFiller.java
@@ -30,7 +30,7 @@ import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay;
import net.minecraft.ChatFormatting;
import net.minecraft.client.resources.language.I18n;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.MapExtendingRecipe;
@@ -75,9 +75,9 @@ public class MapExtendingRecipeFiller implements CraftingRecipeFiller<MapExtendi
return tooltip;
});
stack.tooltip(
- new TranslatableComponent("filled_map.id", mapId).withStyle(ChatFormatting.GRAY),
- new TranslatableComponent("filled_map.scale", (1 << scale)).withStyle(ChatFormatting.GRAY),
- new TranslatableComponent("filled_map.level", scale, 4).withStyle(ChatFormatting.GRAY)
+ Component.translatable("filled_map.id", mapId).withStyle(ChatFormatting.GRAY),
+ Component.translatable("filled_map.scale", (1 << scale)).withStyle(ChatFormatting.GRAY),
+ Component.translatable("filled_map.level", scale, 4).withStyle(ChatFormatting.GRAY)
);
}
return stacks;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java
index a26c3f14a..24cd5644b 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ShieldDecorationRecipeFiller.java
@@ -31,6 +31,7 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay;
+import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
@@ -54,9 +55,9 @@ public class ShieldDecorationRecipeFiller implements CraftingRecipeFiller<Shield
for (int i = 0; i < 2; i++) {
BannerPattern.Builder patternBuilder = new BannerPattern.Builder();
- BannerPattern[] allPatterns = BannerPattern.values();
+ Holder<BannerPattern>[] allPatterns = Registry.BANNER_PATTERN.holders().toArray(Holder[]::new);
for (int j = 0; j < 2; j++) {
- BannerPattern pattern = allPatterns[random.nextInt(allPatterns.length - 1) + 1];
+ Holder<BannerPattern> pattern = allPatterns[random.nextInt(allPatterns.length - 1) + 1];
patternBuilder.addPattern(pattern, colors[random.nextInt(colors.length)]);
}
ItemStack banner = new ItemStack(bannerOptional.get());
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/SuspiciousStewRecipeFiller.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/SuspiciousStewRecipeFiller.java
index bfd82e763..fab4e4e70 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/SuspiciousStewRecipeFiller.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/filler/SuspiciousStewRecipeFiller.java
@@ -27,7 +27,7 @@ import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay;
-import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.chat.Component;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.SuspiciousStewRecipe;
@@ -57,7 +57,7 @@ public class SuspiciousStewRecipeFiller implements CraftingRecipeFiller<Suspicio
@Override
public void registerCategories(CategoryRegistry registry) {
registerExtension(registry, (bounds, widgets, display) -> {
- widgets.add(createInfoWidget(bounds, display, new TranslatableComponent("text.rei.crafting.suspicious_stew")));
+ widgets.add(createInfoWidget(bounds, display, Component.translatable("text.rei.crafting.suspicious_stew")));
});
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java
index 6818fa940..d922212e1 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java
@@ -55,7 +55,7 @@ public class ConfigureCategoriesScreen extends Screen {
public Screen parent;
public ConfigureCategoriesScreen(Map<CategoryIdentifier<?>, Boolean> filteringQuickCraftCategories, Set<CategoryIdentifier<?>> hiddenCategories, List<CategoryIdentifier<?>> categoryOrdering) {
- super(new TranslatableComponent("config.roughlyenoughitems.configureCategories.title"));
+ super(Component.translatable("config.roughlyenoughitems.configureCategories.title"));
this.filteringQuickCraftCategories = filteringQuickCraftCategories;
this.hiddenCategories = hiddenCategories;
this.categoryOrdering = categoryOrdering;
@@ -236,7 +236,7 @@ public class ConfigureCategoriesScreen extends Screen {
}).leftAligned();
}
{
- this.upButton = new Button(0, 0, 20, 20, new TextComponent("↑"), button -> {
+ this.upButton = new Button(0, 0, 20, 20, Component.literal("↑"), button -> {
int index = categoryOrdering.indexOf(configuration.getCategoryIdentifier());
if (index > 0) {
categoryOrdering.remove(index);
@@ -245,7 +245,7 @@ public class ConfigureCategoriesScreen extends Screen {
resetListEntries();
}
});
- this.downButton = new Button(0, 0, 20, 20, new TextComponent("↓"), button -> {
+ this.downButton = new Button(0, 0, 20, 20, Component.literal("↓"), button -> {
int index = categoryOrdering.indexOf(configuration.getCategoryIdentifier());
if (index < categoryOrdering.size() - 1) {
categoryOrdering.remove(index);
@@ -294,14 +294,14 @@ public class ConfigureCategoriesScreen extends Screen {
}
boolean shown = !hiddenCategories.contains(configuration.getCategoryIdentifier());
{
- Component subtitle = new TranslatableComponent("config.roughlyenoughitems.configureCategories.visibility." + shown)
+ Component subtitle = Component.translatable("config.roughlyenoughitems.configureCategories.visibility." + shown)
.withStyle(shown ? ChatFormatting.GREEN : ChatFormatting.RED);
int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 22, 8421504);
visibilityToggleButton.getPoint().setLocation(i + 3, y + 22);
visibilityToggleButton.render(matrices, mouseX, mouseY, delta);
}
if (shown) {
- Component subtitle = new TranslatableComponent("config.roughlyenoughitems.filtering.filteringQuickCraftCategories.configure." + filteringQuickCraftCategories.getOrDefault(configuration.getCategoryIdentifier(), configuration.isQuickCraftingEnabledByDefault()))
+ Component subtitle = Component.translatable("config.roughlyenoughitems.filtering.filteringQuickCraftCategories.configure." + filteringQuickCraftCategories.getOrDefault(configuration.getCategoryIdentifier(), configuration.isQuickCraftingEnabledByDefault()))
.withStyle(ChatFormatting.GRAY);
int i = client.font.drawShadow(matrices, subtitle.getVisualOrderText(), xPos, y + 32, 8421504);
quickCraftToggleButton.getPoint().setLocation(i + 3, y + 32);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java
index b310bf51d..9fd0c8d99 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java
@@ -269,7 +269,7 @@ public class FilteringRulesScreen extends Screen {
private static <Cache> Function<Screen, Screen> placeholderScreen(FilteringRule<Cache> r) {
class PlaceholderScreen extends OptionEntriesScreen {
public PlaceholderScreen(Screen parent) {
- super(new TranslatableComponent("config.roughlyenoughitems.filteringRulesScreen"), parent);
+ super(Component.translatable("config.roughlyenoughitems.filteringRulesScreen"), parent);
}
@Override
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java
index b2fe82b92..2b535e627 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/rules/SearchFilteringRuleType.java
@@ -88,7 +88,7 @@ public enum SearchFilteringRuleType implements FilteringRuleType<SearchFiltering
@Override
@Nullable
public Function<Screen, Screen> createEntryScreen(SearchFilteringRule rule) {
- return screen -> new OptionEntriesScreen(new TranslatableComponent("config.roughlyenoughitems.filteringRulesScreen"), screen) {
+ return screen -> new OptionEntriesScreen(Component.translatable("config.roughlyenoughitems.filteringRulesScreen"), screen) {
TextFieldListEntry entry = null;
BooleanListEntry show = null;
List<EntryWidget> entryStacks = new ArrayList<>();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java
index 3ff6caf20..768e8355a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/REIConfigScreen.java
@@ -43,16 +43,12 @@ import me.shedaniel.rei.impl.client.config.ConfigObjectImpl;
import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.config.components.ConfigCategoriesListWidget;
import me.shedaniel.rei.impl.client.gui.config.components.ConfigEntriesListWidget;
-import me.shedaniel.rei.impl.client.gui.config.options.AllREIConfigCategories;
-import me.shedaniel.rei.impl.client.gui.config.options.CompositeOption;
-import me.shedaniel.rei.impl.client.gui.config.options.OptionCategory;
-import me.shedaniel.rei.impl.client.gui.config.options.OptionGroup;
+import me.shedaniel.rei.impl.client.gui.config.options.*;
import me.shedaniel.rei.impl.client.gui.modules.Menu;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
-import net.minecraft.network.chat.TranslatableComponent;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.Nullable;
@@ -83,7 +79,7 @@ public class REIConfigScreen extends Screen implements ConfigAccess {
}
public REIConfigScreen(Screen parent, List<OptionCategory> categories) {
- super(new TranslatableComponent("config.roughlyenoughitems.title"));
+ super(ConfigUtils.translatable("config.roughlyenoughitems.title"));
this.parent = parent;
this.categories = CollectionUtils.map(categories, OptionCategory::copy);
this.cleanRequiresLevel();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
index 0cc924884..3b621b5f5 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
@@ -43,7 +43,6 @@ import me.shedaniel.rei.impl.client.gui.screen.collapsible.CollapsibleEntriesScr
import me.shedaniel.rei.impl.client.search.argument.Argument;
import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl;
import net.minecraft.client.Minecraft;
-import net.minecraft.network.chat.TranslatableComponent;
import java.util.ArrayList;
import java.util.HashMap;
@@ -256,7 +255,7 @@ public interface AllREIConfigOptions {
throw new RuntimeException(e);
}
}
- Minecraft.getInstance().setScreen(new ConfigReloadingScreen(new TranslatableComponent("text.rei.config.is.reloading"), PluginManager::areAnyReloading, onClose, null));
+ Minecraft.getInstance().setScreen(new ConfigReloadingScreen(translatable("text.rei.config.is.reloading"), PluginManager::areAnyReloading, onClose, null));
}).requiresLevel();
CompositeOption<Object> RELOAD_SEARCH = make("reset.reload_search", i -> null, (i, v) -> new Object())
.reload((access, option, onClose) -> {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ConfigUtils.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ConfigUtils.java
index 539be5526..c343c4e95 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ConfigUtils.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/ConfigUtils.java
@@ -26,9 +26,8 @@ package me.shedaniel.rei.impl.client.gui.config.options;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.impl.client.gui.config.REIConfigScreen;
import net.minecraft.client.Minecraft;
+import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
public interface ConfigUtils {
static boolean isReducedMotion() {
@@ -40,14 +39,14 @@ public interface ConfigUtils {
}
static MutableComponent literal(String text) {
- return new TextComponent(text);
+ return Component.literal(text);
}
static MutableComponent translatable(String key) {
- return new TranslatableComponent(key);
+ return Component.translatable(key);
}
static MutableComponent translatable(String key, Object... args) {
- return new TranslatableComponent(key, args);
+ return Component.translatable(key, args);
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java
index 9b2e86b1b..ad5e74d27 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/preview/TooltipPreviewer.java
@@ -35,12 +35,11 @@ import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.gui.config.ConfigAccess;
import me.shedaniel.rei.impl.client.gui.config.options.AllREIConfigOptions;
+import me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@@ -59,14 +58,14 @@ public class TooltipPreviewer {
boolean appendModNames = access.get(AllREIConfigOptions.APPEND_MOD_NAMES);
boolean appendFavorites = access.get(AllREIConfigOptions.APPEND_FAVORITES_HINT);
List<Tooltip.Entry> entries = new ArrayList<>();
- entries.add(Tooltip.entry(new TranslatableComponent("block.minecraft.oak_planks")));
+ entries.add(Tooltip.entry(ConfigUtils.translatable("block.minecraft.oak_planks")));
if (appendModNames) {
- entries.add(Tooltip.entry(new TextComponent("Minecraft").withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC)));
+ entries.add(Tooltip.entry(ConfigUtils.literal("Minecraft").withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC)));
}
if (appendFavorites) {
String name = ConfigObject.getInstance().getFavoriteKeyCode().getLocalizedName().getString();
entries.addAll(Stream.of(I18n.get("text.rei.favorites_tooltip", name).split("\n"))
- .map(TextComponent::new).map(Tooltip::entry).toList());
+ .map(ConfigUtils::literal).map(Tooltip::entry).toList());
}
List<FormattedCharSequence> components = entries.stream().flatMap(entry -> Minecraft.getInstance().font.split(entry.getAsText(), width - 12 - 4).stream()).toList();
int minWidth = components.stream().mapToInt(component -> Minecraft.getInstance().font.width(component)).max().orElse(0) + 4;
@@ -97,8 +96,7 @@ public class TooltipPreviewer {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
- bufferBuilder.end();
- BufferUploader.end(bufferBuilder);
+ BufferUploader.drawWithShader(bufferBuilder.end());
RenderSystem.disableBlend();
RenderSystem.enableTexture();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
index 1c6d86062..21ec75301 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntriesScreen.java
@@ -54,8 +54,6 @@ import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import java.util.*;
@@ -69,7 +67,7 @@ public class CollapsibleEntriesScreen extends Screen {
private boolean dirty = true;
public CollapsibleEntriesScreen(Runnable onClose, CollapsibleConfigManager.CollapsibleConfigObject configObject) {
- super(new TranslatableComponent("text.rei.collapsible.entries.title"));
+ super(Component.translatable("text.rei.collapsible.entries.title"));
this.onClose = onClose;
this.configObject = configObject;
this.prepareWidgets(configObject);
@@ -79,7 +77,7 @@ public class CollapsibleEntriesScreen extends Screen {
this.widgets.clear();
for (CollapsibleConfigManager.CustomGroup customEntry : configObject.customGroups) {
- this.widgets.add(new CollapsibleEntryWidget(true, customEntry.id, new TextComponent(customEntry.name),
+ this.widgets.add(new CollapsibleEntryWidget(true, customEntry.id, Component.literal(customEntry.name),
CollectionUtils.filterAndMap(customEntry.stacks, EntryStackProvider::isValid, EntryStackProvider::provide), configObject,
() -> {
this.prepareWidgets(configObject);
@@ -110,12 +108,12 @@ public class CollapsibleEntriesScreen extends Screen {
public void init() {
super.init();
{
- Component backText = new TextComponent("↩ ").append(new TranslatableComponent("gui.back"));
+ Component backText = Component.literal("↩ ").append(Component.translatable("gui.back"));
addRenderableWidget(new Button(4, 4, font.width(backText) + 10, 20, backText,
button -> this.onClose()));
}
{
- Component addText = new TextComponent(" + ");
+ Component addText = Component.literal(" + ");
addRenderableWidget(new Button(width - 4 - 20, 4, 20, 20, addText, $ -> {
setupCustom(new ResourceLocation("custom:" + UUID.randomUUID()), "", new ArrayList<>(), this.configObject, () -> {
this.prepareWidgets(configObject);
@@ -130,23 +128,23 @@ public class CollapsibleEntriesScreen extends Screen {
}
public static void setupCustom(ResourceLocation id, String name, List<EntryStack<?>> stacks, CollapsibleConfigManager.CollapsibleConfigObject configObject, Runnable markDirty) {
- Minecraft.getInstance().setScreen(new OptionEntriesScreen(new TranslatableComponent("text.rei.collapsible.entries.custom.title"), Minecraft.getInstance().screen) {
+ Minecraft.getInstance().setScreen(new OptionEntriesScreen(Component.translatable("text.rei.collapsible.entries.custom.title"), Minecraft.getInstance().screen) {
private TextFieldListEntry entry;
@Override
public void addEntries(Consumer<ListEntry> entryConsumer) {
addEmpty(entryConsumer, 10);
- addText(entryConsumer, new TranslatableComponent("text.rei.collapsible.entries.custom.id").withStyle(ChatFormatting.GRAY)
- .append(new TextComponent(" " + id).withStyle(ChatFormatting.DARK_GRAY)));
+ addText(entryConsumer, Component.translatable("text.rei.collapsible.entries.custom.id").withStyle(ChatFormatting.GRAY)
+ .append(Component.literal(" " + id).withStyle(ChatFormatting.DARK_GRAY)));
addEmpty(entryConsumer, 10);
- addText(entryConsumer, new TranslatableComponent("text.rei.collapsible.entries.custom.name").withStyle(ChatFormatting.GRAY));
+ addText(entryConsumer, Component.translatable("text.rei.collapsible.entries.custom.name").withStyle(ChatFormatting.GRAY));
entryConsumer.accept(this.entry = new TextFieldListEntry(width - 36, widget -> {
widget.setMaxLength(40);
if (this.entry != null) widget.setValue(this.entry.getWidget().getValue());
else widget.setValue(name);
}));
addEmpty(entryConsumer, 10);
- entryConsumer.accept(new ButtonListEntry(width - 36, $ -> new TranslatableComponent("text.rei.collapsible.entries.custom.select"), ($, button) -> {
+ entryConsumer.accept(new ButtonListEntry(width - 36, $ -> Component.translatable("text.rei.collapsible.entries.custom.select"), ($, button) -> {
CustomCollapsibleEntrySelectionScreen screen = new CustomCollapsibleEntrySelectionScreen(stacks);
screen.parent = this.minecraft.screen;
this.minecraft.setScreen(screen);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
index 90f6a617a..574a3d7a3 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/collapsible/CollapsibleEntryWidget.java
@@ -50,8 +50,6 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth;
@@ -100,7 +98,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
this.stacks = CollectionUtils.map(stacks, stack -> Widgets.createSlot(new Rectangle(0, 0, 16, 16))
.entry(stack).disableBackground());
this.configObject = configObject;
- this.toggleButton = new Button(0, 0, 20, 20, new TranslatableComponent("text.rei.collapsible.entries.toggle"), button -> {
+ this.toggleButton = new Button(0, 0, 20, 20, Component.translatable("text.rei.collapsible.entries.toggle"), button -> {
if (this.configObject.disabledGroups.contains(this.id)) {
this.configObject.disabledGroups.remove(this.id);
} else {
@@ -109,7 +107,7 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
});
this.toggleButton.setWidth(this.font.width(toggleButton.getMessage()) + 8);
if (this.custom) {
- this.deleteButton = new Button(0, 0, 20, 20, new TranslatableComponent("text.rei.collapsible.entries.delete"), button -> {
+ this.deleteButton = new Button(0, 0, 20, 20, Component.translatable("text.rei.collapsible.entries.delete"), button -> {
this.configObject.customGroups.removeIf(customEntry -> customEntry.id.equals(this.id));
markDirty.run();
});
@@ -171,11 +169,11 @@ public class CollapsibleEntryWidget extends WidgetWithBounds {
try (CloseableScissors scissors = scissor(poses, lineBounds)) {
poses.pushPose();
poses.translate(0, -idDrawer.progress() * 10, 0);
- font.drawShadow(poses, new TranslatableComponent("text.rei.collapsible.entries.count", this.stacks.size() + ""), bounds.x + 4, y, 0xFFAAAAAA);
+ font.drawShadow(poses, Component.translatable("text.rei.collapsible.entries.count", this.stacks.size() + ""), bounds.x + 4, y, 0xFFAAAAAA);
boolean enabled = !this.configObject.disabledGroups.c