Skip to content

Take the fluid unit from GTNHLib instead of hardcoding L - #157

Merged
boubou19 merged 2 commits into
masterfrom
fix/fluid-unit-from-gtnhlib
Aug 2, 2026
Merged

Take the fluid unit from GTNHLib instead of hardcoding L#157
boubou19 merged 2 commits into
masterfrom
fix/fluid-unit-from-gtnhlib

Conversation

@Eldrinn-Elantey

@Eldrinn-Elantey Eldrinn-Elantey commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Fluid slots always labelled amounts and capacities as L, ignoring the useForgeFluidMillibuckets option GTNHLib already exposes, so the setting had no effect on any GUI built on ModularUI2.

The unit now falls back to NumberFormatUtil.getFluidUnit() when a widget does not set one explicitly. Calls to fluidUnit() still override it, and UNIT_LITER/UNIT_BUCKET are unchanged.

https://discord.com/channels/181078474394566657/465207956745486336/1456155245708312812

Checklist

  • I have tested this PR in DevEnv
  • I have tested this PR in Fullpack
  • This PR is in compliance with the GTNH AI Policy
  • This PR requires another PR in order to merge

@Eldrinn-Elantey
Eldrinn-Elantey requested a review from a team August 2, 2026 09:56

@brachy84 brachy84 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The baseUnitPrefix also needs to be adjusted. If the unit is millibucket then it should be SIPrefix.Milli

Comment thread src/main/java/com/cleanroommc/modularui/widgets/slot/FluidSlot.java
Comment thread src/main/java/com/cleanroommc/modularui/widgets/slot/FluidSlot.java
@Eldrinn-Elantey

Copy link
Copy Markdown
Author

@brachy84
getUnit() isn't nullable. Only the backing fields are: getBaseUnit() and getBaseUnitSiPrefix() fall back to the config default when nothing was set explicitly, so getUnit() always returns a value. I can annotate the getters with @NotNull if that reads better.

The reason for getUnit() here is that both lines pass the raw fluid.amount, which is in millibuckets. getBaseUnit() drops the prefix, so with the milli prefix the tooltip would read "1,000/4,000,000 B". The capacity line right below already used getUnit() for the same reason, so this just makes the three lines consistent.

Keeping getBaseUnit() and converting the value with getBaseUnitAmount() would render "1/4,000 B" instead. Players read fluid amounts in millibuckets everywhere else, in recipes, in NEI and in machine info, so bucket counts in the tooltip would be the odd one out, and small amounts would collapse into fractions. The exact number is what the tooltip is for, so I'd keep it as is.

@boubou19
boubou19 merged commit f9cfb98 into master Aug 2, 2026
1 check passed
@boubou19
boubou19 deleted the fix/fluid-unit-from-gtnhlib branch August 2, 2026 15:12
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