Just Enough Items (JEI)

Just Enough Items (JEI)

387M Downloads

[Suggestion]: Don't restrict `BasicRecipeTransferHandler` to a single item per slot

XFactHD opened this issue ยท 5 comments

commented

Suggestion

Currently, the implementation of BasicRecipeTransferHandler is limited to transferring a single item per target slot (which is fine for vanilla crafting systems like the crafting table). This however means that any mod adding a custom crafting system where an input slot may require more than a single item has to basically completely duplicate the BasicRecipeTransferHandler even if that implementation would otherwise be perfectly adequate for the recipe.
Therefore my suggestion is to lift that restriction and allow the BasicRecipeTransferHandler to transfer multiple items per slot.

commented

Thanks for the suggestion!
The recipe transfer handler will transfer more than 1 set of items if you set the maxTransfer to true:

* @param maxTransfer if true, transfer as many items as possible. if false, transfer one set

Is this what you are looking for, or can you clarify if you have something else in mind?

commented

What I mean is that "transferring one set", as the referenced comment calls it, means that only a single item per target slot is transferred. Setting maxTransfer to true (i.e. holding shift while pressing the transfer button) looks for the ingredient with the lowest available count in the player's inventory and uses that as the transfer amount for all ingredients instead of 1.

Let's take this recipe as an example and a player inventory containing 2 slopes and 4 slime balls:
grafik

If I transfer it with maxTransfer == false (without holding shift), a single slope and a single slime ball are transferred to the input slots, which is insufficient:
grafik

If I transfer it with maxTransfer == true (holding down shift), two slopes and two slime balls are transferred to the input slots, which means only one slot is sufficiently filled for this recipe:
grafik

If I want to be able to transfer a single set of items (or a multiple thereof with maxTransfer = true) where a set may contain stacks with a size > 1, I am currently forced to completely re-implement the basic transfer handler.

commented

Do you have a correct implementation for this already, where you copied and edited BasicRecipeTransferHandler?
I could implement it but I would not like to duplicate effort, it's a complicated bit of code to edit.
I am open to reviewing a PR for this if you want to contribute one, or if there is no existing solution I can work on it.

commented

Thank you for clarifying, I think I understand the issue you're facing now.

commented

I have only done a rough breakpoint-driven walk through the BasicRecipeTransferHandler but I haven't looked into actually modifying it yet and I won't be able to do so for the next 4 weeks. If you haven't had a chance to look into it by then, I'd be happy to at least try my luck at contributing the necessary changes.