diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-04-14 19:32:28 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-04-14 19:32:28 +0800 |
| commit | a92c5492155f1bd12853acea98a235d3bb78839e (patch) | |
| tree | a8cb71de497f732265b7c1567f8e9393bb92eb87 /api/src | |
| parent | 76b81a28284a8bcfb073b4386d823a73d605b971 (diff) | |
| parent | d892547a9b8a8ae85655900c08b6cc97c6aa2050 (diff) | |
| download | RoughlyEnoughItems-a92c5492155f1bd12853acea98a235d3bb78839e.tar.gz RoughlyEnoughItems-a92c5492155f1bd12853acea98a235d3bb78839e.tar.bz2 RoughlyEnoughItems-a92c5492155f1bd12853acea98a235d3bb78839e.zip | |
Merge remote-tracking branch 'origin/6.x' into 6.x-1.17
# Conflicts:
# api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java
# runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java
# runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java
Diffstat (limited to 'api/src')
5 files changed, 33 insertions, 17 deletions
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 90abba478..254d0b5fd 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 @@ -58,8 +58,8 @@ public interface CategoryRegistry extends Reloadable<REIClientPlugin>, Iterable< * * @param category the category to register */ - default <T extends Display> void register(DisplayCategory<T> category) { - register(category, config -> {}); + default <T extends Display> void add(DisplayCategory<T> category) { + add(category, config -> {}); } /** @@ -68,16 +68,16 @@ public interface CategoryRegistry extends Reloadable<REIClientPlugin>, Iterable< * @param category the category to register * @param configurator the consumer for configuring the attributes of the category */ - <T extends Display> void register(DisplayCategory<T> category, Consumer<CategoryConfiguration<T>> configurator); + <T extends Display> void add(DisplayCategory<T> category, Consumer<CategoryConfiguration<T>> configurator); /** * Registers the categories supplied. * * @param categories the categories to register */ - default <T extends Display> void register(Iterable<DisplayCategory<? extends T>> categories) { + default <T extends Display> void add(Iterable<DisplayCategory<? extends T>> categories) { for (DisplayCategory<?> category : categories) { - register(category); + add(category); } } @@ -86,9 +86,9 @@ public interface CategoryRegistry extends Reloadable<REIClientPlugin>, Iterable< * * @param categories the categories to register */ - default <T extends Display> void register(DisplayCategory<? extends T>... categories) { + default <T extends Display> void add(DisplayCategory<? extends T>... categories) { for (DisplayCategory<?> category : categories) { - register(category); + add(category); } } 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 65bdb9460..7535645a5 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 @@ -62,22 +62,22 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { * * @param display the recipe display */ - void registerDisplay(Display display); + void add(Display display); /** * Returns an unmodifiable map of displays visible to the player * * @return an unmodifiable map of displays */ - Map<CategoryIdentifier<?>, List<Display>> getAllDisplays(); + Map<CategoryIdentifier<?>, List<Display>> getAll(); /** * Returns the list of displays visible to the player for a category * * @return the list of displays */ - default <D extends Display> List<D> getDisplays(CategoryIdentifier<D> categoryId) { - return (List<D>) getAllDisplays().getOrDefault(categoryId, Collections.emptyList()); + default <D extends Display> List<D> get(CategoryIdentifier<D> categoryId) { + return (List<D>) getAll().getOrDefault(categoryId, Collections.emptyList()); } /** diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java index 3b0f6b454..7288ca97a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java @@ -49,7 +49,9 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -@Environment(EnvType.CLIENT) +/** + * @see me.shedaniel.rei.api.common.util.EntryStacks + */ public interface EntryStack<T> extends TextRepresentable, Renderer { static EntryStack<Unit> empty() { return Internals.getEntryStackProvider().empty(); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java index 3cd5fbd50..a70eb4521 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java @@ -139,6 +139,18 @@ public final class EntryStacks { } /** + * Hash Code of the {@code context} context. + * + * @param stack the stack to hash code + * @param context the context to use + * @param <T> the type of the stack + * @return the hash code of the {@code context} context + */ + public static <T> long hash(EntryStack<T> stack, ComparisonContext context) { + return stack.getDefinition().hash(stack, stack.getValue(), context); + } + + /** * Hash Code of the {@link ComparisonContext#EXACT} context, stacks with the same hash code should share the same normalized stack. * <p> * For example, enchantment books of different enchantments will not receive the same hash code under this context. @@ -147,9 +159,10 @@ public final class EntryStacks { * @param stack the stack to hash code * @param <T> the type of the stack * @return the hash code of the {@link ComparisonContext#EXACT} context + * @see #hash(EntryStack, ComparisonContext) */ public static <T> long hashExact(EntryStack<T> stack) { - return stack.getDefinition().hash(stack, stack.getValue(), ComparisonContext.EXACT); + return hash(stack, ComparisonContext.EXACT); } /** @@ -161,8 +174,9 @@ public final class EntryStacks { * @param stack the stack to hash code * @param <T> the type of the stack * @return the hash code of the {@link ComparisonContext#FUZZY} context + * @see #hash(EntryStack, ComparisonContext) */ public static <T> long hashFuzzy(EntryStack<T> stack) { - return stack.getDefinition().hash(stack, stack.getValue(), ComparisonContext.FUZZY); + return hash(stack, ComparisonContext.FUZZY); } } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/TextRepresentable.java b/api/src/main/java/me/shedaniel/rei/api/common/util/TextRepresentable.java index b4b0c9c0c..0cf9bc535 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/util/TextRepresentable.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/util/TextRepresentable.java @@ -23,11 +23,11 @@ package me.shedaniel.rei.api.common.util; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.network.chat.Component; -@Environment(EnvType.CLIENT) +/** + * A component that can be represented in {@link Component}. + */ public interface TextRepresentable { default Component asFormattedText() { return ImmutableTextComponent.EMPTY; |
