Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to filter item insertion to item handlers retrieved via API? #238

Closed
desht opened this issue Apr 28, 2022 · 3 comments
Closed
Assignees
Labels
type: enhancement New feature or request

Comments

@desht
Copy link

desht commented Apr 28, 2022

Hi, I'm looking to write some mod integration between my mods (PneumaticCraft and Modular Routers), and I'm using the Curios API to retrieve the player's Curios item handlers for automated insertion/extraction. However, I notice that these item handlers don't do any kind item filtering on what may be inserted, unlike when you attempt to insert items via GUI slots.

Am I missing something here, or this is an oversight in the mod?

For reference, my current approach is to build an item handler like this, using the Forge CombinedInvWrapper on all Curios item handlers for the given player:

public static IItemHandler makeCombinedInvWrapper(@Nonnull Player player) {
        return CuriosApi.getCuriosHelper().getCuriosHandler(player)
                .map(handler -> new CombinedInvWrapper(handler.getCurios().values().stream()
                        .map(ICurioStacksHandler::getStacks)
                        .toArray(IItemHandlerModifiable[]::new))
                ).orElse(new CombinedInvWrapper());
}

This item handler seems happy to allow insertion of any item into the player's Curios slots, regardless of whether they can be inserted via inventory GUI.

@TheIllusiveC4
Copy link
Owner

Hmm, at a quick glance, probably an oversight in the mod. I don't think anyone has tried to use Curios in this way before, at least none that has been brought up to me before. The problem is likely because Curios does validity checks outside of the item handlers themselves because it only expects to be interacted with directly through the container or the capability. I'll look into the best way to accommodate for your use-case.

@Kurtoid
Copy link

Kurtoid commented Jul 2, 2023

Encountering the same issue here while trying to add Curios functionality to Advanced Peripheral's Inventory Manager

@TheIllusiveC4
Copy link
Owner

TheIllusiveC4 commented Sep 5, 2023

Sorry for the long delay on this.

I've just released Curios 5.3.0 for 1.20.1, which addresses this issue by consolidating all of the validation checks into the item handlers. Interacting with the item handlers directly, such as the example in the OP, should work correctly without any other changes or checks needed. Please let me know if there any other further issues or if the issue persists, and if there are any other questions or concerns about how to interact with the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants