[1.7] Block based food? (Cakes)
Wuerfel21 opened this issue ยท 4 comments
There is no example for making modded cakes compatible with AppleCore! How is one supposed to do it?
EDIT: Also, please note that the Item is NOT instanceof ItemBlock!!!
Good question, doesn't look like there's any support for this at the moment. Here are the things that you'll need to do once I add better support for block-based foods:
- The block's Item will need to implement
IEdible
- When your block is eaten, you'll need to either:
- Call
FoodStats.func_151686_a(ItemFood, ItemStack)
using AppleCore'sItemFoodProxy
(see Non-standard food integration for a similar example) - Fire the appropriate events before and after eating your food (
AppleCoreAPI.accessor.getFoodValuesForPlayer(itemStack, player)
before, use the returned FoodValues when calling FoodStats.addStats(int, float), and then fire aFoodEvent.FoodEaten
event on theMinecraftForge.EVENT_BUS
).
- Call
Well, the problem here is that the Item has the hunger value of the entire cake, whereas eating a slice only gives you 1/6th... Using the damage value to create a "fake" itemstack that only has 1/6th of the hunger seems to work, but it is considered a different food by SpiceOfLife. Also the name sometimes doesnt show in the food journal. Now trying the event stuff.
So well, I gave up on having the Item show the hunger points for the entire Cake, now it works splendid!
Closing, see here for how to go about this in AppleCore 3.1.0 (which I'll be releasing in a bit).