diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-04-06 15:47:20 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-04-06 15:47:20 +0800 |
| commit | 966bbd7fe43237f9b1aa6cfd94cf5e34a9bcfddf (patch) | |
| tree | 7c19b609f1d61f0afde3947742056dbb8b17a396 /api/src/main/java | |
| parent | 5b0c5838978fc74f783c6dcff2983af4fb97d912 (diff) | |
| download | RoughlyEnoughItems-966bbd7fe43237f9b1aa6cfd94cf5e34a9bcfddf.tar.gz RoughlyEnoughItems-966bbd7fe43237f9b1aa6cfd94cf5e34a9bcfddf.tar.bz2 RoughlyEnoughItems-966bbd7fe43237f9b1aa6cfd94cf5e34a9bcfddf.zip | |
Expose draggable stacks
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'api/src/main/java')
27 files changed, 432 insertions, 100 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java b/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java index b585c2642..5ef067f6a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java @@ -33,7 +33,7 @@ public abstract class REIOverlay extends WidgetWithBounds { public abstract void queueReloadOverlay(); - public abstract DraggingContext getDraggingContext(); + public abstract DraggingContext<?> getDraggingContext(); public abstract boolean isNotInExclusionZones(double mouseX, double mouseY); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index c4b2205ae..917a88b75 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.api.client.gui; +import com.google.common.base.Predicates; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; @@ -46,39 +47,42 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHolder { - private static final Comparator<EntryStack<?>> ENTRY_COMPARATOR = Comparator.comparingLong(EntryStacks::hashExact); - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); - private List<Slot> inputWidgets; - private List<Slot> outputWidgets; - private List<GuiEventListener> widgets; + protected static final Comparator<EntryStack<?>> ENTRY_COMPARATOR = Comparator.comparingLong(EntryStacks::hashExact); + protected static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); + protected List<Slot> inputWidgets; + protected List<Slot> outputWidgets; + protected List<GuiEventListener> widgets; @ApiStatus.Internal - private SimpleDisplayRenderer(List<EntryIngredient> input, List<EntryIngredient> output) { - this.inputWidgets = simplify(input).stream().filter(stacks -> !stacks.isEmpty()).map(stacks -> Widgets.createSlot(new Point(0, 0)).entries(stacks).disableBackground().disableHighlight().disableTooltips()).collect(Collectors.toList()); - this.outputWidgets = CollectionUtils.map(simplify(output), outputStacks -> - Widgets.createSlot(new Point(0, 0)).entries(CollectionUtils.filterToList(outputStacks, stack -> !stack.isEmpty())).disableBackground().disableHighlight().disableTooltips()); + protected SimpleDisplayRenderer(List<EntryIngredient> input, List<EntryIngredient> output) { + this.inputWidgets = CollectionUtils.map(simplify(input), this::createSlot); + this.outputWidgets = CollectionUtils.map(simplify(output), this::createSlot); this.widgets = Stream.concat(inputWidgets.stream(), outputWidgets.stream()).collect(Collectors.toList()); } + private Slot createSlot(EntryIngredient ingredient) { + return Widgets.createSlot(new Point(0, 0)) + .entries(CollectionUtils.filterToList(ingredient, stack -> !stack.isEmpty())) + .disableBackground() + .disableHighlight() + .disableTooltips(); + } + private static List<EntryIngredient> simplify(List<EntryIngredient> original) { List<EntryIngredient> out = new ArrayList<>(); for (EntryIngredient ingredient : original) { - if (out.stream().noneMatch(s -> equalsList(ingredient, s))) { - out.add(ingredient); + EntryIngredient filter = ingredient.filter(Predicates.not(EntryStack::isEmpty)); + if (!filter.isEmpty() && out.stream().noneMatch(s -> equalsList(filter, s))) { + out.add(filter); } } return out; } - public static DisplayRenderer from(Supplier<List<EntryIngredient>> input, Supplier<List<EntryIngredient>> output) { - return from(input.get(), output.get()); - } - public static DisplayRenderer from(List<EntryIngredient> input, List<EntryIngredient> output) { return new SimpleDisplayRenderer(input, output); } @@ -148,7 +152,7 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold } public int getItemsHeight() { - return Mth.ceil(((float) inputWidgets.size()) / (getItemsPerLine() - 2)); + return Math.max(Mth.ceil(((float) inputWidgets.size()) / (getItemsPerLine() - 2)), outputWidgets.size()); } public int getItemsPerLine() { diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/DisplayScreenType.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/DisplayScreenType.java index 7500f5375..8e2fcc726 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/DisplayScreenType.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/DisplayScreenType.java @@ -26,11 +26,9 @@ package me.shedaniel.rei.api.client.gui.config; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.resources.language.I18n; -import org.jetbrains.annotations.ApiStatus; import java.util.Locale; -@ApiStatus.Internal @Environment(EnvType.CLIENT) public enum DisplayScreenType { UNSET, diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProvider.java index 4fc3e892c..fe5ccffe2 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProvider.java @@ -23,22 +23,61 @@ package me.shedaniel.rei.api.client.gui.drag; +import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; -@FunctionalInterface -public interface DraggableStackProvider { - static DraggableStackProvider from(Supplier<Iterable<DraggableStackProvider>> providers) { - return (context, mouseX, mouseY) -> { - for (DraggableStackProvider provider : providers.get()) { - DraggableStack stack = provider.getHoveredStack(context, mouseX, mouseY); - if (stack != null) return stack; +/** + * A provider for supplying {@link DraggableStack} to the screen. + */ +public interface DraggableStackProvider<T extends Screen> extends Comparable<DraggableStackProvider<T>> { + static <T extends Screen> DraggableStackProvider<T> from(Supplier<Iterable<DraggableStackProvider<T>>> providers) { + return new DraggableStackProvider<T>() { + @Override + public <R extends Screen> boolean isHandingScreen(R screen) { + for (DraggableStackProvider<T> provider : providers.get()) { + if (provider.isHandingScreen(screen)) { + return true; + } + } + return false; + } + + @Override + @Nullable + public DraggableStack getHoveredStack(DraggingContext<T> context, double mouseX, double mouseY) { + for (DraggableStackProvider<T> provider : providers.get()) { + if (provider.isHandingScreen(context.getScreen())) { + DraggableStack stack = provider.getHoveredStack(context, mouseX, mouseY); + if (stack != null) return stack; + } + } + return null; } - return null; }; } @Nullable - DraggableStack getHoveredStack(DraggingContext context, double mouseX, double mouseY); + DraggableStack getHoveredStack(DraggingContext<T> context, double mouseX, double mouseY); + + <R extends Screen> boolean isHandingScreen(R screen); + + default DraggingContext<T> getContext() { + return DraggingContext.getInstance().cast(); + } + + /** + * Gets the priority of the handler, the higher the priority, the earlier this is called. + * + * @return the priority + */ + default double getPriority() { + return 0f; + } + + @Override + default int compareTo(DraggableStackProvider<T> o) { + return Double.compare(getPriority(), o.getPriority()); + } }
\ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProviderWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProviderWidget.java new file mode 100644 index 000000000..8efb79311 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackProviderWidget.java @@ -0,0 +1,73 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.drag; + +import net.minecraft.client.gui.screens.Screen; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Function; + +/** + * An interface to be implemented on {@link me.shedaniel.rei.api.client.gui.widgets.Widget} to provide + * {@link DraggableStack}. + */ +@FunctionalInterface +public interface DraggableStackProviderWidget { + static DraggableStackProviderWidget from(Function<DraggingContext<Screen>, Iterable<DraggableStackProviderWidget>> providers) { + return (context, mouseX, mouseY) -> { + for (DraggableStackProviderWidget provider : providers.apply(context)) { + DraggableStack stack = provider.getHoveredStack(context, mouseX, mouseY); + if (stack != null) return stack; + } + return null; + }; + } + + @Nullable + DraggableStack getHoveredStack(DraggingContext<Screen> context, double mouseX, double mouseY); + + static DraggableStackProvider<Screen> toProvider(DraggableStackProviderWidget widget) { + return toProvider(widget, 0D); + } + + static DraggableStackProvider<Screen> toProvider(DraggableStackProviderWidget widget, double priority) { + return new DraggableStackProvider<Screen>() { + @Override + @Nullable + public DraggableStack getHoveredStack(DraggingContext<Screen> context, double mouseX, double mouseY) { + return widget.getHoveredStack(context, mouseX, mouseY); + } + + @Override + public <R extends Screen> boolean isHandingScreen(R screen) { + return true; + } + + @Override + public double getPriority() { + return priority; + } + }; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitor.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitor.java index 8ebdf9c57..6959d912a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitor.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitor.java @@ -23,23 +23,63 @@ package me.shedaniel.rei.api.client.gui.drag; +import net.minecraft.client.gui.screens.Screen; + import java.util.Optional; import java.util.function.Supplier; -@FunctionalInterface -public interface DraggableStackVisitor { - static DraggableStackVisitor from(Supplier<Iterable<DraggableStackVisitor>> visitors) { - return (stack) -> { - for (DraggableStackVisitor visitor : visitors.get()) { - Optional<Acceptor> acceptor = visitor.visitDraggedStack(stack); - if (acceptor.isPresent()) return acceptor; +/** + * A visitor for accepting {@link DraggableStack} to the screen. + */ +public interface DraggableStackVisitor<T extends Screen> extends Comparable<DraggableStackVisitor<T>> { + static <T extends Screen> DraggableStackVisitor<T> from(Supplier<Iterable<DraggableStackVisitor<T>>> visitors) { + return new DraggableStackVisitor<T>() { + @Override + public <R extends Screen> boolean isHandingScreen(R screen) { + for (DraggableStackVisitor<T> visitor : visitors.get()) { + if (visitor.isHandingScreen(screen)) { + return true; + } + } + return false; + } + + @Override + public Optional<Acceptor> visitDraggedStack(DraggingContext<T> context, DraggableStack stack) { + for (DraggableStackVisitor<T> visitor : visitors.get()) { + if (visitor.isHandingScreen(context.getScreen())) { + Optional<Acceptor> acceptor = visitor.visitDraggedStack(context, stack); + if (acceptor.isPresent()) return acceptor; + } + } + return Optional.empty(); } - return Optional.empty(); }; } - Optional<Acceptor> visitDraggedStack(DraggableStack stack); + Optional<Acceptor> visitDraggedStack(DraggingContext<T> context, DraggableStack stack); + + <R extends Screen> boolean isHandingScreen(R screen); + + default DraggingContext<T> getContext() { + return DraggingContext.getInstance().cast(); + } + + /** + * Gets the priority of the handler, the higher the priority, the earlier this is called. + * + * @return the priority + */ + default double getPriority() { + return 0.0; + } + + @Override + default int compareTo(DraggableStackVisitor<T> o) { + return Double.compare(getPriority(), o.getPriority()); + } + @FunctionalInterface interface Acceptor { void accept(DraggableStack stack); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitorWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitorWidget.java new file mode 100644 index 000000000..0af21ddc5 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggableStackVisitorWidget.java @@ -0,0 +1,71 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.client.gui.drag; + +import net.minecraft.client.gui.screens.Screen; + +import java.util.Optional; +import java.util.function.Function; + +/** + * An interface to be implemented on {@link me.shedaniel.rei.api.client.gui.widgets.Widget} to accept + * incoming {@link DraggableStack}. + */ +@FunctionalInterface +public interface DraggableStackVisitorWidget { + static DraggableStackVisitorWidget from(Function<DraggingContext<Screen>, Iterable<DraggableStackVisitorWidget>> providers) { + return (context, stack) -> { + for (DraggableStackVisitorWidget visitor : providers.apply(context)) { + Optional<DraggableStackVisitor.Acceptor> acceptor = visitor.visitDraggedStack(context, stack); + if (acceptor.isPresent()) return acceptor; + } + return Optional.empty(); + }; + } + + Optional<DraggableStackVisitor.Acceptor> visitDraggedStack(DraggingContext<Screen> context, DraggableStack stack); + + static DraggableStackVisitor<Screen> toVisitor(DraggableStackVisitorWidget widget) { + return toVisitor(widget, 0.0); + } + + static DraggableStackVisitor<Screen> toVisitor(DraggableStackVisitorWidget widget, double priority) { + return new DraggableStackVisitor<Screen>() { + @Override + public Optional<Acceptor> visitDraggedStack(DraggingContext<Screen> context, DraggableStack stack) { + return widget.visitDraggedStack(context, stack); + } + + @Override + public <R extends Screen> boolean isHandingScreen(R screen) { + return true; + } + + @Override + public double getPriority() { + return priority; + } + }; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggingContext.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggingContext.java index 9ea02d146..628408dce 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggingContext.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/drag/DraggingContext.java @@ -25,6 +25,7 @@ package me.shedaniel.rei.api.client.gui.drag; import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.REIHelper; +import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; @@ -32,18 +33,28 @@ import java.util.function.Supplier; /** * The context of the current dragged stack on the overlay. * <p> - * Widgets should implement {@link DraggableStackProvider} to submit applicable stacks to drag. - * Widgets should implement {@link DraggableStackVisitor} to accept incoming dragged stacks. + * Widgets should implement {@link DraggableStackProviderWidget} to submit applicable stacks to drag. + * Widgets should implement {@link DraggableStackVisitorWidget} to accept incoming dragged stacks. + * <p> + * External providers should use {@link me.shedaniel.rei.api.client.registry.screen.ScreenRegistry#registerDraggableStackProvider(DraggableStackProvider)}, + * and {@link me.shedaniel.rei.api.client.registry.screen.ScreenRegistry#registerDraggableStackVisitor(DraggableStackVisitor)}. */ -public interface DraggingContext { - static DraggingContext getInstance() { +public interface DraggingContext<S extends Screen> { + static DraggingContext<?> getInstance() { return REIHelper.getInstance().getOverlay().get().getDraggingContext(); } + /** + * Returns whether a draggable stack is present. + * + * @return whether a draggable stack is present + */ default boolean isDraggingStack() { return getCurrentStack() != null; } + S getScreen(); + /** * Returns the current dragged stack, may be null. * @@ -70,4 +81,8 @@ public interface DraggingContext { * @param position the position supplier of the destination */ void renderBackToPosition(DraggableStack stack, Point initialPosition, Supplier<Point> position); + + default <T extends Screen> DraggingContext<T> cast() { + return (DraggingContext<T>) this; + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java index f209ac35c..5c9a697c6 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayCategory.java @@ -65,7 +65,7 @@ public interface DisplayCategory<T extends Display> extends Identifiable { */ @ApiStatus.OverrideOnly default DisplayRenderer getDisplayRenderer(T display) { - return SimpleDisplayRenderer.from(display::getInputEntries, display::getOutputEntries); + return SimpleDisplayRenderer.from(display.getInputEntries(), display.getOutputEntries()); } /** 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 fc4ecd094..65bdb9460 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 @@ -23,6 +23,7 @@ package me.shedaniel.rei.api.client.registry.display; +import com.google.common.base.Predicates; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.display.visibility.DisplayVisibilityPredicate; import me.shedaniel.rei.api.common.category.CategoryIdentifier; @@ -31,8 +32,8 @@ 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 org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -54,7 +55,7 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { * * @return the recipe count */ - int getDisplayCount(); + int displaySize(); /** * Registers a recipe display @@ -149,11 +150,41 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { */ List<DisplayVisibilityPredicate> getVisibilityPredicates(); - default <T, D extends Display> void registerFiller(Class<T> typeClass, Function<T, D> mappingFunction) { - registerFiller(typeClass, typeClass::isInstance, mappingFunction); + /** + * 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}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param <T> the type of object + * @param <D> the type of display + */ + default <T, D extends Display> void registerFiller(Class<T> typeClass, Function<T, D> filler) { + registerFiller(typeClass, Predicates.alwaysTrue(), filler); } - <T, D extends Display> void registerFiller(Class<T> typeClass, Predicate<? extends T> predicate, Function<T, D> mappingFunction); + /** + * 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}. + * + * @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 <T> the type of object + * @param <D> the type of display + */ + <T, D extends Display> void registerFiller(Class<T> typeClass, Predicate<? extends T> predicate, Function<T, D> filler); |
