From e6687c01b254bf903d4895aa0bb631b1679d465c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 18 Dec 2022 20:24:23 +0800 Subject: Close #913 --- api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'api') 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 02afcd7f4..94e119eae 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 @@ -135,6 +135,9 @@ public interface ConfigObject { */ boolean isEntryListWidgetScrolled(); + @ApiStatus.Experimental + boolean isHidingEntryPanelIfIdle(); + /** * Returns whether REI should append mod names to tooltips. * -- cgit From ffe21652b40a93a00f33a27a5ecf41479b48bcd9 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 18 Dec 2022 20:50:56 +0800 Subject: Close #1131 --- .../client/registry/display/DisplayRegistry.java | 121 +++++++++++++++++++-- 1 file changed, 114 insertions(+), 7 deletions(-) (limited to 'api') 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 fd34e4e84..b708a2e31 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 @@ -212,7 +212,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -227,7 +227,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, RecipeType recipeType, Function> filler) { + registerRecipesFiller(typeClass, type -> Objects.equals(recipeType, type), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -242,7 +258,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Function> filler) { + registerRecipesFiller(typeClass, recipeType, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -257,7 +289,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Predicate predicate, Function> filler) { + registerDisplaysFiller(typeClass, recipe -> recipeType.test((RecipeType) recipe.getType()) && ((Predicate) predicate).test(recipe), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -272,7 +320,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default void registerDisplaysFiller(Class typeClass, Function> filler) { + registerDisplaysFiller(typeClass, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param predicate the predicate of {@code T} @@ -286,7 +350,22 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param predicate the predicate of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Class typeClass, Predicate predicate, Function> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param predicate the predicate of {@code T} and reason @@ -301,7 +380,22 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param predicate the predicate of {@code T} and reason + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Class typeClass, BiPredicate predicate, Function> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param predicate the predicate of the object * @param filler the filler, taking an object and returning a {@code D} @@ -309,6 +403,19 @@ public interface DisplayRegistry extends RecipeManagerContext { */ void registerFiller(Predicate predicate, Function filler); + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param predicate the predicate of the object + * @param filler the filler, taking an object and returning a {@code D} + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Predicate predicate, Function> filler); + /** * Tries to fill displays from {@code T}. * -- cgit From c93345b568ba0c6231986cac30485e689212c731 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 25 Dec 2022 00:10:10 +0800 Subject: Implement Unified Ingredients --- .../rei/api/common/entry/EntryIngredient.java | 51 ++++++++++++++++++++++ .../entry/settings/EntryIngredientSetting.java | 33 ++++++++++++++ .../rei/api/common/util/CollectionUtils.java | 9 ++-- 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java index f0c634b11..f21719676 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java @@ -23,13 +23,16 @@ package me.shedaniel.rei.api.common.entry; +import me.shedaniel.rei.api.common.entry.settings.EntryIngredientSetting; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.impl.Internals; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.UUID; import java.util.function.Predicate; import java.util.function.UnaryOperator; import java.util.stream.Collector; @@ -198,6 +201,54 @@ public interface EntryIngredient extends List> { */ EntryIngredient map(UnaryOperator> transformer); + /** + * Returns the value of a {@link EntryIngredientSetting} of this {@link EntryIngredient}. + *

