From 8c13c015031a0de865d2e767cd8e879754f803e2 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 5 Aug 2022 01:30:08 +0800 Subject: More work --- .../CategoryIdentifierConstructorImpl.java | 4 +- ...ei.impl.Internals.CategoryIdentifierConstructor | 1 - ...l.common.provider.CategoryIdentifierConstructor | 1 + .../rei/impl/client/config/ConfigManagerImpl.java | 11 +- .../rei/impl/client/config/ConfigObjectImpl.java | 7 +- .../entries/UncertainDisplayViewingScreen.java | 2 +- .../client/gui/credits/CreditsEntryListWidget.java | 2 +- .../search/method/unihan/BomopofoInputMethod.java | 142 ++++++ .../search/method/unihan/JyutpingInputMethod.java | 77 +++ .../search/method/unihan/PinyinInputMethod.java | 136 ++++++ .../search/method/unihan/UniHanInputMethod.java | 82 ++++ .../client/search/method/unihan/UniHanManager.java | 123 +++++ .../impl/client/entry/type/EntryRegistryImpl.java | 2 +- .../rei/impl/common/entry/EntryIngredientImpl.java | 4 +- .../common/entry/stack/EntryStackProviderImpl.java | 4 +- ...niel.rei.impl.Internals$EntryIngredientProvider | 1 - ...shedaniel.rei.impl.Internals$EntryStackProvider | 1 - ...ei.impl.common.provider.EntryIngredientProvider | 1 + ...iel.rei.impl.common.provider.EntryStackProvider | 1 + .../entry/comparison/NbtHasherProviderImpl.java | 4 +- .../type/types/DeferringEntryTypeProviderImpl.java | 4 +- ...l.rei.impl.Internals$DeferringEntryTypeProvider | 1 - ....shedaniel.rei.impl.Internals$NbtHasherProvider | 1 - ...impl.common.provider.DeferringEntryTypeProvider | 1 + ...niel.rei.impl.common.provider.NbtHasherProvider | 1 + .../DelegatingFavoriteEntryProviderImpl.java | 4 +- .../widget/favorites/FavoritesEntriesManager.java | 4 +- .../config/entries/FilteringAddRuleScreen.java | 3 +- .../config/entries/FilteringConfigEntries.java | 23 + .../config/entries/FilteringRulesScreen.java | 3 +- .../client/config/entries/FilteringScreen.java | 116 +++-- .../entry/filtering/FilteringRuleInternal.java | 23 + .../client/entry/filtering/FilteringRuleType.java | 25 +- .../entry/filtering/rules/ManualFilteringRule.java | 23 + .../entry/filtering/rules/SearchFilteringRule.java | 23 + .../filtering/rules/SearchFilteringRuleType.java | 21 +- .../entry/type/PreFilteredEntryListImpl.java | 28 +- .../runtime/FilteredStacksVisibilityHandler.java | 44 +- .../impl/client/init/CoreClientInitialization.java | 159 +++++++ .../rei/impl/common/init/CoreInitialization.java | 113 +++++ .../rei/impl/common/logging/LoggerInitializer.java | 2 +- .../rei/impl/common/transfer/InputSlotCrafter.java | 198 ++++++++ .../impl/common/transfer/MenuInfoRegistryImpl.java | 128 +++++ .../autocrafting/DefaultCategoryHandler.java | 185 ++++++++ ...l.rei.api.common.transfer.info.MenuInfoRegistry | 1 + .../client/gui/performance/PerformanceScreen.java | 199 ++++++++ .../entry/PerformanceConfigEntries.java | 37 ++ .../gui/performance/entry/PerformanceEntry.java | 93 ++++ .../performance/entry/PerformanceEntryImpl.java | 71 +++ .../performance/entry/SubCategoryListEntry.java | 177 +++++++ .../rei/impl/common/plugins/PluginManagerImpl.java | 153 ++++++ .../impl/common/plugins/PluginReloaderImpl.java | 290 ++++++++++++ .../plugins/performance/PerformanceLogger.java | 56 +++ .../plugins/performance/PerformanceLoggerImpl.java | 99 ++++ ...client.config.ConfigManagerInternal$SystemSetup | 1 + .../transfer/TransferHandlerRegistryImpl.java | 68 +++ ...lient.registry.transfer.TransferHandlerRegistry | 1 + .../client/view/AbstractViewSearchBuilder.java | 50 ++ .../view/LegacyWrapperViewSearchBuilder.java | 145 ++++++ .../impl/client/view/ViewSearchBuilderImpl.java | 145 ++++++ .../shedaniel/rei/impl/client/view/ViewsImpl.java | 516 +++++++++++++++++++++ .../client/view/craftable/CraftableFilter.java | 131 ++++++ 62 files changed, 3824 insertions(+), 148 deletions(-) delete mode 100644 runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals.CategoryIdentifierConstructor create mode 100644 runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.CategoryIdentifierConstructor create mode 100644 runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/BomopofoInputMethod.java create mode 100644 runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/JyutpingInputMethod.java create mode 100644 runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/PinyinInputMethod.java create mode 100644 runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanInputMethod.java create mode 100644 runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanManager.java delete mode 100644 runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryIngredientProvider delete mode 100644 runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryStackProvider create mode 100644 runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryIngredientProvider create mode 100644 runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryStackProvider delete mode 100644 runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$DeferringEntryTypeProvider delete mode 100644 runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$NbtHasherProvider create mode 100644 runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.DeferringEntryTypeProvider create mode 100644 runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.NbtHasherProvider create mode 100644 runtime-engine/initialization/src/main/java/me/shedaniel/rei/impl/client/init/CoreClientInitialization.java create mode 100644 runtime-engine/initialization/src/main/java/me/shedaniel/rei/impl/common/init/CoreInitialization.java create mode 100644 runtime-engine/menu-info/src/main/java/me/shedaniel/rei/impl/common/transfer/InputSlotCrafter.java create mode 100644 runtime-engine/menu-info/src/main/java/me/shedaniel/rei/impl/common/transfer/MenuInfoRegistryImpl.java create mode 100644 runtime-engine/menu-info/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java create mode 100644 runtime-engine/menu-info/src/main/resources/META-INF/services/me.shedaniel.rei.api.common.transfer.info.MenuInfoRegistry create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceConfigEntries.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntryImpl.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloaderImpl.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/common/plugins/performance/PerformanceLogger.java create mode 100644 runtime-engine/plugins/src/main/java/me/shedaniel/rei/impl/common/plugins/performance/PerformanceLoggerImpl.java create mode 100644 runtime-engine/plugins/src/main/resources/META-INF/services/me.shedaniel.rei.impl.client.config.ConfigManagerInternal$SystemSetup create mode 100644 runtime-engine/transfer-handlers/src/main/java/me/shedaniel/rei/impl/client/transfer/TransferHandlerRegistryImpl.java create mode 100644 runtime-engine/transfer-handlers/src/main/resources/META-INF/services/me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry create mode 100644 runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/AbstractViewSearchBuilder.java create mode 100644 runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/LegacyWrapperViewSearchBuilder.java create mode 100644 runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewSearchBuilderImpl.java create mode 100644 runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java create mode 100644 runtime-engine/views/src/main/java/me/shedaniel/rei/impl/client/view/craftable/CraftableFilter.java (limited to 'runtime-engine') diff --git a/runtime-engine/categories/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierConstructorImpl.java b/runtime-engine/categories/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierConstructorImpl.java index a4246ccec..a3eb2ae2f 100644 --- a/runtime-engine/categories/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierConstructorImpl.java +++ b/runtime-engine/categories/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierConstructorImpl.java @@ -25,13 +25,13 @@ package me.shedaniel.rei.impl.common.category; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.provider.CategoryIdentifierConstructor; import net.minecraft.resources.ResourceLocation; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -public class CategoryIdentifierConstructorImpl implements Internals.CategoryIdentifierConstructor { +public class CategoryIdentifierConstructorImpl implements CategoryIdentifierConstructor { private static final Map> CACHE = new ConcurrentHashMap<>(); @Override diff --git a/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals.CategoryIdentifierConstructor b/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals.CategoryIdentifierConstructor deleted file mode 100644 index 6909538ca..000000000 --- a/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals.CategoryIdentifierConstructor +++ /dev/null @@ -1 +0,0 @@ -me.shedaniel.rei.impl.common.category.CategoryIdentifierConstructorImpl \ No newline at end of file diff --git a/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.CategoryIdentifierConstructor b/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.CategoryIdentifierConstructor new file mode 100644 index 000000000..6909538ca --- /dev/null +++ b/runtime-engine/categories/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.CategoryIdentifierConstructor @@ -0,0 +1 @@ +me.shedaniel.rei.impl.common.category.CategoryIdentifierConstructorImpl \ No newline at end of file diff --git a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java index 25c4aeb16..4f8e6bd62 100644 --- a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java +++ b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java @@ -50,7 +50,6 @@ import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.config.addon.ConfigAddonRegistry; import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; -import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.CheatingMode; import me.shedaniel.rei.api.client.gui.config.DisplayScreenType; @@ -58,13 +57,12 @@ import me.shedaniel.rei.api.client.gui.config.SyntaxHighlightingMode; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.Internals; import me.shedaniel.rei.impl.client.config.addon.ConfigAddonRegistryImpl; import me.shedaniel.rei.impl.client.config.entries.*; -import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRule; import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen; -import me.shedaniel.rei.impl.client.gui.performance.entry.PerformanceEntry; import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -260,9 +258,6 @@ public class ConfigManagerImpl implements ConfigManagerInternal { @Override public void saveConfig() { - if (getConfig().getFilteringRules().stream().noneMatch(FilteringRule::isManual)) { - getConfig().getFilteringRules().add(new ManualFilteringRule()); - } AutoConfig.getConfigHolder(ConfigObjectImpl.class).registerLoadListener((configHolder, configObject) -> { object = configObject; return InteractionResult.PASS; @@ -313,7 +308,7 @@ public class ConfigManagerImpl implements ConfigManagerInternal { ).build(); builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.advanced")).getEntries().add(0, feedbackEntry); builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.advanced")).getEntries().add(0, new ReloadPluginsEntry(220)); - builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.advanced")).getEntries().add(0, new PerformanceEntry(220)); + builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.advanced")).getEntries().addAll(0, CollectionUtils.flatMap(Internals.resolveServices(SystemSetup.class), SystemSetup::collectAdvanced)); } return builder.setAfterInitConsumer(screen -> { ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); diff --git a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index ae2008f0a..e13b0e54d 100644 --- a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -36,7 +36,7 @@ import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.*; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -367,11 +367,6 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { return advanced.filtering.shouldFilterDisplays; } - @ApiStatus.Internal - public List getFilteringRules() { - return advanced.filtering.filteringRules; - } - @Override @ApiStatus.Experimental public boolean shouldAsyncSearch() { diff --git a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/entries/UncertainDisplayViewingScreen.java b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/entries/UncertainDisplayViewingScreen.java index 96c3542c6..21ce7ac95 100644 --- a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/entries/UncertainDisplayViewingScreen.java +++ b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/config/entries/UncertainDisplayViewingScreen.java @@ -45,7 +45,7 @@ import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.ClientInternals; import me.shedaniel.rei.impl.client.config.ConfigManagerInternal; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; diff --git a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java index 9a576014c..58cca6382 100644 --- a/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java +++ b/runtime-engine/configs/src/main/java/me/shedaniel/rei/impl/client/gui/credits/CreditsEntryListWidget.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.impl.client.gui.credits; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.gui.widget.DynamicSmoothScrollingEntryListWidget; -import me.shedaniel.rei.impl.client.gui.text.TextTransformations; +import me.shedaniel.rei.impl.client.util.TextTransformations; import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; diff --git a/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/BomopofoInputMethod.java b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/BomopofoInputMethod.java new file mode 100644 index 000000000..0054c2bc7 --- /dev/null +++ b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/BomopofoInputMethod.java @@ -0,0 +1,142 @@ +/* + * 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.search.method.unihan; + +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * MIT License + *

+ * Copyright (c) 2019 Juntong Liu + *

+ * 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. + */ +public class BomopofoInputMethod extends PinyinInputMethod { + private static final Map CONVERSION = Stream.of(new String[][]{ + {"", ""}, {"0", ""}, {"1", " "}, {"2", "6"}, {"3", "3"}, + {"4", "4"}, {"a", "8"}, {"ai", "9"}, {"an", "0"}, {"ang", ";"}, + {"ao", "l"}, {"b", "1"}, {"c", "h"}, {"ch", "t"}, {"d", "2"}, + {"e", "k"}, {"ei", "o"}, {"en", "p"}, {"eng", "/"}, {"er", "-"}, + {"f", "z"}, {"g", "e"}, {"h", "c"}, {"i", "u"}, {"ia", "u8"}, + {"ian", "u0"}, {"iang", "u;"}, {"iao", "ul"}, {"ie", "u,"}, {"in", "up"}, + {"ing", "u/"}, {"iong", "m/"}, {"iu", "u."}, {"j", "r"}, {"k", "d"}, + {"l", "x"}, {"m", "a"}, {"n", "s"}, {"o", "i"}, {"ong", "j/"}, + {"ou", "."}, {"p", "q"}, {"q", "f"}, {"r", "b"}, {"s", "n"}, + {"sh", "g"}, {"t", "w"}, {"u", "j"}, {"ua", "j8"}, {"uai", "j9"}, + {"uan", "j0"}, {"uang", "j;"}, {"uen", "mp"}, {"ueng", "j/"}, {"ui", "jo"}, + {"un", "jp"}, {"uo", "ji"}, {"v", "m"}, {"van", "m0"}, {"vang", "m;"}, + {"ve", "m,"}, {"vn", "mp"}, {"w", "j"}, {"x", "v"}, {"y", "u"}, + {"z", "y"}, {"zh", "5"}, + }).collect(Collectors.toMap(d -> IntList.of(d[0].codePoints().toArray()), d -> IntList.of(d[1].trim().codePoints().toArray()))); + + public BomopofoInputMethod(UniHanManager manager) { + super(manager); + } + + @Override + public Component getName() { + return new TranslatableComponent("text.rei.input.methods.bopomofo"); + } + + @Override + public Component getDescription() { + return new TranslatableComponent("text.rei.input.methods.bopomofo.description"); + } + + @Override + protected ExpendedChar asExpendedChar(String string) { + IntList codepoints = new IntArrayList(string.length() + 1); + int[] tone = {-1}; + string.codePoints().forEach(codepoint -> { + if (codepoint == 'ü') { + codepoints.add('v'); + return; + } + ToneEntry toneEntry = toneMap.get(codepoint); + if (toneEntry == null) { + codepoints.add(codepoint); + } else { + codepoints.add(toneEntry.codepoint()); + tone[0] = toneEntry.tone(); + } + }); + if (tone[0] != -1) { + codepoints.add(Character.forDigit(tone[0], 10)); + } + List phonemes = standard(codepoints).stream().map(str -> CONVERSION.getOrDefault(str, str)).toList(); + return new ExpendedChar(phonemes); + } + + private static List standard(IntList s) { + List ret = new ArrayList<>(); + int cursor = 0; + + // initial + if (hasInitial(s)) { + cursor = s.size() > 2 && s.getInt(1) == 'h' ? 2 : 1; + ret.add(s.subList(0, cursor)); + } + + // final + if (s.size() != cursor + 1 && s.size() - 1 > cursor) { + ret.add(s.subList(cursor, s.size() - 1)); + } + + // tone + if (s.size() >= 1) { + ret.add(s.subList(s.size() - 1, s.size())); + } + + return ret; + } + + private static boolean hasInitial(IntList s) { + return Stream.of('a', 'e', 'i', 'o', 'u', 'v').noneMatch(i -> s.getInt(0) == i); + } +} diff --git a/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/JyutpingInputMethod.java b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/JyutpingInputMethod.java new file mode 100644 index 000000000..5a48d55f6 --- /dev/null +++ b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/JyutpingInputMethod.java @@ -0,0 +1,77 @@ +/* + * 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.search.method.unihan; + +import it.unimi.dsi.fastutil.ints.IntList; +import me.shedaniel.rei.api.client.search.method.CharacterUnpackingInputMethod; +import me.shedaniel.rei.api.client.search.method.InputMethod; +import me.shedaniel.rei.api.common.util.CollectionUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; + +import java.util.Collections; +import java.util.List; + +public class JyutpingInputMethod extends UniHanInputMethod implements CharacterUnpackingInputMethod { + public JyutpingInputMethod(UniHanManager manager) { + super(manager); + } + + @Override + public Iterable expendFilter(String filter) { + return Collections.singletonList(IntList.of(filter.codePoints().toArray())); + } + + @Override + public List expendSourceChar(int codePoint) { + List sequences = dataMap.get(codePoint); + if (sequences != null && !sequences.isEmpty()) return sequences; + return List.of(new ExpendedChar(List.of(IntList.of(codePoint)))); + } + + @Override + protected String getFieldKey() { + return "kCantonese"; + } + + @Override + protected String getFieldDelimiter() { + return " "; + } + + @Override + public List getMatchingLocales() { + return CollectionUtils.filterToList(InputMethod.getAllLocales(), locale -> locale.code().startsWith("zh_")); + } + + @Override + public Component getName() { + return new TranslatableComponent("text.rei.input.methods.jyutping"); + } + + @Override + public Component getDescription() { + return new TranslatableComponent("text.rei.input.methods.jyutping.description"); + } +} diff --git a/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/PinyinInputMethod.java b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/PinyinInputMethod.java new file mode 100644 index 000000000..6c317e0dd --- /dev/null +++ b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/PinyinInputMethod.java @@ -0,0 +1,136 @@ +/* + * 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.search.method.unihan; + +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.IntList; +import me.shedaniel.rei.api.client.search.method.CharacterUnpackingInputMethod; +import me.shedaniel.rei.api.client.search.method.InputMethod; +import me.shedaniel.rei.api.common.util.CollectionUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class PinyinInputMethod extends UniHanInputMethod implements CharacterUnpackingInputMethod { + protected final Int2ObjectMap toneMap; + + protected record ToneEntry(int codepoint, int tone) {} + + public PinyinInputMethod(UniHanManager manager) { + super(manager); + toneMap = new Int2ObjectOpenHashMap<>(); + addTone('ā', "a1"); + addTone('á', "a2"); + addTone('ǎ', "a3"); + addTone('à', "a4"); + addTone('ē', "e1"); + addTone('é', "e2"); + addTone('ě', "e3"); + addTone('è', "e4"); + addTone('ī', "i1"); + addTone('í', "i2"); + addTone('ǐ', "i3"); + addTone('ì', "i4"); + addTone('ō', "o1"); + addTone('ó', "o2"); + addTone('ǒ', "o3"); + addTone('ò', "o4"); + addTone('ū', "u1"); + addTone('ú', "u2"); + addTone('ǔ', "u3"); + addTone('ù', "u4"); + addTone('ǖ', "v1"); + addTone('ǘ', "v2"); + addTone('ǚ', "v3"); + addTone('ǜ', "v4"); + } + + private void addTone(char c, String s) { + toneMap.put(c, new ToneEntry(s.charAt(0), Character.digit(s.charAt(1), 10))); + } + + @Override + public Iterable expendFilter(String filter) { + return Collections.singletonList(IntList.of(filter.codePoints().toArray())); + } + + @Override + public List expendSourceChar(int codePoint) { + List sequences = dataMap.get(codePoint); + if (sequences != null && !sequences.isEmpty()) return sequences; + return List.of(new ExpendedChar(List.of(IntList.of(codePoint)))); + } + + @Override + protected String getFieldKey() { + return "kMandarin"; + } + + @Override + protected String getFieldDelimiter() { + return " "; + } + + @Override + public List getMatchingLocales() { + return CollectionUtils.filterToList(InputMethod.getAllLocales(), locale -> locale.code().startsWith("zh_")); + } + + @Override + public Component getName() { + return new TranslatableComponent("text.rei.input.methods.pinyin"); + } + + @Override + public Component getDescription() { + return new TranslatableComponent("text.rei.input.methods.pinyin.description"); + } + + @Override + protected ExpendedChar asExpendedChar(String string) { + List codepoints = new ArrayList<>(string.length() + 1); + int[] tone = {-1}; + string.codePoints().forEach(codepoint -> { + if (codepoint == 'ü') { + codepoints.add(IntList.of('v')); + return; + } + ToneEntry toneEntry = toneMap.get(codepoint); + if (toneEntry == null) { + codepoints.add(IntList.of(codepoint)); + } else { + codepoints.add(IntList.of(toneEntry.codepoint)); + tone[0] = toneEntry.tone; + } + }); + if (tone[0] != -1) { + codepoints.add(IntList.of(Character.forDigit(tone[0], 10))); + } + return new ExpendedChar(codepoints); + } +} diff --git a/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanInputMethod.java b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanInputMethod.java new file mode 100644 index 000000000..1402c54ba --- /dev/null +++ b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanInputMethod.java @@ -0,0 +1,82 @@ +/* + * 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.search.method.unihan; + +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.IntList; +import me.shedaniel.rei.api.client.search.method.CharacterUnpackingInputMethod.ExpendedChar; +import me.shedaniel.rei.api.client.search.method.InputMethod; +import me.shedaniel.rei.api.common.util.CollectionUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + +public abstract class UniHanInputMethod implements InputMethod { + protected final UniHanManager manager; + protected Int2ObjectMap> dataMap = new Int2ObjectOpenHashMap<>(); + + public UniHanInputMethod(UniHanManager manager) { + this.manager = manager; + } + + protected abstract String getFieldKey(); + + protected abstract String getFieldDelimiter(); + + @Override + public CompletableFuture prepare(Executor executor) { + return dispose(executor) + .thenRunAsync(manager::download, executor) + .thenRunAsync(this::load, executor); + } + + public void load() { + try { + manager.load((codepoint, fieldKey, data) -> { + if (fieldKey.equals(getFieldKey())) { + String[] strings = data.split(getFieldDelimiter()); + List sequences = dataMap.computeIfAbsent(codepoint, value -> new ArrayList<>(strings.length)); + for (String string : strings) { + sequences.add(asExpendedChar(string)); + } + } + }); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + protected ExpendedChar asExpendedChar(String string) { + return new ExpendedChar(CollectionUtils.map(IntList.of(string.codePoints().toArray()), IntList::of)); + } + + @Override + public CompletableFuture dispose(Executor executor) { + return CompletableFuture.runAsync(dataMap::clear, executor); + } +} diff --git a/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanManager.java b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanManager.java new file mode 100644 index 000000000..bf36fc130 --- /dev/null +++ b/runtime-engine/default-runtime-plugin/src/main/java/me/shedaniel/rei/impl/client/search/method/unihan/UniHanManager.java @@ -0,0 +1,123 @@ +/* + * 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.search.method.unihan; + +import me.shedaniel.rei.impl.common.InternalLogger; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.LineIterator; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.zip.ZipInputStream; + +public class UniHanManager { + private final Path unihanPath; + + public UniHanManager(Path unihanPath) { + this.unihanPath = unihanPath; + } + + public boolean downloaded() { + return Files.exists(unihanPath); + } + + public void download() { + if (downloaded()) return; + try { + URL url = new URL("https://www.unicode.org/Public/UCD/latest/ucd/Unihan.zip"); + Files.deleteIfExists(unihanPath); + Path parent = unihanPath.getParent(); + if (parent != null) Files.createDirectories(parent); + HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); + long completeFileSize = httpConnection.getContentLength(); + BufferedInputStream inputStream = new BufferedInputStream(httpConnection.getInputStream()); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BufferedOutputStream bufferedStream = new BufferedOutputStream(outputStream, 1024); + byte[] data = new byte[1024]; + long downloadedFileSize = 0; + int x; + int lastPercent = 0; + while ((x = inputStream.read(data, 0, 1024)) >= 0) { + downloadedFileSize += x; + double progress = (double) downloadedFileSize / (double) completeFileSize; + int percent = (int) (progress * 100); + if (percent > lastPercent) { + lastPercent = percent; + InternalLogger.getInstance().debug("Downloading UniHan Progress: %d%%".formatted(percent)); + } + bufferedStream.write(data, 0, x); + } + bufferedStream.close(); + inputStream.close(); + Files.write(unihanPath, outputStream.toByteArray(), StandardOpenOption.CREATE); + InternalLogger.getInstance().debug("Downloaded UniHan"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public Path getUnihanPath() { + return unihanPath; + } + + public void load(DataConsumer consumer) throws IOException { + try (ZipInputStream inputStream = new ZipInputStream(Files.newInputStream(getUnihanPath()))) { + while (inputStream.getNextEntry() != null) { + read(IOUtils.lineIterator(inputStream, StandardCharsets.UTF_8), consumer); + } + } + } + + private void read(LineIterator lines, DataConsumer consumer) { + int i = 0; + while (lines.hasNext()) { + i++; + String line = lines.nextLine(); + if (line.startsWith("#") || line.isEmpty()) continue; + if (!line.startsWith("U+")) { + throw new IllegalArgumentException("Invalid line: " + i + ", " + line); + } + int firstTab = line.indexOf('\t'); + String code = line.substring(2, firstTab); + int codePoint = Integer.parseInt(code, 16); + int secondTab = line.indexOf('\t', firstTab + 1); + String fieldKey = line.substring(firstTab + 1, secondTab); + String data = line.substring(secondTab + 1); + consumer.read(codePoint, fieldKey, data); + } + } + + @FunctionalInterface + public interface DataConsumer { + void read(int codepoint, String fieldKey, String data); + } +} diff --git a/runtime-engine/entries/src/main/java/me/shedaniel/rei/impl/client/entry/type/EntryRegistryImpl.java b/runtime-engine/entries/src/main/java/me/shedaniel/rei/impl/client/entry/type/EntryRegistryImpl.java index be1ed5225..29c3ae419 100644 --- a/runtime-engine/entries/src/main/java/me/shedaniel/rei/impl/client/entry/type/EntryRegistryImpl.java +++ b/runtime-engine/entries/src/main/java/me/shedaniel/rei/impl/client/entry/type/EntryRegistryImpl.java @@ -39,7 +39,7 @@ import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryStacks; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.Internals; import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/EntryIngredientImpl.java b/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/EntryIngredientImpl.java index 017fc7cf0..4da98dd58 100644 --- a/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/EntryIngredientImpl.java +++ b/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/EntryIngredientImpl.java @@ -26,7 +26,7 @@ package me.shedaniel.rei.impl.common.entry; import com.google.common.collect.Iterators; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.provider.EntryIngredientProvider; import net.minecraft.nbt.ListTag; import org.jetbrains.annotations.ApiStatus; @@ -37,7 +37,7 @@ import java.util.function.UnaryOperator; import java.util.stream.StreamSupport; @ApiStatus.Internal -public class EntryIngredientImpl implements Internals.EntryIngredientProvider { +public class EntryIngredientImpl implements EntryIngredientProvider { @Override public EntryIngredient empty() { return EmptyEntryIngredient.EMPTY; diff --git a/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/stack/EntryStackProviderImpl.java b/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/stack/EntryStackProviderImpl.java index 3de5102f6..3cf510df6 100644 --- a/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/stack/EntryStackProviderImpl.java +++ b/runtime-engine/entry-stacks/src/main/java/me/shedaniel/rei/impl/common/entry/stack/EntryStackProviderImpl.java @@ -26,14 +26,14 @@ package me.shedaniel.rei.impl.common.entry.stack; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.BuiltinEntryTypes; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.provider.EntryStackProvider; import net.minecraft.util.Unit; import org.jetbrains.annotations.ApiStatus; import java.util.Objects; @ApiStatus.Internal -public class EntryStackProviderImpl implements Internals.EntryStackProvider { +public class EntryStackProviderImpl implements EntryStackProvider { @Override public EntryStack empty() { return EmptyEntryStack.EMPTY; diff --git a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryIngredientProvider b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryIngredientProvider deleted file mode 100644 index 9349d031d..000000000 --- a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryIngredientProvider +++ /dev/null @@ -1 +0,0 @@ -me.shedaniel.rei.impl.common.entry.EntryIngredientImpl \ No newline at end of file diff --git a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryStackProvider b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryStackProvider deleted file mode 100644 index 2ef298128..000000000 --- a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$EntryStackProvider +++ /dev/null @@ -1 +0,0 @@ -me.shedaniel.rei.impl.common.entry.stack.EntryStackProviderImpl \ No newline at end of file diff --git a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryIngredientProvider b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryIngredientProvider new file mode 100644 index 000000000..9349d031d --- /dev/null +++ b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryIngredientProvider @@ -0,0 +1 @@ +me.shedaniel.rei.impl.common.entry.EntryIngredientImpl \ No newline at end of file diff --git a/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryStackProvider b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryStackProvider new file mode 100644 index 000000000..2ef298128 --- /dev/null +++ b/runtime-engine/entry-stacks/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.EntryStackProvider @@ -0,0 +1 @@ +me.shedaniel.rei.impl.common.entry.stack.EntryStackProviderImpl \ No newline at end of file diff --git a/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java b/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java index 2b7dbe68a..4e5d02b2f 100644 --- a/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java +++ b/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java @@ -26,7 +26,7 @@ package me.shedaniel.rei.impl.common.entry.comparison; import com.google.common.base.Predicates; import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; import me.shedaniel.rei.api.common.entry.comparison.EntryComparator; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.provider.NbtHasherProvider; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -35,7 +35,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.Predicate; -public class NbtHasherProviderImpl implements Internals.NbtHasherProvider { +public class NbtHasherProviderImpl implements NbtHasherProvider { private final EntryComparator defaultHasher = _provide(); @Override diff --git a/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/DeferringEntryTypeProviderImpl.java b/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/DeferringEntryTypeProviderImpl.java index f47dd9e94..bf671635a 100644 --- a/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/DeferringEntryTypeProviderImpl.java +++ b/runtime-engine/entry-types/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/DeferringEntryTypeProviderImpl.java @@ -30,7 +30,7 @@ import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.common.entry.type.BuiltinEntryTypes; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.entry.type.EntryType; -import me.shedaniel.rei.impl.Internals; +import me.shedaniel.rei.impl.common.provider.DeferringEntryTypeProvider; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.resources.ResourceLocation; @@ -42,7 +42,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; @ApiStatus.Internal -public class DeferringEntryTypeProviderImpl implements Internals.DeferringEntryTypeProvider { +public class DeferringEntryTypeProviderImpl implements DeferringEntryTypeProvider { private static final ResourceLocation RENDERING_ID = new ResourceLocation("rendering"); private final Map> typeCache = new ConcurrentHashMap<>(); private final Supplier> empty = Suppliers.memoize(() -> emptyType(BuiltinEntryTypes.EMPTY_ID)); diff --git a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$DeferringEntryTypeProvider b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$DeferringEntryTypeProvider deleted file mode 100644 index 95aeea47d..000000000 --- a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$DeferringEntryTypeProvider +++ /dev/null @@ -1 +0,0 @@ -me.shedaniel.rei.impl.common.entry.type.types.DeferringEntryTypeProviderImpl \ No newline at end of file diff --git a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$NbtHasherProvider b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$NbtHasherProvider deleted file mode 100644 index 5f9b83304..000000000 --- a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.Internals$NbtHasherProvider +++ /dev/null @@ -1 +0,0 @@ -me.shedaniel.rei.impl.common.entry.comparison.NbtHasherProviderImpl \ No newline at end of file diff --git a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.DeferringEntryTypeProvider b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.DeferringEntryTypeProvider new file mode 100644 index 000000000..95aeea47d --- /dev/null +++ b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.DeferringEntryTypeProvider @@ -0,0 +1 @@ +me.shedaniel.rei.impl.common.entry.type.types.DeferringEntryTypeProviderImpl \ No newline at end of file diff --git a/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.NbtHasherProvider b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.NbtHasherProvider new file mode 100644 index 000000000..5f9b83304 --- /dev/null +++ b/runtime-engine/entry-types/src/main/resources/META-INF/services/me.shedaniel.rei.impl.common.provider.NbtHasherProvider @@ -0,0 +1 @@ +me.shedaniel.rei.impl.common.entry.comparison.NbtHasherProviderImpl \ No newline at end of file diff --git a/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java b/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java index 97ede0acf..39b866599 100644 --- a/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java +++ b/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/favorites/DelegatingFavoriteEntryProviderImpl.java @@ -27,7 +27,7 @@ import com.mojang.serialization.DataResult; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.client.provider.DelegatingFavoriteEntryProvider; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -37,7 +37,7 @@ import java.util.Optional; import java.util.UUID; import java.util.function.Supplier; -public class DelegatingFavoriteEntryProviderImpl implements ClientInternals.DelegatingFavoriteEntryProvider { +public class DelegatingFavoriteEntryProviderImpl implements DelegatingFavoriteEntryProvider { @Override public FavoriteEntry delegate(Supplier> result, Supplier tag) { return new DelegatedFavoriteEntry(result, tag); diff --git a/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesEntriesManager.java b/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesEntriesManager.java index 40f1de3a7..6f01cb29b 100644 --- a/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesEntriesManager.java +++ b/runtime-engine/favorites/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/FavoritesEntriesManager.java @@ -30,9 +30,9 @@ import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.overlay.OverlayListWidget; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.common.util.CollectionUtils; -import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.impl.client.config.ConfigManagerInternal; import me.shedaniel.rei.impl.client.favorites.MutableFavoritesList; +import me.shedaniel.rei.impl.client.provider.FavoritesEntriesListProvider; import java.util.AbstractList; import java.util.ArrayList; @@ -41,7 +41,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; -public class FavoritesEntriesManager implements ClientInternals.FavoritesEntriesListProvider { +public class FavoritesEntriesManager implements FavoritesEntriesListProvider { public static List getConfigFavoriteEntries() { ConfigManagerInternal manager = ConfigManagerInternal.getInstance(); diff --git a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java index abb5653ae..50580d118 100644 --- a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java +++ b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringAddRuleScreen.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.config.entries; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; -import me.shedaniel.rei.api.client.entry.filtering.FilteringRule; import me.shedaniel.rei.impl.client.entry.filtering.FilteringRuleInternal; import me.shedaniel.rei.impl.client.entry.filtering.FilteringRuleType; import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRuleType; @@ -153,7 +152,7 @@ public class FilteringAddRuleScreen extends Screen { public DefaultRuleEntry(Screen parent, FilteringEntry entry, FilteringRuleInternal rule, BiFunction screenFunction) { super(rule); - this.screenFunction = (screenFunction == null ? rule.getType().createEntryScreen().orElse(null) : screenFunction); + this.screenFunction = (screenFunction == null ? ((FilteringRuleType) rule.getType()).createEntryScreen(rule).orElse(null) : screenFunction); addButton = new Button(0, 0, 20, 20, Component.nullToEmpty(" + "), button -> { entry.edited = true; Minecraft.getInstance().setScreen(this.screenFunction.apply(entry, parent)); diff --git a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringConfigEntries.java b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringConfigEntries.java index cfb2ed8da..133cf2fb1 100644 --- a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringConfigEntries.java +++ b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringConfigEntries.java @@ -1,3 +1,26 @@ +/* + * 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.config.entries; import com.google.common.collect.Lists; diff --git a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java index 419ccb036..32a13038a 100644 --- a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java +++ b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringRulesScreen.java @@ -27,6 +27,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget; import me.shedaniel.rei.impl.client.entry.filtering.FilteringRuleInternal; +import me.shedaniel.rei.impl.client.entry.filtering.FilteringRuleType; import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRuleType; import me.shedaniel.rei.impl.client.gui.InternalTextures; import net.minecraft.client.Minecraft; @@ -184,7 +185,7 @@ public class FilteringRulesScreen extends Screen { public DefaultRuleEntry(FilteringRuleInternal rule, FilteringEntry entry, BiFunction screenFunction) { super(rule); - this.screenFunction = (screenFunction == null ? rule.getType().createEntryScreen().orElse(null) : screenFunction); + this.screenFunction = (screenFunction == null ? ((FilteringRuleType) rule.getType()).createEntryScreen(rule).orElse(null) : screenFunction); configureButton = new Button(0, 0, 20, 20, Component.nullToEmpty(null), button -> { entry.edited = true; Minecraft.getInstance().setScreen(this.screenFunction.apply(entry, Minecraft.getInstance().screen)); diff --git a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java index 168b9a19d..1e4df400b 100644 --- a/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java +++ b/runtime-engine/filtering-entries/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java @@ -35,16 +35,12 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.client.REIRuntime; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.client.search.SearchFilter; import me.shedaniel.rei.api.client.search.SearchProvider; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; -import me.shedaniel.rei.impl.client.gui.widget.BatchedEntryRendererManager; -import me.shedaniel.rei.impl.client.gui.widget.EntryWidget; -import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; @@ -64,15 +60,13 @@ import java.util.List; import java.util.Set; import java.util.function.Predicate; -import static me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget.entrySize; - @ApiStatus.Internal