Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with AppleCore #18

Closed
squeek502 opened this issue Jun 12, 2018 · 4 comments
Closed

Incompatible with AppleCore #18

squeek502 opened this issue Jun 12, 2018 · 4 comments

Comments

@squeek502
Copy link

squeek502 commented Jun 12, 2018

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:

@TheRandomLabs
Copy link
Owner

Alright, I'm using the FoodStatsAddition event now. Are there any problems with the way I've done it?

@squeek502
Copy link
Author

Two potential problems I see:

  1. 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 and RTFoodStats is loaded.
  2. Once moved into its own class, stats.foodSaturationLevel = newStats.getValue(); will no longer work (since foodSaturationLevel is private and FoodStats.setFoodSaturationLevel is client-only). You can use AppleCoreAPI.mutator.setSaturation(stats, newStats.getValue()); to get around that (and stats.setFoodLevel() for hunger).

@TheRandomLabs
Copy link
Owner

TheRandomLabs commented Jun 12, 2018

I don't think #1 will be an issue, but I'll test it anyway.
#2 isn't an issue either since I'm using access transformers.

EDIT: Worked fine with just RandomTweaks installed.

@squeek502
Copy link
Author

Nice work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants