mrsterner / GuardVillagers

Creative Commons Zero v1.0 Universal
12 stars 8 forks source link

Custom Goals from the mod are not added to existing entities #111

Open SuperHeroBaga opened 4 months ago

SuperHeroBaga commented 4 months ago

All the custom goals from the mod (like the cleric that heals, villagers that run away from polar bears, witches that attack villagers, and all the others), are added to their goal selectors only when the entity has been newly spawned (such as with a spawn egg, with the summon command or new chunks loaded with new entities spawned with them). Entities that are loaded upon re-entering a world or re-loading chunks that were originally already explored in the world won't have any of the custom goals, this is a pretty big deal because that means they will be present in only one session! (not even if the players gets far enough from the entities to unload the chunks they are on and then come back just to find out they lost all the additional goals, and yes rejoining the world won't do it).

The issue probably stands to the fact that the method the line of code that deals with adding all the goals to the entities is called only in some cases, one of them not being loading existing or saved in disk entities which are dealt by another method.

To solve the bug changing the method you are injecting that line of code to another more appropriate method or simply putting it there too will certainly do it.

Hope you can fix the issue because I really love your mod!