TerraFirmaCraft

TerraFirmaCraft

3M Downloads

(1.21) Server only nutrition logic called on client

Closed this issue ยท 0 comments

commented

TFC's nutrition system assumes that the logic is only run on the logical server, not the logical client. The comment at the top of NutritionData.java confirms this, and it makes sense that game logic should only be run on the server. However, several methods in NutritionData are in fact run on the logical client, causing problems such as apparent lost nutrition data and quickly changing health values. These methods are called from various methods in PlayerInfo, such as PlayerInfo#tick, which describes how the method is designed to only be run on the server.

The method NutritionData#calculateNutrition seems to be causing most of the problems when called on the client, I'm assuming by using the client's invalid version of server-only food data to calculate the player's nutrition bars and max health. None of the methods I mentioned should be able to be called on the client, but they all are.

I looked in the NeoForge code and found that FoodData.tick() has a Player as a parameter, but in the MCP version of the 1.21 code it has a ServerPlayer as a parameter. It could be neoforge running server only code where it shouldn't for some reason, but it's probably some other arcane nonsense I don't understand