Refactor fluid slot filling/draining logic & better support for IFluidContainerItem#93
Open
Refactor fluid slot filling/draining logic & better support for IFluidContainerItem#93
Conversation
- Renamed method to be more clear - Return null if draining IFluidContainerItem does not result in an empty container
they were the same, except the latter one used unnecessary ItemStack copying also disabled checking IFluidContainerItem in GTUtility method because we are already checking it earlier
added support for IFluidContainerItem like GT Large Cell or Certus Fluid Tank to partially fill the slot when they hold more than the slot can currently accept also considered a situation when you hold a stack of filled containers - if the slot can accept only 0.5 or 1.5 worth of the container amount, it will drain exactly that amount and give back half the container
- instead of returning an original itemStack when fillFluidContainer() returns null, return null respectively
- same as the fillFluid refactoring - also allowed mass-filling or mass-draining when you have several partially-filled containers in one stack, not just completely filled
This was referenced Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This refactor is divided into several commits, with each having a description of what was done there. Though be warned that methods were basically rewritten so there's no point in comparing them with old code line by line
The main reason for this refactor is to support IFluidContainerItem various use cases. Previously, these containers were treated as normal containers and could only be filled or drained by their full capacity. Now, they can be filled/drained in any way imaginable:
Let's look at an example: