Adding minecraft:cannot_be_attacked does not stop already attacking mobs from attacking
Partner Rank: 3
Verification builds:
1.21.50
Summary:
Adding minecraft:cannot_be_attacked does not stop already attacking mobs from attacking
Impact:
A primary use we have for this component are mobs that "faint" instead of dying like in our Craftee Companion project. Because the mob never really dies, vanilla mobs do not stop targeting and attacking them even though we want the game to consider them dead. We have used workarounds for this in the past, but this component presents a great opportunity for us to achieve this effect officially, if it correctly stopped mobs who were already targeting our custom ones.
Repro Steps:{}
Test World: cannot_be_attacked_report.mcworld![]()
- Import the test world
- Spawn an ldz:test_entity and a husk
- The husk will start attacking the test entity
- Run the event cannot_be_attacked on the test entity
Observed Results:
The husk does not stop attacking the test entity
Expected Results:
The husk should stop attacking the test entity as soon as the minecraft:cannot_be_attacked component is added
Screenshots/Videos attached: Yes/No
Yes here
Regression Builds:
None
Notes: