Question Disabling Villager Panicking

Antike Biene

New member
Oct 17, 2024
1
0
1
Hello dear PaperMC-Community,

I am trying to stop a villager from panicking (when a hostile mob is nearby).
Code:
Bukkit.getMobGoals().removeGoal((Villager) memberEntity, VanillaGoal.PANIC);
This code did nothing. It is in a method that is executed during an EntitySpawnEvent with a delay of one tick (tried 3 ticks too). I checked if memberEntity isn't right but the variable refers to the entity I target. I also tried doing it via a scheduled task every 5 ticks or so but they still panicked the entire time (not even stopped for a brief second or tick). I guess the line itself has a problem and therefore doesn't work. So I want to know what is my mistake and how can I change the targeted villager to adapt the desired behaviour.

Thank you!
 

electronicboy

Administrator
Staff member
Dec 11, 2021
271
17
53
28
Villagers don't use the older goals system, they use the newer brain system which is not exposed in the API yet