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

Crashing when paired with Oversaturation #124

Open
truenachtara opened this issue Jun 12, 2018 · 8 comments
Open

Crashing when paired with Oversaturation #124

truenachtara opened this issue Jun 12, 2018 · 8 comments

Comments

@truenachtara
Copy link

I'm the Oversaturation dev. I'm modifying FoodStats, which is causing some players who use both this mod and my mod to crash when they eat food. However, in the dev environment, I'm experiencing a full-on crash when I load the world. Do you have any information on stopping this?

Here's my mod: https://github.com/truenachtara/Oversaturation
My dev environment crash: https://pastebin.com/Sw9XdLaC
An issue report detailing a player experiencing this issue in-game (contains crash report): Cazsius/Spice-of-Life-Carrot-Edition#32

@squeek502
Copy link
Owner

Overloading FoodStats will not be compatible with AppleCore (and with any other mods that overload FoodStats). Instead, when you detect AppleCore is installed, you should use AppleCore's events to modify the saturation like so:

@SubscribeEvent
public void getFoodValues(FoodEvent.GetPlayerFoodValues event)
{
	int maxHunger = AppleCoreAPI.accessor.getMaxHunger(event.player);
	int curHunger = event.player.getFoodStats().getFoodLevel();
	int extraSaturation = event.foodStats.hunger - (maxHunger - curHunger);
	if (extraSaturation > 0) {
		int newHunger = maxHunger - curHunger;
		float newSaturationModifier = event.foodValues.saturationModifier + extraSaturation;
		event.foodValues = new FoodValues(newHunger, newSaturationModifier);
	}
}

Note: the above should be in its own class that is only loaded when "applecore" is loaded.

See here for how to include the AppleCore API in your dev environment.

@squeek502
Copy link
Owner

Actually, I missed that your mod removes the maxSaturation == currentHunger limitation, so instead you'll need to use the method outlined here: TheRandomLabs/RandomTweaks#18

@Darkmega18

This comment has been minimized.

@squeek502

This comment has been minimized.

@Darkmega18

This comment has been minimized.

@squeek502

This comment has been minimized.

@Darkmega18

This comment has been minimized.

@squeek502

This comment has been minimized.

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

No branches or pull requests

3 participants