How to force a mob to move to a certain point

Started by jupop777 on

Topic category: Help with modding (Java Edition)

Last seen on 19:13, 24. May 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to force a mob to move to a certain point

I dunno how to put images in here so ill try my best to explain. I need a non-vanilla mob to move from anywhere on the the map to a certain place (for instance, if I was building an rpg type game I need an npc to move to a certain area without teleporting so that the players could follow it). I also need the mob to be able to move around normally after it reaches this area, so that the npc can run from the evil characters in the rpg. TIA

Last seen on 19:13, 24. May 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
help
Sun, 05/24/2020 - 01:26

help

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you need to modify the…
Sun, 05/24/2020 - 13:10

you need to modify the entity's AI. mcreator can't do what you want with the preset AI options. some coding is required.

Last seen on 19:13, 24. May 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, I have some java…
Mon, 05/25/2020 - 03:19

Ok, I have some java experience, but do you have anything I can start with?

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
your entity has to be a Mob…
Mon, 05/25/2020 - 05:20

your entity has to be a Mob or Creature.

once you've setup everything else with your entity's properties, lock your entity's code.

goto your entity's source code and find an appropriate place to put in this.setHomePosAndDistance passing it your target location BlockPos and radius.

in the place where you entity's AI functions are set, add EntityAIMoveTowardsRestriction AI task in the appropriate priority. the first parameter is "this", the second is the speed.

you're gonna have to mess around where to put those to get it working right. code on brother!