MinecraftFreecam / Freecam

A highly customizable freecam mod for Minecraft. [Maintiners: @hashalite @MattSturgeon]
https://curseforge.com/minecraft/mc-mods/free-cam
MIT License
75 stars 30 forks source link

Fix disableOnDamage false-positives #70

Closed MattSturgeon closed 1 year ago

MattSturgeon commented 1 year ago

ClientPlayerEntity.damage() is often called even when the player's health isn't actually going to change. For example, fire damage while under the effect of Fire Resistance.

Instead, let's check LivingEntity.setHealth(), since this is where actual changes to the player's health are made.

disableOnDamage will still activate when damaged while health is regenerating on average. But to fix that we'd have to track health over time and only disable when we detect a lasting reduction in health... Not in the scope of this simple PR.

Fixes #63