Skip to content

Fix FluidIngredient::equals#4713

Open
Mqrius wants to merge 1 commit intoGregTechCEu:1.20.1from
Mqrius:fluids-2
Open

Fix FluidIngredient::equals#4713
Mqrius wants to merge 1 commit intoGregTechCEu:1.20.1from
Mqrius:fluids-2

Conversation

@Mqrius
Copy link
Contributor

@Mqrius Mqrius commented Mar 5, 2026

What

FluidIngredient::equals was broken in a way that doesn't usually show because FluidIngredient.values is usually size 1. (The nested loop should be a zip loop)
Additionally, VALUE_COMPARATOR was broken (no meaningful comparison values)

Implementation Details

Sorting is fixed by first sorting by Type (TagValue, FluidValue, other Value), and then inside those groups sort by tag or key.

For other Values, we can't meaningfully sort because Value doesn't implement Comparable. I considered having Value implement Comparable but it would change the public API and might break existing code so I decided not to.

As a consequence, in a very specific case, the equals behavior is too lenient. If you have two FluidIngredients that:

  • are not the same object
  • and have equal NBT
  • and have equal number of values
  • and have equal TagValues and FluidValues
  • and have a Value that's not a TagValue or a FluidValue

Then the code will consider those alternative Values to be always equal even if they are not, because I can't guarantee that these alternative Values are Comparable so I can't compare them.

Outcome

Fix latent bugs in cases where a FluidIngredient consists of multiple ingredients or tags

How Was This Tested

Game compiles and runs

Potential Compatibility Issues

Specifically avoided API changes

@Mqrius Mqrius requested a review from a team as a code owner March 5, 2026 14:47
@github-actions github-actions bot added the 1.20.1 label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant