Incompatible with AppleCore
squeek502 opened this issue ยท 4 comments
RandomTweaks overloads FoodStats, which causes an incompatibility with AppleCore (and with any other mod that overloads FoodStats). To fix this, you can overload FoodStats only when AppleCore is not installed, and use AppleCore's events when it is.
Your FoodStats modifications can be replicated by using the FoodEvent.FoodStatsAddition
event like so:
@SubscribeEvent
public void onFoodStatsAddition(FoodEvent.FoodStatsAddition event)
{
event.setCanceled(true);
// your code, but using event.player.getFoodStats() and AppleCoreAPI.mutator.setSaturation
}
Another example can be found here: squeek502/AppleCore#121
Relevant issues/links:
Alright, I'm using the FoodStatsAddition event now. Are there any problems with the way I've done it?
Two potential problems I see:
- AppleCoreEventHandler probably needs to be its own class, not an inner class, as the
import squeek.applecore.api.food.FoodEvent
will likely cause problems when AppleCore is not installed andRTFoodStats
is loaded. - Once moved into its own class,
stats.foodSaturationLevel = newStats.getValue();
will no longer work (sincefoodSaturationLevel
is private andFoodStats.setFoodSaturationLevel
is client-only). You can useAppleCoreAPI.mutator.setSaturation(stats, newStats.getValue());
to get around that (andstats.setFoodLevel()
for hunger).