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

Implement variable sized item recipe transfer handler #3872

Open
wants to merge 3 commits into
base: 1.21.x
Choose a base branch
from

Conversation

AlexiyOrlov
Copy link

This PR makes it possible to properly implement item transfer handler for recipes that have inputs with variable item stack size inputs.
For this I added a default method to IRecipeTransferHandler, where a user can return item stack sizes for transferred items.
This method is then passed to BasicRecipeTransferHandlerServer through PacketRecipeTransfer. If the list is empty, transfer behaves as before, otherwise stack sizes are given to net.minecraft.world.inventory.Slot#safeTake, which handles item extraction.
Also I had to replace 3 hash maps with linked hash maps to preserve stack size to slot mapping.
I exposed IRecipeTransferHandlerHelper in the transfer handler registration method to allow getting IStackHelper for use in transfer handler instantiation.
I tested these changes in my mod I'm developing. I have custom recipe type that can have input items with variable size, so I decided to make this PR.

…m amount transfer method; expose stack helper; implement item transfer with variable size input stack
@CLAassistant
Copy link

CLAassistant commented Dec 20, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants