
[Feature]: More flexible food calculation api
khjxiaogu opened this issue ยท 7 comments
What is the new feature or improvement?
Mod authors(like me) would like to provide diet value for their special custom foods, since intergrated method does not suit every situation. Providing a custom api by event or something else would be very convenient.
Can you be more specific? What do you need exactly and why does the current API not meet your needs?
Current API only provide a integrated food group calculation, but I would like to specify each food group value instead of using tags or that itemstack-base api.
Diet was built on the assumption that all of the food groups are treated equally, to keep the calculations simple. Just tag the foods into the right food groups and that's it. I'm not completely sure that introducing this level of granularity is a good idea, but enough people have asked about it that I'm willing to take another look at the concept and reform a conclusion.
An API like Function<ItemStack,Map<DietGroup,Float>> would be enough
Here's a question though: In this scenario, how would you deal with the fact that diet groups can be changed to be anything? You might try to, for example, make it so that the item returns proteins
and fruit
at 0.05
and 0.01
respectively. But what happens if the user's instance doesn't have either of those food groups? How exactly do you attempt to define what values need to belong to each food group when those food groups can be anything or even nonexistent?
Here's a question though: In this scenario, how would you deal with the fact that diet groups can be changed to be anything? You might try to, for example, make it so that the item returns
proteins
andfruit
at0.05
and0.01
respectively. But what happens if the user's instance doesn't have either of those food groups? How exactly do you attempt to define what values need to belong to each food group when those food groups can be anything or even nonexistent?
I don't mean to define hard coded group like proteins
, I just want to define a different calculation method to calculated combind foods like sandwiches. So That wont cause incompatibility. Also, just ignore food groups that not exists could be fine.
What exactly do you mean by different calculation method? Can you give a specific example of a food that you want this to apply to and how that implementation would differ from what's currently available?
I'm just having some trouble picturing what you're asking for. If you want to define each food group value yourself like you stated before, then you implicitly need hard code checks for certain groups. Otherwise, how would you know which calculations to use for which food group? Returning a Map<DietGroup, Float>
means that you have access to instances of DietGroup
and you have assigned values to each of them, which would require hard coded checks to differentiate one group from another. And if your calculations don't care about which food groups are available, then how does it differ from the API as it is now?
how does it differ from the API as it is now?
Just like A sandwich with TWO beef steaks, I would like to make it provide double amount of protein or more, but your method could not achieve this. And I want to add a multiplier for some special foods without having to define hardcoded value in config