From 05069aa62b09f02a8cd6e526ec58a30347a56500 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 27 Jul 2022 23:25:27 +0800 Subject: WIP Module --- .../api/client/entry/renderer/EntryRenderer.java | 4 +- .../api/client/favorites/FavoriteEntryType.java | 2 +- .../rei/api/client/overlay/OverlayListWidget.java | 2 + .../client/registry/entry/CollapsibleEntry.java | 42 ++++++++++++ .../registry/entry/CollapsibleEntryRegistry.java | 2 +- .../api/client/registry/entry/EntryRegistry.java | 8 ++- .../registry/entry/PreFilteredEntryList.java | 51 ++++++++++++++ .../rei/api/client/search/SearchFilter.java | 20 ++++++ .../rei/api/client/search/SearchProvider.java | 14 ++++ .../rei/api/common/registry/ParentReloadable.java | 5 ++ .../me/shedaniel/rei/impl/ClientInternals.java | 60 ++++++++++------- .../main/java/me/shedaniel/rei/impl/Internals.java | 78 ++++++++++++++++------ 12 files changed, 238 insertions(+), 50 deletions(-) create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntry.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/registry/entry/PreFilteredEntryList.java (limited to 'api/src/main') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java index c51309603..2aa203aa9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java @@ -29,7 +29,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.api.common.entry.type.BuiltinEntryTypes; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; @@ -46,7 +46,7 @@ import org.jetbrains.annotations.Nullable; @Environment(EnvType.CLIENT) public interface EntryRenderer extends EntryRendererProvider { static EntryRenderer empty() { - return ClientInternals.getEmptyEntryRenderer(); + return (EntryRenderer) BuiltinEntryTypes.EMPTY.getDefinition().getRenderer(); } @Environment(EnvType.CLIENT) diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java index 35a5e8f96..d80c567b0 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntryType.java @@ -80,7 +80,7 @@ public interface FavoriteEntryType { default void add(FavoriteEntry... entries) { add(false, entries); } - + @ApiStatus.Experimental void add(boolean defaultFavorited, FavoriteEntry... entries); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java index 1fa784806..57e7e8999 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java @@ -54,4 +54,6 @@ public interface OverlayListWidget { * @return whether the mouse is within the overlay list widget */ boolean containsMouse(Point point); + + void queueReloadSearch(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntry.java new file mode 100644 index 000000000..a3623970a --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntry.java @@ -0,0 +1,42 @@ +/* + * 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.api.client.registry.entry; + +import me.shedaniel.rei.api.common.entry.EntryStack; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Experimental +public interface CollapsibleEntry { + ResourceLocation getId(); + + Component getName(); + + boolean matches(EntryStack stack, long hashExact); + + boolean isExpanded(); + + void setExpanded(boolean expanded); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntryRegistry.java index c24ca5e2a..4de3468eb 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/CollapsibleEntryRegistry.java @@ -44,7 +44,7 @@ import java.util.function.Predicate; * and collect tags together. */ @ApiStatus.Experimental -public interface CollapsibleEntryRegistry extends Reloadable { +public interface CollapsibleEntryRegistry extends Reloadable, List { /** * @return the {@link CollapsibleEntryRegistry} instance */ diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java index 63ed14d72..49dec73bb 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java @@ -83,7 +83,9 @@ public interface EntryRegistry extends Reloadable { * @return the unmodifiable list of filtered entry stacks, * only available after plugins reload. */ - List> getPreFilteredList(); + default List> getPreFilteredList() { + return PreFilteredEntryList.getInstance().getList(); + } /** * Applies the filtering rules to the entry list, is rather computational expensive. @@ -154,7 +156,9 @@ public interface EntryRegistry extends Reloadable { // TODO Re-evaluate the need for this @ApiStatus.Internal - Collection> refilterNew(boolean warn, Collection> entries); + default Collection> refilterNew(boolean warn, Collection> entries) { + return PreFilteredEntryList.getInstance().refilterNew(warn, entries); + } /** * Checks if a stack is already registered. diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/PreFilteredEntryList.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/PreFilteredEntryList.java new file mode 100644 index 000000000..f9bd53422 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/PreFilteredEntryList.java @@ -0,0 +1,51 @@ +/* + * 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.api.client.registry.entry; + +import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.registry.Reloadable; +import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.Internals; +import org.jetbrains.annotations.ApiStatus; + +import java.util.Collection; +import java.util.List; + +@ApiStatus.Experimental +public interface PreFilteredEntryList extends Reloadable { + static PreFilteredEntryList getInstance() { + return ClientInternals.getPreFilteredEntryList(); + } + + // TODO Re-evaluate the need for this + @ApiStatus.Internal + Collection> refilterNew(boolean warn, Collection> entries); + + /** + * @return the unmodifiable list of filtered entry stacks, + * only available after plugins reload. + */ + List> getList(); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java index 80b4987df..0bc7f8fff 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchFilter.java @@ -23,9 +23,12 @@ package me.shedaniel.rei.api.client.search; +import it.unimi.dsi.fastutil.ints.IntIntPair; import me.shedaniel.rei.api.common.entry.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.network.chat.Style; +import org.jetbrains.annotations.ApiStatus; import java.util.Collection; import java.util.function.Predicate; @@ -80,4 +83,21 @@ public interface SearchFilter extends Predicate> { */ default void prepareFilter(Collection> stacks) { } + + /** + * Processes the decoration of the search filter. + * + * @param sink the decoration sink + */ + @ApiStatus.Experimental + default void processDecoration(ParseDecorationSink sink) { + } + + interface ParseDecorationSink { + void addQuote(int index); + + void addSplitter(int index); + + void addPart(IntIntPair range, Style style, boolean usingGrammar, Collection grammarRanges, int index); + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchProvider.java index a337e5e17..9ec3af0b1 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/search/SearchProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/search/SearchProvider.java @@ -58,4 +58,18 @@ public interface SearchProvider extends Reloadable { */ @ApiStatus.Experimental SearchFilter createFilter(String filter, InputMethod inputMethod); + + /** + * Clears the search cache. + */ + @ApiStatus.Experimental + void clearCache(); + + /** + * Returns whether the search provider has cached. + * + * @return whether the search provider has cached + */ + @ApiStatus.Experimental + boolean hasCache(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java b/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java index 44039e240..e91f19245 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/registry/ParentReloadable.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.common.registry; import me.shedaniel.rei.api.common.plugins.REIPlugin; +import me.shedaniel.rei.impl.Internals; import java.util.List; @@ -32,6 +33,10 @@ public interface ParentReloadable

> extends Reloadable

void registerReloadable(Reloadable reloadable); + default > void registerReloadable(Class reloadableClass) { + registerReloadable(Internals.resolveService(reloadableClass)); + } + @Override default void startReload() { for (ReloadStage stage : ReloadStage.values()) { diff --git a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java index 36456399b..60c6399fd 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -28,18 +28,17 @@ import com.mojang.serialization.DataResult; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.ClientHelper; -import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.DrawableConsumer; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.client.registry.entry.PreFilteredEntryList; import me.shedaniel.rei.api.client.registry.screen.ClickArea; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.plugins.PluginManager; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import net.minecraft.ReportedException; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.nbt.CompoundTag; @@ -55,19 +54,17 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; import java.util.Collection; import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Supplier; +import java.util.function.*; @ApiStatus.Internal public final class ClientInternals { - private static Supplier clientHelper = ClientInternals::throwNotSetup; - private static Supplier widgetsProvider = ClientInternals::throwNotSetup; - private static Supplier viewSearchBuilder = ClientInternals::throwNotSetup; - private static Supplier> clientPluginManager = ClientInternals::throwNotSetup; - private static Supplier> emptyEntryRenderer = ClientInternals::throwNotSetup; - private static BiFunction>, Supplier, FavoriteEntry> delegateFavoriteEntry = (supplier, toJson) -> throwNotSetup(); + private static final ClientHelper CLIENT_HELPER = resolveService(ClientHelper.class); + private static final WidgetsProvider WIDGETS_PROVIDER = resolveService(WidgetsProvider.class); + private static final ViewSearchBuilder VIEW_SEARCH_BUILDER = resolveService(ViewSearchBuilder.class); + private static final PluginManager CLIENT_PLUGIN_MANAGER = Internals.createPluginManager( + REIClientPlugin.class, + UnaryOperator.identity()); + private static final DelegatingFavoriteEntryProvider DELEGATE_FAVORITE_ENTRY = resolveService(DelegatingFavoriteEntryProvider.class); private static Function> favoriteEntryFromJson = (object) -> throwNotSetup(); private static Function clickAreaHandlerResult = (result) -> throwNotSetup(); private static BiConsumer, TooltipComponent> clientTooltipComponentProvider = (tooltip, result) -> throwNotSetup(); @@ -77,6 +74,16 @@ public final class ClientInternals { private static Supplier> jeiCompatMods = ClientInternals::throwNotSetup; private static Supplier builtinClientPlugin = ClientInternals::throwNotSetup; private static Function, TooltipComponent> missingTooltip = (stacks) -> throwNotSetup(); + private static BiConsumer crashHandler = (exception, component) -> throwNotSetup(); + private static Supplier preFilteredEntryList = ClientInternals::throwNotSetup; + + public static T resolveService(Class serviceClass) { + return Internals.resolveService(serviceClass); + } + + public static List resolveServices(Class serviceClass) { + return Internals.resolveServices(serviceClass); + } private static T throwNotSetup() { throw new AssertionError("REI Internals have not been initialized!"); @@ -108,15 +115,15 @@ public final class ClientInternals { } public static ClientHelper getClientHelper() { - return clientHelper.get(); + return CLIENT_HELPER; } public static WidgetsProvider getWidgetsProvider() { - return widgetsProvider.get(); + return WIDGETS_PROVIDER; } public static ViewSearchBuilder createViewSearchBuilder() { - return viewSearchBuilder.get(); + return VIEW_SEARCH_BUILDER; } public static Object getBuiltinPlugin() { @@ -144,30 +151,33 @@ public final class ClientInternals { } public static FavoriteEntry delegateFavoriteEntry(Supplier> supplier, Supplier toJoin) { - return delegateFavoriteEntry.apply(supplier, toJoin); + return DELEGATE_FAVORITE_ENTRY.delegate(supplier, toJoin); } public static DataResult favoriteEntryFromJson(CompoundTag tag) { return favoriteEntryFromJson.apply(tag); } - public static EntryRenderer getEmptyEntryRenderer() { - return emptyEntryRenderer.get().cast(); - } - public static List getJeiCompatMods() { return jeiCompatMods.get(); } public static PluginManager getPluginManager() { - return clientPluginManager.get(); + return CLIENT_PLUGIN_MANAGER; } public static TooltipComponent createMissingTooltip(List stacks) { return missingTooltip.apply(stacks); } - @Environment(EnvType.CLIENT) + public static PreFilteredEntryList getPreFilteredEntryList() { + return preFilteredEntryList.get(); + } + + public static void crash(ReportedException exception, String component) { + crashHandler.accept(exception, component); + } + public interface WidgetsProvider { boolean isRenderingPanel(Panel panel); @@ -207,4 +217,8 @@ public final class ClientInternals { WidgetWithBounds wrapPadded(int padLeft, int padRight, int padTop, int padBottom, WidgetWithBounds widget); } + + public interface DelegatingFavoriteEntryProvider { + FavoriteEntry delegate(Supplier> result, Supplier tag); + } } diff --git a/api/src/main/java/me/shedaniel/rei/impl/Internals.java b/api/src/main/java/me/shedaniel/rei/impl/Internals.java index 1e64c2c57..dd24614e6 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/Internals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/Internals.java @@ -31,9 +31,9 @@ import me.shedaniel.rei.api.common.entry.comparison.EntryComparator; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.entry.type.EntryType; import me.shedaniel.rei.api.common.plugins.PluginManager; +import me.shedaniel.rei.api.common.plugins.PluginView; import me.shedaniel.rei.api.common.plugins.REIPlugin; import me.shedaniel.rei.api.common.plugins.REIServerPlugin; -import me.shedaniel.rei.api.common.transfer.info.MenuInfoRegistry; import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; @@ -41,31 +41,51 @@ import net.minecraft.util.Unit; import org.jetbrains.annotations.ApiStatus; import java.lang.reflect.Field; -import java.util.function.Function; +import java.util.List; +import java.util.ServiceLoader; import java.util.function.Supplier; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; @ApiStatus.Internal public final class Internals { - private static Supplier entryStackProvider = Internals::throwNotSetup; - private static Supplier entryIngredientProvider = Internals::throwNotSetup; - private static Function> entryTypeDeferred = (object) -> throwNotSetup(); - private static Supplier>> commonPluginManager = Internals::throwNotSetup; - private static Supplier> serverPluginManager = Internals::throwNotSetup; - private static Supplier nbtHasherProvider = Internals::throwNotSetup; - private static Function> categoryIdentifier = (object) -> throwNotSetup(); - private static Supplier stubMenuInfoRegistry = Internals::throwNotSetup; + private static final EntryStackProvider ENTRY_STACK_PROVIDER = resolveService(EntryStackProvider.class); + private static final EntryIngredientProvider ENTRY_INGREDIENT_PROVIDER = resolveService(EntryIngredientProvider.class); + private static final DeferringEntryTypeProvider ENTRY_TYPE_DEFERRED = resolveService(DeferringEntryTypeProvider.class); + private static final PluginManagerConstructor PLUGIN_MANAGER_CONSTRUCTOR = resolveService(PluginManagerConstructor.class); + private static final PluginManager> COMMON_PLUGIN_MANAGER = createPluginManager( + (Class>) (Class) REIPlugin.class, + UnaryOperator.identity()); + private static final PluginManager SERVER_PLUGIN_MANAGER = createPluginManager( + REIServerPlugin.class, + view -> view.then(COMMON_PLUGIN_MANAGER.view())); + private static final NbtHasherProvider NBT_HASHER_PROVIDER = resolveService(NbtHasherProvider.class); + private static final CategoryIdentifierConstructor CATEGORY_IDENTIFIER_CONSTRUCTOR = resolveService(CategoryIdentifierConstructor.class); private static Supplier logger = Internals::throwNotSetup; private static T throwNotSetup() { throw new AssertionError("REI Internals have not been initialized!"); } - @ApiStatus.Internal - public static void attachInstance(T instance, Class clazz) { - attachInstanceSupplier(instance, clazz.getSimpleName()); + public static T resolveService(Class serviceClass) { + ServiceLoader loader = ServiceLoader.load(serviceClass); + List> providers = loader.stream().toList(); + if (providers.isEmpty()) { + throw new IllegalArgumentException("No service providers found for class " + serviceClass.getName()); + } else if (providers.size() > 1) { + throw new IllegalArgumentException("Multiple service providers found for class " + serviceClass.getName() + ": " + + providers.stream().map(provider -> provider.type().getName()) + .collect(Collectors.joining(", "))); + } else { + return providers.get(0).get(); + } + } + + public static List resolveServices(Class serviceClass) { + ServiceLoader loader = ServiceLoader.load(serviceClass); + return loader.stream().map(ServiceLoader.Provider::get).toList(); } - @ApiStatus.Internal public static void attachInstanceSupplier(T instance, String name) { attachInstance((Supplier) () -> instance, name); } @@ -86,31 +106,35 @@ public final class Internals { } public static EntryStackProvider getEntryStackProvider() { - return entryStackProvider.get(); + return ENTRY_STACK_PROVIDER; } public static EntryIngredientProvider getEntryIngredientProvider() { - return entryIngredientProvider.get(); + return ENTRY_INGREDIENT_PROVIDER; } public static EntryType deferEntryType(ResourceLocation id) { - return entryTypeDeferred.apply(id); + return ENTRY_TYPE_DEFERRED.get(id); + } + + public static

> PluginManager

createPluginManager(Class

clazz, UnaryOperator> constructor) { + return PLUGIN_MANAGER_CONSTRUCTOR.create(clazz, constructor); } public static PluginManager> getPluginManager() { - return commonPluginManager.get(); + return COMMON_PLUGIN_MANAGER; } public static PluginManager getServerPluginManager() { - return serverPluginManager.get(); + return SERVER_PLUGIN_MANAGER; } public static EntryComparator getNbtHasher(String[] ignoredKeys) { - return nbtHasherProvider.get().provide(ignoredKeys); + return NBT_HASHER_PROVIDER.provide(ignoredKeys); } public static CategoryIdentifier getCategoryIdentifier(String location) { - return (CategoryIdentifier) categoryIdentifier.apply(location); + return CATEGORY_IDENTIFIER_CONSTRUCTOR.create(location); } public static InternalLogger getInternalLogger() { @@ -137,7 +161,19 @@ public final class Internals { EntryIngredient.Builder builder(int initialCapacity); } + public interface PluginManagerConstructor { +

> PluginManager

create(Class

clazz, UnaryOperator> constructor); + } + public interface NbtHasherProvider { EntryComparator provide(String... ignoredKeys); } + + public interface DeferringEntryTypeProvider { + EntryType get(ResourceLocation id); + } + + public interface CategoryIdentifierConstructor { + CategoryIdentifier create(String location); + } } -- cgit