I have reported this initially in MCPE-167651, where the damage_sensor component had these results, and the recently added beforeEvents.entityHurt has brought it back.
If a player receives lethal damage, but the damage is modified to be nonlethal, the game continues to treat it as a fatal attack, resulting in no invulnerability frames being applied from taking damage.
Steps to reproduce:
Create a script to modify the damage that players take. For this example, I am simply going to make all damage players take equal to 3 damage.
world.beforeEvents.entityHurt.subscribe((data) => { if (data.hurtEntity.typeId == "minecraft:player") {data.damage = 3} }
Open a test world with said script and apply a lethal amount of damage to the player (players only have 20 hit points, so anything 20 and above should be good enough)
Expected Results:
The player should take knockback, should turn red, should emit the hurt sound effect, should have invulnerability frames, and should receive 3 damage.
Results shown:
None of the expected results appear save for the correct amount of applied damage.
Thank you for your report!
However, this issue has been temporarily closed as Awaiting Response.
Could you please attach an example addon showcasing the issue?
This ticket will automatically reopen when you reply.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki