Skip to content

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

Merged
chrombread merged 12 commits intomasterfrom
refactor-fluid-slot-filling-logic
Feb 14, 2026
Merged

Refactor fluid slot filling/draining logic & better support for IFluidContainerItem#93
chrombread merged 12 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
as I figured out in my latest GT refactoring, they don't have any special fluid handling so we don't lose any profit by using our own implementation only
@danyadev danyadev force-pushed the refactor-fluid-slot-filling-logic branch from 2711c2c to 0484cec Compare February 12, 2026 10:14
Copy link
Member

@chrombread chrombread left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick comment. code looks fine and runs fine

Copy link
Member

@chrombread chrombread left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. seems to work just fine in game.

@chrombread chrombread merged commit 7edca73 into master Feb 14, 2026
1 check passed
@chrombread chrombread deleted the refactor-fluid-slot-filling-logic branch February 14, 2026 00:27
@Dream-Master Dream-Master removed the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Feb 14, 2026
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.

3 participants

Comments