Jump to content

ItemStack-dependent food stats calculation for all implementations of ItemFood


HashtagShell

Recommended Posts

The way foods are handled right now in Minecraft is that whenever the food heal or saturation of an ItemStack are needed, the Item type of the stack is asked which values this ItemStack has. Most current food items in the game extend ItemFood, which has some extra fields (mostly private and final, but ATs can fix that) to store these values and return them in the methods designated for this purpose (e.g. ItemFood#getSaturationModifier(Lnet/minecraft/item/ItemStack;)F).

I want to make these methods return a modified value for all types that extend ItemFood and either leave these methods alone or override them is such a way that uses its super's return value. If it overrides the method and doesn't use the super, then the coder of that type has decided that their food has special behaviour and I respect that.

 

I know of a solution that uses mechanics too hacky for Lex.

 

As such, my question is whether there is a way to achieve this effect in all (or most) queries for the saturation of the ItemStack by standard means supported by Forge?

This does not only include the player eating, which could be easily handled by catching an event, but also more technical usages, such as the culinary generator from ExU, the food-eating flower (which nobody remembers the name of) from Botania, or AppleCore's foodstats display in the tooltip. Specific solutions for these three cases are not what I'm after, something general would be great.

 

I have been only talking about saturation in this example, but take it as what it is (an example). This question extends on all food-ish traits, so saturation, healAmount, and also maxItemUseDuration (which affects the speed of eating in this case, although the culinary generator, the flower and AppleCore will ignore this value).

 

I honestly don't think there is a way to something this general/universal with the infrastructure Forge provides, but we'll see.

Edited by HashtagShell
Fixed that for you -.- ~Lex; Fixed OOC because Lex deleted a part ~Hash
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.