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

Fix nutrients always stuck at 50% in singleplayer #19

Merged

Conversation

Neidmare
Copy link
Contributor

Bug

No matter which combination of foods you eat, in Single Player nutrition always converges at 50%.
This does not happen on a dedicated Server, only in Single Player.

Steps to reproduce

Set any nutrition to below 50%, for example dairy
/nutrition set YourName dairy 0

Then eat something that does not have dairy, for example a blueberry smoothie.
/hunger 1, then eat it.

Open nutritions panel, dairy increased to 1%

Its the same with all other foods/nutrients. It also decreases any nutrients that are above 50 back down to 50.

Version

GTNH 2.6.1
Java 17.0.12+7
Nutrition 0.0.10

Fix

I've dug around the codebase a bit and traced it to this PR #5

The comment at https://github.com/GTNewHorizons/Nutrition/blob/master/src/main/java/ca/wescook/nutrition/events/EventEatFood.java#L20 explains how and when nutrients are supposed to normalize to 50.

The bug is caused by a check that is supposed to distinguish between client and server, but in singleplayer it's never detecting the client. I replaced it with the same check that the other event also uses.

I've tested the change in both singleplayer and multiplayer, and this fixes it.
Also tested that healing axe still normalizes the nutrients.

@Dream-Master Dream-Master requested a review from a team September 28, 2024 15:36
@Dream-Master Dream-Master merged commit 867aaa2 into GTNewHorizons:master Sep 28, 2024
1 check passed
@Kogepan229 Kogepan229 mentioned this pull request Oct 2, 2024
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

Successfully merging this pull request may close these issues.

3 participants