[Feature Request] Checking 'edibility status' of food items
yeelp opened this issue ยท 5 comments
The ItemFood class has a private field alwaysEdible to determine if a food item can be eaten regardless if a player has full hunger or not. Now it's obviously possible to access this field via reflection, but a much more elegant solution in my opinion would be a method in the IAppleCoreAccessor class to do this. I imagine AppleCore could provide an implementation that is much more efficient than reflection.
I find this to be a huge pitfall with the ItemFood class. You can set if a food item is always edible, but not get this property. This seems like a natural addition to the API.
I'll see what I can do. I'm kind of new to the modding scene, but proficient in Java, so I imagine I could do it nicely, given enough time.
As far as I'm aware, the cost of reflection for this sort of thing is pretty minimal, and is mostly just an upfront cost (as long as you store the Field instead of looking it up each time). Could be wrong about that, though, never looked into it too deeply.
Reposting my comment from here for visibility
If the intention is just to provide a field getter for
ItemFood.alwaysEdible
, just using reflection should be fine. Shouldn't need ASM for this.EDIT: Example from AppleSkin: