Scaling Health

Scaling Health

23M Downloads

【BUG】"startingHealth" did not work at the first join

blood789 opened this issue · 2 comments

commented

Versions

  • Scaling Health: ScalingHealth-1.18.2-6.3.0+5
  • Silent Lib: silent-lib-1.18.2-6.2.0
  • Forge: 40.1.80
  • Modpack: N/A
  • Optifine Installed: No

Expected Behavior

(Description here)

Actual Behavior

(Description here)

Links/Images

  • (Link or file)
  • (Another link or file, if needed)

Steps to Reproduce the Problem

  1. Set as below:
    {
    "startingHealth" : 6,
    "minHealth" : 6,
    "maxHealth" : 60,
    "setOnDeath": "6",
    "levelsPerHp": 5,
    "hpPerLevel": 1,
    "maxAttackDamage" : 10,
    "regen" : {
    "initialDelay": 20,
    "tickDelay": 5,
    "exhaustion": 0.1,
    "minFood": 10,
    "maxFood": 2147483647,
    "minHealth": 0,
    "maxHealth": 2147483647,
    "proportionalToMaxHealth": false
    }
    }

2.When I first open the game and select a single world, join the world. I have 20 Health. At the datapack, I set "startingHealth" : 6.
3.Do not leave the game, climb up and get some hurt. Health will immediately become 6(3 Heart).
4.Leave the single player game, save the world, but do not close the program of Minecraft. Create a new world, this time, I have 6 health when I join the game.

5.Close the program of Minecraft and reopen. Create a new world, I have 20 health strangely......
6.Leave the single player game, save the world, but do not close the program of Minecraft. Create a new world, this time, I have 6 health when I join the game.

commented

Having the same problem with 1.19.2 version

Scaling Health: ScalingHealth-1.19.2-7.0.0+6
Silent Lib: silent-lib-1.19.2-7.0.3
Forge: 43.1.47
Modpack: N/A
Optifine Installed: No

player.json
{ "startingHealth" : 50, "minHealth" : 2, "maxHealth" : 200, "setOnDeath": "maxHealth", "levelsPerHp": 10, "hpPerLevel": 1, "maxAttackDamage" : 50, "regen" : { "initialDelay": 0, "tickDelay": 5, "exhaustion": 0.1, "minFood": 2147483646, "maxFood": 2147483647, "minHealth": 2147483646, "maxHealth": 2147483647, "proportionalToMaxHealth": false } }

commented

The problem seems to be that, in singleplayer, the logical server reads settings from the client-side copy SHMechanics::getMechanics(). Starting health (and other player stats) are modified during PlayerLoggedInEvent but the client-side settings are only synchronized later. The settings are stored as static values, so after reloading the world the client-side copy is already updated from the previous run.