emilyploszaj / emi

A featureful and accessible item and recipe viewer
MIT License
242 stars 45 forks source link

Expose a way to modify the displayed amount for custom EmiStacks #482

Open pupnewfster opened 6 months ago

pupnewfster commented 6 months ago

For my custom EmiStack I can easily enough change what component I create for getTooltip to display it with a suffix (mB in this case) rather than just calling EmiTooltipComponents#getAmount, but I don't believe there currently is a way to make the recipe tree render the prefix when listing the quantities for the stacks.

Version: 1.1.1+1.20.4

emilyploszaj commented 6 months ago

I thought the day would never come where I'd have to clean this up. There's some mild complexity here deciding how to expose this. Current implementation doesn't have this as a simple method on EmiIngredient because there are a handful of cases where an amount is obtained without it being the actual amount on a stack (summing ingredients in a recipe tree). Though, I'm not sure if that use case is actually reasonable, or if creating an ingredient with the amount just to get the tooltip is reasonable as well. The way to display amount also could, eventually, have to deal with the complexity of compression (Perhaps 1000000mB should actually be displayed as 1KB, etc).

Ideally, Mekanism should just specify that its volume based stacks are measured like that, reusing the existing Fluid implementation (which does not yet exist), but I'll have to think on it a bit to know what's reasonable to expose from both a tech debt and usability standpoint going forward.

Also, as a side note, technically EMI can display fluids in a handful of ways. Because of its Fabric origins, it has the option to display fluids measured in Liters (where 1mB == 1L) or droplets (where 1mB == 81d) because of fabric's... let's say lack of convention. This is slightly more reasonable on that platform where a bucket is actually 81000 units. Either way, not super critical to this bug, just useful to mention.