Trying to get my mob to follow the player anywhere, if they have a global value higher then 1

Started by BobEsBeans on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Trying to get my mob to follow the player anywhere, if they have a global value higher then 1
Mon, 11/10/2025 - 06:47 (edited)

Okay so I haven't been able to find anything like this, if there is a forum that explains this please link me to it.

So basically,

  • I want my mob to spawn at the nearest water source if a player kills a villager. (Not important as of now but would still be helpful)
  • Every time the player kills a villager it adds to a global variable. (This is done)
  • I want my mob to be able to load chunks near it and path find to the player no matter how far they are away.
  • Eventually I want them to path find to whatever player has the highest amount of villager kills.

Now what I've tried to do is make an attack condition in the AI and goals section to do this but what ends up happening is my mob just wanders around like he's not aggroed on the player, if I take the condition off he aggros but then he cant find me after I get so far away. I have the follow and tracking ranges at their max.

Any help on any of these would be extremely helpful!

AI and goals: 

https://imgur.com/detfZ8r

Attack Condition:

https://imgur.com/FiVXsad

Behavior:

https://imgur.com/8ljRssX

Attack Condition: 

https://imgur.com/IuVEPUO

Kill Counter: 

https://imgur.com/KQeTIx4

Spawn: 

https://imgur.com/iY9iMGh

Can Spawn: 

https://imgur.com/DmoufCg

Edited by BobEsBeans on Mon, 11/10/2025 - 06:47
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay so now he's peaceful…
Fri, 11/14/2025 - 08:43

Okay so now he's peaceful until attacked, but he wasn't not when the villager count is 1 or more. Found out this was because of the checking for the highest count of villager kills blocks (this https://imgur.com/65TZzos). Did I do this part wrong or was I supposed to do something else with the variable? https://imgur.com/MVUSljD 

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This fixes him not attacking…
Sat, 11/15/2025 - 02:30

This fixes him not attacking for each kill:
That is because it is checking if they have killed 100 villagers, I think you should default it to 1 instead of 100, also change it to be equal or greater( >=) than, instead of only = so if they go over they still get attacked. 

And next you'd need to update that highest kill count when a player goes over it, if they do then replace that highest count, you can do this by creating this procedure 
"on player tick" 
if their amount_souls > highest_souls 
then set highest_souls = amount_souls

Then go back to your "when dexter kills an entity" procedure, and add this inside the first if statement before setting amount_souls= 0
if amount_souls of target entity = highest_souls
set highest_souls = 1 
(this will automatically update from the previous procedure to the highest kills so it wont stay 1 for more than 1 tick.)

Hope this helps.

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry for getting back to…
Sun, 11/16/2025 - 21:45

Sorry for getting back to you so late, yes that made the timer work so than you for that as well as all your help so far! The issue I'm having now is that he doesn't swap targets to whoever has the most kills, is there a different block to swap targets? or did I do something wrong? https://imgur.com/mbdP05q 

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So I assume that would be…
Mon, 11/17/2025 - 03:47

So I assume that would be because of how the highest souls works, I recommend you change it to be a global variable so you don't need to check for what entity it's attached to, but also it might be remembering who it aggroed first, so in the same "dexter kills another entity" procedure just make it set its attack target to "no entity" so it forgets who it is attacking after they are killed, the block should be in the advanced tab. 

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes that is correct, also…
Tue, 11/18/2025 - 23:46

Yes that is correct, also the reason for that error is because you coded that variable before when it was a player variable, but now that it is a world variable, checking for a world variable inside a targeted player wouldn't work, so you'd have to click "Do nothing" and then go and delete the old variable and replace it in those 3 procedures, it should be good when it no longer needs a target entity tag. 
You can use the link below to find how you would like to store the variable, however I think map is the best fit here.
https://mcreator.net/wiki/variables