aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-05-28 21:32:59 +0800
committershedaniel <daniel@shedaniel.me>2021-05-28 21:34:16 +0800
commitf644c84c664c9bc64e08d100e799caee6750e796 (patch)
treece49adc1884259899dddae338449b1582476ddcb /api
parente82ab958bc7d13e556d7426b7a1862ec76e23eba (diff)
parentc16a70a0f43a96b6dd2afa86b4fe35f501530aa2 (diff)
downloadRoughlyEnoughItems-f644c84c664c9bc64e08d100e799caee6750e796.tar.gz
RoughlyEnoughItems-f644c84c664c9bc64e08d100e799caee6750e796.tar.bz2
RoughlyEnoughItems-f644c84c664c9bc64e08d100e799caee6750e796.zip
Merge remote-tracking branch 'origin/6.x' into 6.x-1.17
# Conflicts: # runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java # runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java # runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java # runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java # runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DelegateScreen.java # runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/TransformingScreen.java # settings.gradle
Diffstat (limited to 'api')
-rw-r--r--api/build.gradle2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java6
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/category/CategoryRegistry.java9
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java40
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DynamicDisplayGenerator.java (renamed from api/src/main/java/me/shedaniel/rei/api/client/registry/display/LiveDisplayGenerator.java)11
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/visibility/DisplayVisibilityPredicate.java6
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java18
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java1
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/Views.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java19
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java1
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java8
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java29
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java17
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java16
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java2
19 files changed, 156 insertions, 44 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
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 d51449d65..6c439a43c 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
@@ -29,6 +29,9 @@ import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.api.common.registry.Reloadable;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.core.NonNullList;
+import net.minecraft.core.Registry;
+import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;
@@ -40,6 +43,21 @@ import java.util.function.LongPredicate;
import java.util.function.Predicate;
import java.util.stream.Stream;
+/**
+ * Registry for registering {@link EntryStack} for display on the overlay entry list.
+ *
+ * <p>The default REI plugin iterates both {@link Registry#ITEM} and {@link Registry#FLUID}
+ * to register new entries. Other plugins may override this default behaviour, altering
+ * the entry list.
+ *
+ * <p>REI plugins should only add entries during reload, modifications outside the
+ * reload phase may not be reflected immediately.
+ *
+ * <p>While this registry can be used for registering variants of stacks, there may be
+ * native alternatives such as {@link Item#fillItemCategory(CreativeModeTab, NonNullList)}.
+ *
+ * @see REIClientPlugin#registerEntries(EntryRegistry)
+ */
@Environment(EnvType.CLIENT)
public interface EntryRegistry extends Reloadable<REIClientPlugin> {
/**
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
index ef0559364..3c3ea6462 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandler.java
@@ -301,5 +301,4 @@ public interface TransferHandler extends Comparable<TransferHandler> {
return recipeDisplaySupplier.get();
}
}
-
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java
index 6ddd1b416..7280c4e6a 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java
@@ -38,8 +38,7 @@ public interface Views extends Reloadable<REIClientPlugin> {
/**
* Returns all craftable items from materials.
*
- * @param inventoryItems the materials
* @return the list of craftable entries
*/
- Collection<EntryStack<?>> findCraftableEntriesByMaterials(Iterable<? extends EntryStack<?>> inventoryItems);
+ Collection<EntryStack<?>> findCraftableEntriesByMaterials();
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
index 8b2c8c0e1..a3cf6cc08 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
@@ -27,8 +27,17 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.api.common.plugins.REIPlugin;
import me.shedaniel.rei.api.common.registry.Reloadable;
+import me.shedaniel.rei.api.common.transfer.info.MenuSerializationContext;
import net.minecraft.nbt.CompoundTag;
+/**
+ * The display serializer used for display serialization, useful for persistent displays across reloads,
+ * and server-client communication.
+ *
+ * <p>This is mostly a fallback system for {@link me.shedaniel.rei.api.common.transfer.info.MenuInfo#save(MenuSerializationContext, Display)}.
+ *
+ * @see REIPlugin#registerDisplaySerializer(DisplaySerializerRegistry)
+ */
public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> {
static DisplaySerializerRegistry getInstance() {
return PluginManager.getInstance().get(DisplaySerializerRegistry.class);
@@ -37,9 +46,6 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> {
/**
* Registers a {@link DisplaySerializer} for serializing a {@link Display} for syncing across server-client, and
* for serializing displays to disk for favorites.
- * <p>
- * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers,
- * or mark themselves as unavailable for serialization.
*
* @param categoryId the category identifier of the display
* @param serializer the serializer of the display
@@ -50,20 +56,15 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> {
/**
* Marks a {@link Display} as unavailable to sync across server-client, and
* for serializing displays to disk for favorites.
- * <p>
- * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers,
- * or mark themselves as unavailable for serialization.
*
* @param categoryId the category identifier of the display
* @param <D> the type of the display
*/
<D extends Display> void registerNotSerializable(CategoryIdentifier<D> categoryId);
- <D extends Display> boolean hasRegistered(CategoryIdentifier<D> categoryId);
-
<D extends Display> boolean hasSerializer(CategoryIdentifier<D> categoryId);
- <D extends Display> CompoundTag save(CategoryIdentifier<? extends D> categoryId, D display, CompoundTag tag);
+ <D extends Display> CompoundTag save(D display, CompoundTag tag);
<D extends Display> D read(CategoryIdentifier<? extends D> categoryId, CompoundTag tag);
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java
index f8489ef2e..b49a051d1 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java
@@ -27,6 +27,11 @@ import me.shedaniel.architectury.fluid.FluidStack;
import me.shedaniel.rei.api.common.plugins.PluginManager;
import net.minecraft.world.level.material.Fluid;
+/**
+ * {@inheritDoc}
+ *
+ * @see me.shedaniel.rei.api.common.plugins.REIPlugin#registerFluidComparators(FluidComparatorRegistry)
+ */
public interface FluidComparatorRegistry extends EntryComparatorRegistry<FluidStack, Fluid> {
/**
* @return the instance of {@link FluidComparatorRegistry}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
index 299eab648..fca219167 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java
@@ -27,6 +27,11 @@ import me.shedaniel.rei.api.common.plugins.PluginManager;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
+/**
+ * {@inheritDoc}
+ *
+ * @see me.shedaniel.rei.api.common.plugins.REIPlugin#registerItemComparators(ItemComparatorRegistry)
+ */
public interface ItemComparatorRegistry extends EntryComparatorRegistry<ItemStack, Item> {
/**
* @return the instance of {@link ItemComparatorRegistry}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java
index 880f2ed1c..555149b8e 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java
@@ -41,6 +41,7 @@ import java.util.Collection;
* A definition of an {@link EntryType}, an interface to provide information from an object type.
*
* @param <T> the type of entry
+ * @see EntryTypeRegistry
*/
public interface EntryDefinition<T> {
Class<T> getValueType();
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java
index ae7674c23..7f81fc181 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeBridge.java
@@ -28,8 +28,14 @@ import net.minecraft.world.InteractionResultHolder;
import java.util.stream.Stream;
+/**
+ * A bridge of two different entry types, for comparison and equality checks.
+ *
+ * @param <A> the original entry type
+ * @param <B> the destination entry type
+ * @see EntryTypeRegistry#registerBridge(EntryType, EntryType, EntryTypeBridge)
+ */
@FunctionalInterface
public interface EntryTypeBridge<A, B> {
-
InteractionResultHolder<Stream<EntryStack<B>>> bridge(EntryStack<A> object);
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
index 9b62c3d5f..c376a2b88 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryTypeRegistry.java
@@ -31,6 +31,21 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set;
+/**
+ * Registry for registering alternative entry types.
+ *
+ * <p>{@link EntryType} must be declared statically, deferring to the actual
+ * definition by the identifier of the type. During reload, plugins should
+ * register {@link EntryDefinition} for their deferred {@link EntryType},
+ * these definitions are dynamic.
+ *
+ * <p>{@link EntryTypeBridge} may be used to convert and compare between
+ * different types
+ *
+ * @see EntryDefinition
+ * @see #registerBridge(EntryType, EntryType, EntryTypeBridge)
+ * @see REIPlugin#registerEntryTypes(EntryTypeRegistry)
+ */
public interface EntryTypeRegistry extends Reloadable<REIPlugin<?>> {
static EntryTypeRegistry getInstance() {
return PluginManager.getInstance().get(EntryTypeRegistry.class);
@@ -76,16 +91,26 @@ public interface EntryTypeRegistry extends Reloadable<REIPlugin<?>> {
@Nullable
EntryDefinition<?> get(ResourceLocation id);
+ /**
+ * Returns the set of types in their identifier form.
+ *
+ * @return the set of types
+ */
Set<ResourceLocation> keySet();
+ /**
+ * Returns the set of entry definitions.
+ *
+ * @return the set of entry definitions
+ */
Set<EntryDefinition<?>> values();
/**
* Register a bridge between two entry types, for example, item to fluid, this is used, to
- * approximately match two entry stacks,.
+ * approximately match two entry stacks.
* <p>
* For bridging two entry types, only 1 one way bridge is required, two way bridges are discouraged
- * for performance issues.
+ * for performance issues and possible recursion.
*
* @param original the original entry type
* @param destination the destination entry type
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
index 44998c914..35394feab 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei.api.common.plugins;
+import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.display.DisplaySerializerRegistry;
import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry;
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
@@ -33,21 +34,21 @@ import org.jetbrains.annotations.ApiStatus;
import java.util.Collection;
import java.util.Collections;
+/**
+ * Base interface for a REI plugin.
+ *
+ * @see REIServerPlugin
+ * @see REIClientPlugin
+ */
@ApiStatus.OverrideOnly
public interface REIPlugin<P extends REIPlugin<?>> extends Comparable<REIPlugin<P>>, REIPluginProvider<P> {
/**
- * @return the priority of the plugin, the smaller the number, the earlier it is called.
+ * @return the priority of the plugin, the smaller the priority, the earlier it is called.
*/
- default int getPriority() {
+ default double getPriority() {
return 0;
}
- default String getPluginName() {
- Class<?> self = getClass();
- String simpleName = self.getSimpleName();
- return simpleName == null ? self.getName() : simpleName;
- }
-
@Override
default int compareTo(REIPlugin o) {
return Double.compare(getPriority(), o.getPriority());
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java
index 4380fb0cb..4f0f6d815 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPluginProvider.java
@@ -25,6 +25,11 @@ package me.shedaniel.rei.api.common.plugins;
import java.util.Collection;
+/**
+ * A provider for {@link REIPlugin}.
+ *
+ * @param <P> the type of plugin
+ */
public interface REIPluginProvider<P extends REIPlugin<?>> {
default String getPluginProviderName() {
Class<?> self = getClass();
@@ -32,7 +37,18 @@ public interface REIPluginProvider<P extends REIPlugin<?>> {
return simpleName == null ? self.getName() : simpleName;
}
+ /**
+ * Provides the collection of REI plugins, can be dynamic.
+ *
+ * @return the collection of REI plugins.
+ */
Collection<P> provide();
+ /**
+ * Returns the type of plugin this provider provides,
+ * should be same as {@link P}.
+ *
+ * @return the type of plugin this provider provides
+ */
Class<P> getPluginProviderClass();
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
index 79d3fc431..283a2078f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfo.java
@@ -131,7 +131,7 @@ public interface MenuInfo<T extends AbstractContainerMenu, D extends Display> ex
* @return the {@link CompoundTag} serialized
*/
default CompoundTag save(MenuSerializationContext<T, ?, D> context, D display) {
- return DisplaySerializerRegistry.getInstance().save(display.getCategoryIdentifier(), display, new CompoundTag());
+ return DisplaySerializerRegistry.getInstance().save(display, new CompoundTag());
}
/**
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java
index 29942fcc0..44ca628b6 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/transfer/info/MenuInfoRegistry.java
@@ -29,6 +29,7 @@ import me.shedaniel.rei.api.common.plugins.PluginManager;