+ * This method returns {@code null} if the setting is not set. + * + * @param setting the setting to get + * @param the type of the setting + * @return the value of the setting + */ + @Nullable + @ApiStatus.Experimental + T getSetting(EntryIngredientSetting setting); + + /** + * Applies a setting to this {@link EntryIngredient}. + *

+ * It is generally not recommended to use this method, but to instead use the helper + * methods such as {@link EntryIngredient#unifyFocuses(EntryIngredient...)}. + * + * @param setting the setting to apply + * @param value the value of the setting to apply + * @param the type of the setting + * @return this {@link EntryStack} + */ + @ApiStatus.Experimental + EntryIngredient setting(EntryIngredientSetting setting, T value); + + /** + * Unifies focuses for the given {@link EntryIngredient}s, so the selection for these + * {@link EntryIngredient}s will be the same. + *

+ * For example, a recipe that accepts some type of banner pattern and will output a certain + * type of cloned banner pattern should have both these ingredients unified, such that + * the natural cycling of the ingredient should still make sure these two ingredients + * are matching. + *

+ * For that reason, all ingredients passed to this method must have the same size. + * + * @param ingredients the ingredients to unify + */ + @ApiStatus.Experimental + static void unifyFocuses(EntryIngredient... ingredients) { + UUID uuid = UUID.randomUUID(); + for (EntryIngredient ingredient : ingredients) { + ingredient.setting(EntryIngredientSetting.FOCUS_UUID, uuid); + } + } + @ApiStatus.NonExtendable interface Builder { Builder add(EntryStack stack); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java new file mode 100644 index 000000000..88766ff5d --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java @@ -0,0 +1,33 @@ +/* + * 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.common.entry.settings; + +import org.jetbrains.annotations.ApiStatus; + +import java.util.UUID; + +@ApiStatus.Experimental +public interface EntryIngredientSetting { + EntryIngredientSetting FOCUS_UUID = new EntryIngredientSetting<>() {}; +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java index bd8376e53..3ac72cdf1 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java @@ -514,6 +514,10 @@ public class CollectionUtils { @SafeVarargs public static List concatUnmodifiable(List... lists) { + return new ListConcatenationView<>(Arrays.asList(lists)); + } + + public static List concatUnmodifiable(Iterable> lists) { return new ListConcatenationView<>(lists); } @@ -521,10 +525,9 @@ public class CollectionUtils { * A list which acts as view of the concatenation of a number of lists. */ private static class ListConcatenationView extends AbstractList { - private final List[] lists; + private final Iterable> lists; - @SafeVarargs - public ListConcatenationView(List... lists) { + public ListConcatenationView(Iterable> lists) { this.lists = lists; } -- cgit From b13cdac76a661effc3f20eee4fbfe0de5090141d Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 25 Dec 2022 00:10:44 +0800 Subject: Add helper methods from ClientEntryStacks into EntryStack --- .../api/client/entry/renderer/EntryRenderer.java | 2 +- .../entry/renderer/EntryRendererRegistry.java | 2 +- .../rei/api/client/util/ClientEntryStacks.java | 61 +++++++++++++++++- .../shedaniel/rei/api/common/entry/EntryStack.java | 75 +++++++++++++++++++--- 4 files changed, 128 insertions(+), 12 deletions(-) (limited to 'api') 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 81bb56d15..03503919a 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 @@ -36,7 +36,7 @@ import org.jetbrains.annotations.Nullable; /** * A renderer to render a {@link EntryStack}. - * Use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setRenderer} to change the {@link EntryRenderer} for a {@link EntryStack}. + * Use {@link EntryStack#withRenderer} to change the {@link EntryRenderer} for a {@link EntryStack}. * * @param the entry type * @see BatchedEntryRenderer diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java index f1dbe8d7b..0f3f18c6f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java @@ -36,7 +36,7 @@ import org.jetbrains.annotations.Nullable; /** * Registry to transform {@link EntryRenderer} for stacks at a global level. - * For specific stacks, you can use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setRenderer} + * For specific stacks, you can use {@link EntryStack#withRenderer} */ @ApiStatus.Experimental public interface EntryRendererRegistry extends Reloadable { diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java index 5fa855549..48ce5985a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/util/ClientEntryStacks.java @@ -25,10 +25,16 @@ package me.shedaniel.rei.api.client.util; import dev.architectury.fluid.FluidStack; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.client.entry.renderer.EntryRendererProvider; +import me.shedaniel.rei.api.client.entry.renderer.EntryRendererRegistry; import me.shedaniel.rei.api.client.entry.type.BuiltinClientEntryTypes; import me.shedaniel.rei.api.client.gui.Renderer; 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.api.common.entry.type.EntryDefinition; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import net.minecraft.network.chat.Component; import java.util.function.BiFunction; import java.util.function.Function; @@ -44,22 +50,75 @@ public final class ClientEntryStacks { return EntryStack.of(BuiltinClientEntryTypes.RENDERING, renderer); } + /** + * Sets a renderer for the {@link EntryStack}. This will override the default renderer from the {@link EntryDefinition}. + *

+ * You can transform the renderer on a {@link EntryType} level + * using {@link EntryRendererRegistry#register(EntryType, EntryRendererProvider)}. + * + * @return the {@link EntryStack} + * @see EntryStack#getRenderer() for how the tooltip is resolved + * @see EntryRenderer#empty() for an empty renderer + * @deprecated use {@link EntryStack#withRenderer(EntryRenderer)} with {@link EntryRenderer#empty()} instead + */ + @Deprecated(forRemoval = true) public static EntryStack setNotRenderer(EntryStack stack) { return setRenderer(stack, EntryRenderer.empty()); } + /** + * Sets a renderer for the {@link EntryStack}. This will override the default renderer from the {@link EntryDefinition}. + *

+ * You can transform the renderer on a {@link EntryType} level + * using {@link EntryRendererRegistry#register(EntryType, EntryRendererProvider)}. + * + * @param renderer the new renderer to use + * @return the {@link EntryStack} + * @see EntryStack#getRenderer() for how the tooltip is resolved + * @see EntryRenderer#empty() for an empty renderer + * @deprecated use {@link EntryStack#withRenderer(EntryRenderer)} instead + */ + @Deprecated(forRemoval = true) public static EntryStack setRenderer(EntryStack stack, EntryRenderer renderer) { return stack.setting(EntryStack.Settings.RENDERER, s -> renderer).cast(); } + /** + * Sets a renderer for the {@link EntryStack}. This will override the default renderer from the {@link EntryDefinition}. + *

+ * You can transform the renderer on a {@link EntryType} level + * using {@link EntryRendererRegistry#register(EntryType, EntryRendererProvider)}. + * + * @param rendererProvider the new renderer to use + * @return the {@link EntryStack} + * @see EntryStack#getRenderer() for how the tooltip is resolved + * @see EntryRenderer#empty() for an empty renderer + * @deprecated use {@link EntryStack#withRenderer(Function)} instead + */ + @Deprecated(forRemoval = true) @SuppressWarnings("rawtypes") public static EntryStack setRenderer(EntryStack stack, Function, EntryRenderer> rendererProvider) { return stack.setting(EntryStack.Settings.RENDERER, (Function) rendererProvider).cast(); } + /** + * Sets a tooltip processor to the {@link EntryStack}. The processor will be used to modify the tooltip. + *

+ * You can transform the tooltip on a {@link EntryType} level + * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. + *

+ * To append to the tooltip, use {@link EntryStack#tooltip(Component...)} instead. + * + * @param stack the stack to set the tooltip processor to + * @param processor the processor to modify the tooltips + * @return the {@link EntryStack} + * @see EntryStack#getTooltip(TooltipContext, boolean) for how the tooltip is resolved + * @deprecated use {@link EntryStack#tooltipProcessor(BiFunction)} instead + */ @SuppressWarnings("rawtypes") + @Deprecated(forRemoval = true) public static EntryStack setTooltipProcessor(EntryStack stack, BiFunction, Tooltip, Tooltip> processor) { - return stack.setting(EntryStack.Settings.TOOLTIP_PROCESSOR, (BiFunction) processor).cast(); + return stack.tooltipProcessor((BiFunction) processor); } public static EntryStack setFluidRenderRatio(EntryStack stack, float ratio) { 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 9acf0c8ee..4b79fce3f 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 @@ -27,6 +27,7 @@ import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.client.entry.renderer.EntryRendererProvider; import me.shedaniel.rei.api.client.entry.renderer.EntryRendererRegistry; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; @@ -194,7 +195,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. *

* This tooltip can be appended by {@link EntryStack#tooltip(Component...)}, - * and further processed by {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setTooltipProcessor(EntryStack, BiFunction)}. + * and further processed by {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param context the tooltip context * @param appendModName whether to append the mod name @@ -214,7 +215,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. *

* This tooltip can be appended by {@link EntryStack#tooltip(Component...)}, - * and further processed by {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setTooltipProcessor(EntryStack, BiFunction)}. + * and further processed by {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param context the tooltip context * @return the tooltip, can be {@code null} @@ -257,7 +258,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * then is processed by {@link EntryRendererRegistry}. *

* To modify the renderer at a per stack level, - * use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setRenderer(EntryStack, EntryRenderer)}. + * use {@link EntryStack#withRenderer(EntryRenderer)} instead. * * @return the {@link EntryRenderer} of this {@link EntryStack} */ @@ -405,7 +406,7 @@ public interface EntryStack extends TextRepresentable, Renderer { *

* It is generally not recommended to use this method, but to instead use the helper * methods such as {@link EntryStack#tooltip(Component...)} and - * the methods in {@link me.shedaniel.rei.api.client.util.ClientEntryStacks}. + * the methods in {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param settings the setting to apply * @param value the value of the setting to apply @@ -459,7 +460,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * You can transform the tooltip on a {@link EntryType} level * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. *

- * To modify the tooltip, use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setTooltipProcessor(EntryStack, BiFunction)} instead. + * To modify the tooltip, use {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param tooltips the tooltips to append * @return this {@link EntryStack} @@ -476,7 +477,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * You can transform the tooltip on a {@link EntryType} level * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. *

- * To modify the tooltip, use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setTooltipProcessor(EntryStack, BiFunction)} instead. + * To modify the tooltip, use {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param tooltips the tooltips to append * @return this {@link EntryStack} @@ -493,7 +494,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * You can transform the tooltip on a {@link EntryType} level * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. *

- * To modify the tooltip, use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setTooltipProcessor(EntryStack, BiFunction)} instead. + * To modify the tooltip, use {@link EntryStack#tooltipProcessor(BiFunction)} instead. * * @param tooltipProvider the provider for the tooltips to append * @return this {@link EntryStack} @@ -504,6 +505,56 @@ public interface EntryStack extends TextRepresentable, Renderer { return setting(Settings.TOOLTIP_APPEND_EXTRA, tooltipProvider); } + /** + * Sets a tooltip processor to this {@link EntryStack}. The processor will be used to modify the tooltip. + *

+ * You can transform the tooltip on a {@link EntryType} level + * using {@link EntryRendererRegistry#transformTooltip(EntryType, EntryRendererRegistry.TooltipTransformer)}. + *

+ * To append to the tooltip, use {@link EntryStack#tooltip(Component...)} instead. + * + * @param tooltipProcessor the processor to modify the tooltips + * @return this {@link EntryStack} + * @see EntryStack#getTooltip(TooltipContext, boolean) for how the tooltip is resolved + */ + @SuppressWarnings("rawtypes") + @Environment(EnvType.CLIENT) + default EntryStack tooltipProcessor(BiFunction, Tooltip, Tooltip> tooltipProcessor) { + return setting(EntryStack.Settings.TOOLTIP_PROCESSOR, (BiFunction) tooltipProcessor).cast(); + } + + /** + * Sets a renderer for this {@link EntryStack}. This will override the default renderer from the {@link EntryDefinition}. + *

+ * You can transform the renderer on a {@link EntryType} level + * using {@link EntryRendererRegistry#register(EntryType, EntryRendererProvider)}. + * + * @param renderer the new renderer to use + * @return this {@link EntryStack} + * @see EntryStack#getRenderer() for how the tooltip is resolved + * @see EntryRenderer#empty() for an empty renderer + */ + @Environment(EnvType.CLIENT) + default EntryStack withRenderer(EntryRenderer renderer) { + return setting(Settings.RENDERER, $ -> renderer).cast(); + } + + /** + * Sets a renderer for this {@link EntryStack}. This will override the default renderer from the {@link EntryDefinition}. + *

+ * You can transform the renderer on a {@link EntryType} level + * using {@link EntryRendererRegistry#register(EntryType, EntryRendererProvider)}. + * + * @param renderer the new renderer to use + * @return this {@link EntryStack} + * @see EntryStack#getRenderer() for how the tooltip is resolved + */ + @SuppressWarnings("rawtypes") + @Environment(EnvType.CLIENT) + default EntryStack withRenderer(Function, EntryRenderer> renderer) { + return setting(Settings.RENDERER, (Function) renderer).cast(); + } + /** * Returns the cheated stack of this {@link EntryStack}. * @@ -512,6 +563,12 @@ public interface EntryStack extends TextRepresentable, Renderer { */ EntryStack cheatsAs(); + /** + * Settings for {@link EntryStack}s. + * Please consider using the utility methods in {@link EntryStack} instead of using this class directly. + * + * @param the type of the setting + */ @Deprecated class Settings { @ApiStatus.Internal @@ -543,8 +600,8 @@ public interface EntryStack extends TextRepresentable, Renderer { }); } - private R defaultValue; - private short id; + private final R defaultValue; + private final short id; @ApiStatus.Internal public Settings(R defaultValue) { -- cgit From 89d25568036a31f58fa40e3209a1b9dd05277c65 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 25 Dec 2022 18:59:49 +0800 Subject: Fix #1281 --- .../java/me/shedaniel/rei/api/client/config/ConfigObject.java | 10 ++++++++++ .../rei/api/client/favorites/CompoundFavoriteRenderer.java | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'api') 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 94e119eae..818bea9d5 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 @@ -119,8 +119,18 @@ public interface ConfigObject { * * @return whether favorites motions are animated */ + @Deprecated(forRemoval = true) boolean isFavoritesAnimated(); + /** + * Returns whether motions are reduced. + * + * @return whether motions are reduced + * @since 8.4 + */ + @ApiStatus.Experimental + boolean isReducedMotion(); + /** * Returns whether a toast is shown on screen when a display identifier is copied. * diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java index 4c25a2e94..c7bddf768 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java @@ -29,6 +29,7 @@ import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.animator.NumberAnimator; import me.shedaniel.clothconfig2.api.animator.ValueAnimator; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.AbstractRenderer; import me.shedaniel.rei.api.client.gui.Renderer; import net.fabricmc.api.EnvType; @@ -115,10 +116,10 @@ public class CompoundFavoriteRenderer extends AbstractRenderer { } if (Util.getMillis() - nextSwitch > 1000) { nextSwitch = Util.getMillis(); - offset.setTo((offset.target().intValue() + 1) % count, 500); + offset.setTo((offset.target().intValue() + 1) % count, ConfigObject.getInstance().isReducedMotion() ? 0 : 500); } } else { - offset.setTo(supplier.getAsInt() % count, 500); + offset.setTo(supplier.getAsInt() % count, ConfigObject.getInstance().isReducedMotion() ? 0 : 500); } } } -- cgit From 85c80ea653ec84a892f77d1e80d5bc9a42f4c1e3 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 25 Dec 2022 19:00:07 +0800 Subject: Add @since to javadocs to indicate REI 8.4 --- .../shedaniel/rei/api/client/registry/display/DisplayRegistry.java | 7 +++++++ .../java/me/shedaniel/rei/api/common/entry/EntryIngredient.java | 3 +++ .../main/java/me/shedaniel/rei/api/common/entry/EntryStack.java | 3 +++ .../rei/api/common/entry/settings/EntryIngredientSetting.java | 7 +++++++ 4 files changed, 20 insertions(+) (limited to 'api') 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 b708a2e31..1a93920c6 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 @@ -233,6 +233,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental default , D extends Display> void registerRecipesFiller(Class typeClass, RecipeType recipeType, Function> filler) { @@ -264,6 +265,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Function> filler) { @@ -295,6 +297,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Predicate predicate, Function> filler) { @@ -326,6 +329,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental default void registerDisplaysFiller(Class typeClass, Function> filler) { @@ -357,6 +361,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental void registerDisplaysFiller(Class typeClass, Predicate predicate, Function> filler); @@ -387,6 +392,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param filler the filler, taking a {@code T} and returning a {@code D} * @param the type of object * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental void registerDisplaysFiller(Class typeClass, BiPredicate predicate, Function> filler); @@ -412,6 +418,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * @param predicate the predicate of the object * @param filler the filler, taking an object and returning a {@code D} * @param the type of display + * @since 8.4 */ @ApiStatus.Experimental void registerDisplaysFiller(Predicate predicate, Function> filler); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java index f21719676..b44eb7bb1 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java @@ -209,6 +209,7 @@ public interface EntryIngredient extends List> { * @param setting the setting to get * @param the type of the setting * @return the value of the setting + * @since 8.4 */ @Nullable @ApiStatus.Experimental @@ -224,6 +225,7 @@ public interface EntryIngredient extends List> { * @param value the value of the setting to apply * @param the type of the setting * @return this {@link EntryStack} + * @since 8.4 */ @ApiStatus.Experimental EntryIngredient setting(EntryIngredientSetting setting, T value); @@ -240,6 +242,7 @@ public interface EntryIngredient extends List> { * For that reason, all ingredients passed to this method must have the same size. * * @param ingredients the ingredients to unify + * @since 8.4 */ @ApiStatus.Experimental static void unifyFocuses(EntryIngredient... ingredients) { 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 4b79fce3f..878e083ba 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 @@ -516,6 +516,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * @param tooltipProcessor the processor to modify the tooltips * @return this {@link EntryStack} * @see EntryStack#getTooltip(TooltipContext, boolean) for how the tooltip is resolved + * @since 8.4 */ @SuppressWarnings("rawtypes") @Environment(EnvType.CLIENT) @@ -533,6 +534,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * @return this {@link EntryStack} * @see EntryStack#getRenderer() for how the tooltip is resolved * @see EntryRenderer#empty() for an empty renderer + * @since 8.4 */ @Environment(EnvType.CLIENT) default EntryStack withRenderer(EntryRenderer renderer) { @@ -548,6 +550,7 @@ public interface EntryStack extends TextRepresentable, Renderer { * @param renderer the new renderer to use * @return this {@link EntryStack} * @see EntryStack#getRenderer() for how the tooltip is resolved + * @since 8.4 */ @SuppressWarnings("rawtypes") @Environment(EnvType.CLIENT) diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java index 88766ff5d..78f61f446 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java @@ -23,10 +23,17 @@ package me.shedaniel.rei.api.common.entry.settings; +import me.shedaniel.rei.api.common.entry.EntryIngredient; import org.jetbrains.annotations.ApiStatus; import java.util.UUID; +/** + * Represents a setting for an {@link EntryIngredient}. + * + * @param the type of the setting + * @since 8.4 + */ @ApiStatus.Experimental public interface EntryIngredientSetting { EntryIngredientSetting FOCUS_UUID = new EntryIngredientSetting<>() {}; -- cgit From 45bffbf6342f77da096f12f967db6b4553e34d0f Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 25 Dec 2022 19:08:48 +0800 Subject: Fix Widgets.createTooltip tooltip position --- api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java | 1 + 1 file changed, 1 insertion(+) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 54170fbb6..954a83b8a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -96,6 +96,7 @@ public final class Widgets { Point mouse = new Point(mouseX, mouseY); Tooltip tooltip = tooltipSupplier.apply(mouse); if (tooltip != null) { + tooltip = Tooltip.from(TooltipContext.ofMouse().getPoint(), tooltip.entries()); tooltip.queue(); } }); -- cgit From 1381bd6d9babec1b701b2e74918c5f885e51b709 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 18 Feb 2023 21:01:31 +0800 Subject: Close #669 --- .../main/java/me/shedaniel/rei/api/client/config/ConfigObject.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'api') 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 818bea9d5..5eccfc03a 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 @@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Map; +import java.util.Set; @Environment(EnvType.CLIENT) public interface ConfigObject { @@ -334,6 +335,12 @@ public interface ConfigObject { @ApiStatus.Experimental Map, Boolean> getFilteringQuickCraftCategories(); + @ApiStatus.Experimental + Set> getHiddenCategories(); + + @ApiStatus.Experimental + List> getCategoryOrdering(); + @ApiStatus.Experimental boolean shouldAsyncSearch(); -- cgit From eb2b1d1ecc00ba435e97b5d89879ebe379fd7390 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 18 Feb 2023 21:01:50 +0800 Subject: Remove isJEICompatibilityLayerEnabled in ConfigObject --- .../java/me/shedaniel/rei/api/client/config/ConfigObject.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'api') 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 5eccfc03a..87d242ad3 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 @@ -392,5 +392,14 @@ public interface ConfigObject { SearchMode getModSearchMode(); - boolean isJEICompatibilityLayerEnabled(); + /** + * Returns whether the JEI compatibility layer is enabled. + * + * @return whether the JEI compatibility layer is enabled + * @deprecated the JEI compatibility layer is not bundled with REI anymore + */ + @Deprecated(forRemoval = true) + default boolean isJEICompatibilityLayerEnabled() { + return false; + } } -- cgit From ab7a2bb72b9ee9591049d4ec3c8815d57986bd2c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 19 Feb 2023 02:05:30 +0800 Subject: Mini Displays Favorites --- .../me/shedaniel/rei/api/client/entry/region/RegionEntry.java | 10 ++++++++++ .../me/shedaniel/rei/api/client/favorites/FavoriteEntry.java | 7 +++++++ .../shedaniel/rei/api/client/favorites/FavoriteEntryType.java | 6 ++++++ .../rei/api/common/entry/settings/EntryIngredientSetting.java | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/region/RegionEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/region/RegionEntry.java index cf88e5263..d6ed83471 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/entry/region/RegionEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/region/RegionEntry.java @@ -25,7 +25,11 @@ package me.shedaniel.rei.api.client.entry.region; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry; +import me.shedaniel.rei.api.client.gui.drag.component.DraggableComponent; +import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.common.entry.EntryStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.Optional; @@ -55,4 +59,10 @@ public interface RegionEntry> { default boolean doAction(int button) { return false; } + + @Nullable + @ApiStatus.Experimental + default DraggableComponent asDraggableComponent(Slot slot) { + return null; + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java index 2c5293ba5..42a884d0d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java @@ -28,12 +28,14 @@ import com.mojang.serialization.Lifecycle; import me.shedaniel.rei.api.client.entry.region.RegionEntry; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.util.ClientEntryStacks; +import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.impl.ClientInternals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -73,6 +75,11 @@ public abstract class FavoriteEntry implements RegionEntry { return delegateResult(() -> FavoriteEntryType.registry().get(FavoriteEntryType.ENTRY_STACK).fromArgs(stack), null); } + @ApiStatus.Experimental + public static FavoriteEntry fromDisplay(Display display) { + return delegateResult(() -> FavoriteEntryType.registry().get(FavoriteEntryType.DISPLAY).fromArgs(display), null); + } + @Override public boolean isEntryInvalid() { return isInvalid(); 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 40e1bcf43..62236f22c 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 @@ -25,6 +25,7 @@ package me.shedaniel.rei.api.client.favorites; import com.mojang.serialization.DataResult; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; @@ -44,6 +45,11 @@ public interface FavoriteEntryType { * A builtin type of favorites, wrapping a {@link EntryStack}. */ ResourceLocation ENTRY_STACK = new ResourceLocation("roughlyenoughitems", "entry_stack"); + /** + * A builtin type of favorites, wrapping a {@link Display}. + */ + @ApiStatus.Experimental + ResourceLocation DISPLAY = new ResourceLocation("roughlyenoughitems", "display"); static Registry registry() { return PluginManager.getClientInstance().get(FavoriteEntryType.Registry.class); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java index 78f61f446..0a9666ca2 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/settings/EntryIngredientSetting.java @@ -1,6 +1,6 @@ /* * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 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 -- cgit From 5fcf2698503b1eecae6b8f5abf79afbb11bc6f6e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 7 Jun 2023 02:17:16 +0800 Subject: Initial Work on Config UI Rework --- .../main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java | 5 +++++ api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java | 2 ++ 2 files changed, 7 insertions(+) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 954a83b8a..44e18b32e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -313,6 +313,11 @@ public final class Widgets { return ClientInternals.getWidgetsProvider().wrapOverflow(bounds, widget); } + @ApiStatus.Experimental + public static WidgetWithBounds scissored(Rectangle bounds, Widget widget) { + return ClientInternals.getWidgetsProvider().wrapScissored(bounds, widget); + } + @ApiStatus.Experimental public static WidgetWithBounds padded(int padding, WidgetWithBounds widget) { return padded(padding, padding, padding, padding, widget); 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 e7e165b97..7fc29b400 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -232,6 +232,8 @@ public final class ClientInternals { WidgetWithBounds wrapOverflow(Rectangle bounds, WidgetWithBounds widget); + WidgetWithBounds wrapScissored(Rectangle bounds, Widget widget); + WidgetWithBounds wrapPadded(int padLeft, int padRight, int padTop, int padBottom, WidgetWithBounds widget); } -- cgit From 5aaae0c437971008678afb44474f0d43bdad9783 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 3 Jul 2023 18:30:58 +0800 Subject: Improve Widgets creation --- .../api/client/gui/widgets/WidgetWithBounds.java | 31 ++++++++++++++++++++ .../rei/api/client/gui/widgets/Widgets.java | 33 ++++++++++++++++++---- .../me/shedaniel/rei/impl/ClientInternals.java | 4 +++ 3 files changed, 63 insertions(+), 5 deletions(-) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java index f1860280a..d157a6d3c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/WidgetWithBounds.java @@ -25,6 +25,7 @@ package me.shedaniel.rei.api.client.gui.widgets; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Rectangle; +import org.jetbrains.annotations.ApiStatus; public abstract class WidgetWithBounds extends Widget { public abstract Rectangle getBounds(); @@ -42,4 +43,34 @@ public abstract class WidgetWithBounds extends Widget { render(matrices, mouseX, mouseY, delta); getBounds().setBounds(clone); } + + @ApiStatus.Experimental + public final WidgetWithBounds withPadding(int padding) { + return Widgets.padded(padding, this); + } + + @ApiStatus.Experimental + public final WidgetWithBounds withPadding(int padX, int padY) { + return Widgets.padded(padX, padY, this); + } + + @ApiStatus.Experimental + public final WidgetWithBounds withPaddingHorizontal(int padX) { + return Widgets.padded(padX, 0, this); + } + + @ApiStatus.Experimental + public final WidgetWithBounds withPaddingVertical(int padY) { + return Widgets.padded(0, padY, this); + } + + @ApiStatus.Experimental + public final WidgetWithBounds withPadding(int padLeft, int padRight, int padTop, int padBottom) { + return Widgets.padded(padLeft, padRight, padTop, padBottom, this); + } + + @ApiStatus.Experimental + public final WidgetWithBounds withScissors() { + return Widgets.scissored(this); + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 44e18b32e..1de228f80 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -52,7 +52,8 @@ import java.util.function.Supplier; @Environment(EnvType.CLIENT) public final class Widgets { - private Widgets() {} + private Widgets() { + } public static Widget createDrawableWidget(DrawableConsumer drawable) { return ClientInternals.getWidgetsProvider().createDrawableWidget(drawable); @@ -63,10 +64,11 @@ public final class Widgets { } public static WidgetWithBounds withTooltip(WidgetWithBounds widget, Collection texts) { - return withBounds(concat( + return concatWithBounds( + widget::getBounds, widget, createTooltip(widget::getBounds, texts) - ), widget::getBounds); + ); } public static Widget createTooltip(Rectangle bounds, Component... texts) { @@ -161,11 +163,11 @@ public final class Widgets { } public static WidgetWithBounds withBounds(Widget widget) { - return wrapWidgetWithBounds(widget, null); + return withBounds(widget, (Rectangle) null); } public static WidgetWithBounds withBounds(Widget widget, Rectangle bounds) { - return wrapWidgetWithBoundsSupplier(widget, bounds == null ? null : () -> bounds); + return withBounds(widget, bounds == null ? null : () -> bounds); } public static WidgetWithBounds withBounds(Widget widget, Supplier bounds) { @@ -304,6 +306,22 @@ public final class Widgets { return ClientInternals.getWidgetsProvider().concatWidgets(widgets); } + public static WidgetWithBounds concatWithBounds(Rectangle bounds, Widget... widgets) { + return concatWithBounds(bounds, Arrays.asList(widgets)); + } + + public static WidgetWithBounds concatWithBounds(Rectangle bounds, List widgets) { + return ClientInternals.getWidgetsProvider().concatWidgetsWithBounds(() -> bounds, widgets); + } + + public static WidgetWithBounds concatWithBounds(Supplier bounds, Widget... widgets) { + return concatWithBounds(bounds, Arrays.asList(widgets)); + } + + public static WidgetWithBounds concatWithBounds(Supplier bounds, List widgets) { + return ClientInternals.getWidgetsProvider().concatWidgetsWithBounds(bounds, widgets); + } + public static WidgetWithBounds noOp() { return ClientInternals.getWidgetsProvider().noOp(); } @@ -318,6 +336,11 @@ public final class Widgets { return ClientInternals.getWidgetsProvider().wrapScissored(bounds, widget); } + @ApiStatus.Experimental + public static WidgetWithBounds scissored(WidgetWithBounds widget) { + return ClientInternals.getWidgetsProvider().wrapScissored(widget); + } + @ApiStatus.Experimental public static WidgetWithBounds padded(int padding, WidgetWithBounds widget) { return padded(padding, padding, padding, padding, widget); 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 7fc29b400..af177e30a 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java @@ -228,12 +228,16 @@ public final class ClientInternals { Widget concatWidgets(List widgets); + WidgetWithBounds concatWidgetsWithBounds(Supplier bounds, List widgets); + WidgetWithBounds noOp(); WidgetWithBounds wrapOverflow(Rectangle bounds, WidgetWithBounds widget); WidgetWithBounds wrapScissored(Rectangle bounds, Widget widget); + WidgetWithBounds wrapScissored(WidgetWithBounds widget); + WidgetWithBounds wrapPadded(int padLeft, int padRight, int padTop, int padBottom, WidgetWithBounds widget); } -- cgit From 51d84c0f80e6a459b933add343fc07e9e36a8a7f Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 26 Sep 2023 05:13:24 +0800 Subject: Add the options --- .../me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java index 9218f6d6e..cdbba8b7f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java @@ -35,6 +35,6 @@ public enum FavoriteAddWidgetMode { @Override public String toString() { - return I18n.get("config.roughlyenoughitems.layout.favoriteAddWidgetMode." + name().toLowerCase(Locale.ROOT)); + return I18n.get("config.rei.value.favorites.new_favorites_button_visibility." + name().toLowerCase(Locale.ROOT)); } } -- cgit From ea618dbde55b640576c364086bb789bd06563974 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 22 Oct 2023 23:15:56 +0800 Subject: Add selector --- .../java/me/shedaniel/rei/api/client/gui/config/CheatingMode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/CheatingMode.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/CheatingMode.java index 39b230b93..5e9a98261 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/CheatingMode.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/CheatingMode.java @@ -35,9 +35,9 @@ public enum CheatingMode { public String toString() { switch (this) { case ON: - return I18n.get("text.cloth-config.boolean.value.true"); + return I18n.get("config.rei.value.enabledDisabled.true"); case OFF: - return I18n.get("text.cloth-config.boolean.value.false"); + return I18n.get("config.rei.va