How do i make my mobs defend villages?

Started by Chemistry101 on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do i make my mobs defend villages?

I want my new mob Inquisitors and hunters only to target animals and hostile mobs.  it would be ideal if they do not target animals that I have in my farms. I also want them to search for villages and hang around them when they find one. Basically they should act like villagers They are made so when they make a kill that they have chanced of spawning villagers and another inquisitor or hunter. 

Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
In the AI and task tab of…
Wed, 04/16/2025 - 07:56

In the AI and task tab of your mob, you add the procedure block "Attack on sight" in the combat section, and you can there set a specific type of mob, say zombies, skeletons, etc. I think there is a monster that includes all of them, but check it out and try different settings. 

Then, back in the triggers section of the mob, there is a "when this entity kills another", you set your procedure to spawn others of itself or a villager or the other custom mob you have.

Basically you set a random between 0 and 1, and then check with an If Do the probability you want, say you want the inquisitor to appear with a 20%, hunter with 40%, and a villager with 60%, you set it up so that if the random is bigger than 0.6, it spawns a villager, if else lower than 0.4 spawns a hunter, if else lower than 0.2 an inquisitor. 

I'm not sure how to make a mob find a village though, I think you would have more luck trying to find out how to make them spawn around a village.

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i am aware of the procedure…
Wed, 04/30/2025 - 08:05

i am aware of the procedure where if the mob kills something it can spawn a similar mob. I seem to be having an issue where they are attacking villager and themselves. I definitely do not want them attacking villagers or themselves. I mainly want them to spawn in their fortress and during the day travel to the lowest point they can get. Then at night they should travel to the highest point they can pathfind too. If they happen to be in a village and it is nighttime or raining they should go in doors. I am assuming that the reason they are attacking each other is because I have them set as monsters and I want them to attack other monsters. I notice if I set them to attack ambient mobs or creatures, they will attack the villagers. it would also be great if they wont attack the sheep, cows, chickens, pigs, horses and goats.