make a small fix to fortitude

This commit is contained in:
2026-07-22 14:34:51 +02:00
parent ae339b9fff
commit 45c38d4245
2 changed files with 9 additions and 2 deletions
@@ -31,9 +31,16 @@ public class ServerboundSpendPointPacket {
ServerPlayer player = context.getSender();
if (player == null) return;
player.getCapability(PlayerStatsProvider.PLAYER_STATS).ifPresent(stats -> {
float previousMaxHealth = player.getMaxHealth();
boolean success = stats.spendPoints(attribute);
if (success) {
StatEffects.applyAll(player);
if ("fortitude".equals(attribute)) {
float gainedMaxHealth = player.getMaxHealth() - previousMaxHealth;
if (gainedMaxHealth > 0.0F) {
player.setHealth(Math.min(player.getHealth() + gainedMaxHealth, player.getMaxHealth()));
}
}
CompoundTag data = stats.serializeNBT();
PacketHandler.INSTANCE.send(
PacketDistributor.PLAYER.with(() -> player),
@@ -44,4 +51,4 @@ public class ServerboundSpendPointPacket {
});
context.setPacketHandled(true);
}
}
}