AppleCore

AppleCore

56M Downloads

Crashing when paired with Oversaturation

truenachtara opened this issue ยท 8 comments

commented

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

commented

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.

commented

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

commented

oh dear. so I must be getting something very similar with maybe pams if I had to guess. Cause I'm getting world load crashes due to overloaded food values also... so time to downdate and just stick with what worked till everyone catches this... :V

commented

atleast they never outright crashed. and I say harvestcraft cause it's the only thing i know that adds foods that give you restoration bigger than a full bar and I don't have oversaturation. what exactly causes this overload thing anyways? cause at first it had noppes in the crash so I thought it was it's scripted items playing up, but even after taking that out it still kept exploding. :V unless perhaps it was... abyssalcraft and it's food plates and other bits? I'm just trying to think what other stuff in my game add food... like actually additions.

commented

@Darkmega18 It's probably not Harvestcraft, judging from its source code. Note also that anything that crashes now would probably have always caused hidden problems (like AppleCore events not firing, etc).

commented

'Overloads' is a programming term, it has nothing to do with anything in-game.

It's hard to know which mod is causing it, but it's much more likely that its an obscure or rarely used mod than a popular one (otherwise it probably would have been reported earlier). If you could paste the exact error you get, that would be helpful (because it will contain the class name of the overwritten FoodStats, which will generally give enough clues to figure out what mod it's coming from).

commented

2018-06-14-3.log.gz

That one has what happens when custom NPCs was in.

2018-06-14-4.log.gz

so next I took it out and loaded the world and it got rid of the custom npcs stuff but still went down.

Good luck, and sorry if you don't like direct upload logs. :V

commented

AppleCore 3.1.2 was bugged and had a startup crash regardless of any other mods. Please use 3.1.3 instead.