diff options
| author | shedaniel <daniel@shedaniel.me> | 2024-09-05 02:18:03 +0900 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-09-05 02:18:03 +0900 |
| commit | dcac5f4891046507047c5951c164fb1c1f08da74 (patch) | |
| tree | 33da389988dd919659a6c12ede8d63e8e084e4b2 /api/src/main/java/me | |
| parent | 612dddf0b65be65a70783622c6406a966d935ebc (diff) | |
| parent | 048eccb27ce9907b1028b7acc4f0f98321864750 (diff) | |
| download | RoughlyEnoughItems-dcac5f4891046507047c5951c164fb1c1f08da74.tar.gz RoughlyEnoughItems-dcac5f4891046507047c5951c164fb1c1f08da74.tar.bz2 RoughlyEnoughItems-dcac5f4891046507047c5951c164fb1c1f08da74.zip | |
Merge remote-tracking branch 'origin/15.x-1.20.5' into 16.x-1.21
Diffstat (limited to 'api/src/main/java/me')
3 files changed, 64 insertions, 2 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerMeta.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerMeta.java new file mode 100644 index 000000000..2bdb5616d --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/TransferHandlerMeta.java @@ -0,0 +1,48 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * 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 + * 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.registry.transfer; + +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; + +/** + * A meta interface for {@link TransferHandler}. + */ +@ApiStatus.Experimental +public interface TransferHandlerMeta { + /** + * Returns the available ingredients for the transfer handler. + * This is used in the craftable filter, and the quick transfer tooltip to quickly determine if the handler can handle the recipe. + * <p> + * If this interface is not implemented, REI will assume stacks only from the player's inventory are available. + * + * @param context the context + * @return the available ingredients + */ + default Iterable<ItemStack> getAvailableIngredients(TransferHandler.Context context) { + return List.of(); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java index 659cc933b..17668f8ca 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/transfer/simple/SimpleTransferHandler.java @@ -23,13 +23,16 @@ package me.shedaniel.rei.api.client.registry.transfer.simple; +import com.google.common.collect.Iterables; import it.unimi.dsi.fastutil.ints.IntSet; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; +import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerMeta; 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 me.shedaniel.rei.api.common.entry.InputIngredient; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.transfer.info.stack.SlotAccessor; @@ -43,13 +46,14 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.ApiStatus; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; @ApiStatus.Experimental -public interface SimpleTransferHandler extends TransferHandler { +public interface SimpleTransferHandler extends TransferHandler, TransferHandlerMeta { static <C extends AbstractContainerMenu, D extends Display> SimpleTransferHandler create(Class<? extends C> containerClass, CategoryIdentifier<D> categoryIdentifier, IntRange inputSlots) { @@ -146,6 +150,11 @@ public interface SimpleTransferHandler extends TransferHandler { InputIngredient.withType(entry, VanillaEntryTypes.ITEM)); } + @Override + default Iterable<ItemStack> getAvailableIngredients(Context context) { + return Iterables.transform(Iterables.concat(getInputSlots(context), getInventorySlots(context)), SlotAccessor::getItemStack); + } + /** * Renders the missing ingredients of the transfer. * 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 061d5470d..fb4c6d019 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 @@ -31,6 +31,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.List; public interface Views extends Reloadable<REIClientPlugin> { /** @@ -49,6 +50,10 @@ public interface Views extends Reloadable<REIClientPlugin> { * Returns all craftable items from materials. * * @return the list of craftable entries + * @deprecated This is no longer exposed in the API due to the lack of use cases and how this API is very specific to a type of implementation. */ - Collection<EntryStack<?>> findCraftableEntriesByMaterials(); + @Deprecated(forRemoval = true) + default Collection<EntryStack<?>> findCraftableEntriesByMaterials() { + return List.of(); + } } |
