Skip to content

Refactor fluid slot filling/draining logic & better support for IFluidContainerItem#93

Open
danyadev wants to merge 8 commits intomasterfrom
refactor-fluid-slot-filling-logic
Open

Refactor fluid slot filling/draining logic & better support for IFluidContainerItem#93
danyadev wants to merge 8 commits intomasterfrom
refactor-fluid-slot-filling-logic

Conversation

@danyadev
Copy link
Member

@danyadev danyadev commented Feb 4, 2026

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:

  • to fill the slot up to its capacity
  • to fill the container up to its capacity

Let's look at an example:

  • there's a fluid slot that can hold 32,000 L of fluid, currently empty
  • you're holding 10 Large Steel Cells, each filled 5,000 L out of 8,000 L
  • when you try to put these Cells in a fluid slot (using Shift to apply the whole stack), at first it tries to consume whole items: 5,000 * 6 = 30,000 L and returns to you 6 empty Cells. Then it picks one Cell and tries to apply it too: 2,000 L can be filled in and in return it gives you a Cell with 3,000 L

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants