AppleCore

AppleCore

56M Downloads

[1.7] Block based food? (Cakes)

Wuerfel21 opened this issue ยท 4 comments

commented

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!!!

commented

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's ItemFoodProxy (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 a FoodEvent.FoodEaten event on the MinecraftForge.EVENT_BUS).
commented

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.

commented

So well, I gave up on having the Item show the hunger points for the entire Cake, now it works splendid!

commented

Closing, see here for how to go about this in AppleCore 3.1.0 (which I'll be releasing in a bit).