
[Bug/Feature Request]: IRecipeSlotRichTooltipCallback is insufficient for adjusting fluid stack amount displays
KnightMiner opened this issue ยท 7 comments
Other
Overview of Problem
Since some time before 1.12, Tinkers' Construct has displayed fluid amounts in JEI formatted using our fluid units. For example, an ingot is displayed as "1 ingot" instead of "90 mb". This feature both provides parity with our UIs, and greatly improves the user experience as they are not required to do math or lookup other recipes to find the equivalent amount of items to perform a recipe.
To accomplish this, we typically remove the fluid amount display line, then add in our own fluid amount lines using our tooltip handler. This will show units, or show mb when holding shift. It is important that we remove the JEI added mb display as our tooltip handler falls back to mb if no unit matches an amount, making the unit display confusing if both are shown at the same time.
Since JEI 19.8.5, IRecipeSlotTooltipCallback
was deprecated in favor of IRecipeSlotRichTooltipCallback
. However, the latter is insufficient for our needs as it features no (non deprecated) way to remove tooltip lines.
Suggested fixes
One possible fix would be allowing us to continue removing specific lines from the tooltip, though I suspect there is a reason JEI doesn't want that feature to remain.
Another fix would be a method to suppress just the amount from the tooltip. This would additionally be useful beyond our usage in unit display for when catalysts are involved in recipes, such as the fuels we display in some recipes. These catalysts don't need to display an amount as no amount is really relevant.
A third potential fix is adding a fluid unit formatter API on a per fluid basis, something that maps a fluid stack to a component or a list of components for unit display. We can either manually setup our "Hold Shift for mb" function or let JEI handle that and we just supply non-MB display/a boolean stating if we just displayed in MB. One downside to this option is my fluid formatter supports formatting fluids that are not added by my mod, so there may be conflicts between my desire to display them in relevant units and JEI wanting to allow other mods to register them.
Affected Versions
For 1.20 and 1.21, we can continue to use the deprecated API to accomplish what we want. This problem is mainly an issue for the future of JEI whenever the deprecated API is removed.
Ideally, a fix would be implemented as far back as 1.20 though, as that will let us validate that the fix suits our needs.
Screenshots
Below is a picture of the desired behavior in Tinkers' JEI