diff options
77 files changed, 378 insertions, 786 deletions
diff --git a/api/build.gradle b/api/build.gradle index 40ea8f83d..8a5f988f3 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,4 +1,4 @@ -archivesBaseName = rootProject.name + "-" + project.name +archivesBaseName = rootProject.name + "-" + project.name dependencies { modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}") diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 20bfdd767..571b6022a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -58,10 +58,6 @@ public interface ConfigObject { boolean isGrabbingItems(); - boolean isConfigScreenAnimated(); - - boolean isCreditsScreenAnimated(); - boolean isFavoritesAnimated(); boolean isToastDisplayedOnCopyIdentifier(); @@ -92,8 +88,6 @@ public interface ConfigObject { int getMaxRecipePerPage(); - boolean doesShowUtilsButtons(); - boolean doesDisableRecipeBook(); boolean doesFixTabCloseContainer(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java index 44f185f4c..6061e28b0 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java @@ -33,6 +33,8 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.Identifiable; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.resources.ResourceLocation; import java.util.List; @@ -41,6 +43,13 @@ import java.util.function.Consumer; import java.util.stream.Stream; import java.util.stream.StreamSupport; +/** + * Registry for registering new categories for displays. + * Relies on {@link CategoryIdentifier}, and is reset per plugin reload. + * + * @see REIClientPlugin#registerCategories(CategoryRegistry) + */ +@Environment(EnvType.CLIENT) public interface CategoryRegistry extends Reloadable<REIClientPlugin>, Iterable<CategoryRegistry.CategoryConfiguration<?>> { /** * @return the instance of {@link CategoryRegistry} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java index 07412c76c..14204c920 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java @@ -32,6 +32,7 @@ import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.RecipeManagerContext; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.world.item.crafting.Recipe; import java.util.Collection; import java.util.Collections; @@ -40,6 +41,27 @@ import java.util.Map; import java.util.function.Function; import java.util.function.Predicate; +/** + * Registry for registering displays for categories, this is called right after + * {@link me.shedaniel.rei.api.client.registry.category.CategoryRegistry}. + * + * <p>Each display should have a category associated with it that's registered, + * For any dynamic displays, you may want to look at {@link DynamicDisplayGenerator}. + * + * <p>Plugins may also determine the visibility of the displays dynamically via + * {@link DisplayVisibilityPredicate}, these predicates are preferred comparing to + * removing the displays from the registry. + * + * <p>Displays filler may be used for automatically registering displays from {@link Recipe}, + * these are filled after client recipe manager sync, and are invoked with one cycle. + * Additionally, display filters allow other mods to easily register additional displays + * for your mod. + * + * @see Display + * @see DynamicDisplayGenerator + * @see DisplayVisibilityPredicate + * @see REIClientPlugin#registerDisplays(DisplayRegistry) + */ @Environment(EnvType.CLIENT) public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { /** @@ -85,7 +107,7 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { * * @param generator the generator to register */ - <A extends Display> void registerGlobalDisplayGenerator(LiveDisplayGenerator<A> generator); + <A extends Display> void registerGlobalDisplayGenerator(DynamicDisplayGenerator<A> generator); /** * Registers a display generator @@ -93,28 +115,28 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { * @param categoryId the identifier of the category * @param generator the generator to register */ - <A extends Display> void registerDisplayGenerator(CategoryIdentifier<A> categoryId, LiveDisplayGenerator<A> generator); + <A extends Display> void registerDisplayGenerator(CategoryIdentifier<A> categoryId, DynamicDisplayGenerator<A> generator); /** * Returns an unmodifiable map of display generators * * @return an unmodifiable map of display generators */ - Map<CategoryIdentifier<?>, List<LiveDisplayGenerator<?>>> getCategoryDisplayGenerators(); + Map<CategoryIdentifier<?>, List<DynamicDisplayGenerator<?>>> getCategoryDisplayGenerators(); /** * Returns an unmodifiable list of category-less display generators * * @return an unmodifiable list of category-less display generators */ - List<LiveDisplayGenerator<?>> getGlobalDisplayGenerators(); + List<DynamicDisplayGenerator<?>> getGlobalDisplayGenerators(); /** * Returns the list of display generators for a category * * @return the list of display generators */ - default <D extends Display> List<LiveDisplayGenerator<?>> getCategoryDisplayGenerators(CategoryIdentifier<D> categoryId) { + default <D extends Display> List<DynamicDisplayGenerator<?>> getCategoryDisplayGenerators(CategoryIdentifier<D> categoryId) { return getCategoryDisplayGenerators().getOrDefault(categoryId, Collections.emptyList()); } @@ -153,8 +175,8 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { /** * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> - * Vanilla {@link net.minecraft.world.item.crafting.Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link net.minecraft.world.item.crafting.Recipe}. + * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displaies for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -168,8 +190,8 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { /** * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> - * Vanilla {@link net.minecraft.world.item.crafting.Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link net.minecraft.world.item.crafting.Recipe}. + * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displaies for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param predicate the predicate of {@code T} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DynamicDisplayGenerator.java index 04cfe3198..9c088e5e5 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DynamicDisplayGenerator.java @@ -24,13 +24,22 @@ package me.shedaniel.rei.api.client.registry.display; import me.shedaniel.rei.api.client.view.ViewSearchBuilder; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; import java.util.List; import java.util.Optional; -public interface LiveDisplayGenerator<T extends Display> { +/** + * Interface for generating dynamic displays at runtime. + * Invoked per display view search, so please keep this performant. + * + * @param <T> the type of displays to generate + * @see DisplayRegistry#registerDisplayGenerator(CategoryIdentifier, DynamicDisplayGenerator) + * @see DisplayRegistry#registerGlobalDisplayGenerator(DynamicDisplayGenerator) + */ +public interface DynamicDisplayGenerator<T extends Display> { default Optional<List<T>> getRecipeFor(EntryStack<?> entry) { return Optional.empty(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java index dfc7d7b85..28eff1b9e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java @@ -39,9 +39,9 @@ public interface DisplayVisibilityPredicate extends Comparable<DisplayVisibility /** * Handles the visibility of the display. - * {@link ActionResult#PASS} to pass the handling to another handler - * {@link ActionResult#SUCCESS} to always display it - * {@link ActionResult#FAIL} to never display it + * {@link InteractionResult#PASS} to pass the handling to another handler + * {@link InteractionResult#SUCCESS} to always display it + * {@link InteractionResult#FAIL} to never display it * * @param category the category of the display * @param display the display of the recipe |
