squeek502 / AppleCore

An API for modifying the food and hunger mechanics of Minecraft
The Unlicense
55 stars 24 forks source link

Check Food 'Edibility' #149

Closed yeelp closed 4 years ago

yeelp commented 4 years ago

An important implementation detail that I'm not entirely sure about. Would it be better to throw a RuntimeException when an IllegalAccessException or UnableToFindFieldException are caught? Or would it be better to silently ignore and return false?

EDIT: Forgot to add this closes #148

yeelp commented 4 years ago

The ObfuscationReflectionHelper I used in my project is different than the one used here somehow? Strange, but this can be fixed

squeek502 commented 4 years ago

Thanks! Ended up changing up the reflection implementation and renamed the method to canPlayerEatFood since isFoodEdible seemed like a confusing name because there is already an isEdible.

squeek502 commented 4 years ago

Oh, and just to answer this:

Would it be better to throw a RuntimeException when an IllegalAccessException or UnableToFindFieldException are caught? Or would it be better to silently ignore and return false?

I always prefer hard crashes over silent failures for stuff like this.