Is there a way to get a mob/entity to walk to another mob/entity/block when an event is triggered?

Started by chewygum on

Topic category: Help with Minecraft modding (Java Edition)

Active 5 months ago
Joined Jan 2018
Points:
756

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
Is there a way to get a mob/entity to walk to another mob/entity/block when an event is triggered?

I need help by making a mob/entity go walk to another mob/entity/block when a player walks or collides on it

I have ZERO coding experience so that won't be any help

Active 1 day ago
Joined May 2022
Points:
1254

User statistics:

  • Modifications: 14
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1142
There's a new 'Attempt to…
Sun, 10/01/2023 - 14:25

There's a new 'Attempt to make entity pathfind to x/y/z' function that should work just fine for this, if you replace x/y/z with the positions of the target entity. However, (speaking from personal experience and several days of messing around with this), the pathfinding isn't always the greatest, and isn't precise down to the block. However, for most purposes, should work fine, it's in the 'entity management' tab at the bottom.

Active 5 months ago
Joined Jan 2018
Points:
756

User statistics:

  • Modifications: 0
  • Forum topics: 11
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
I found the part, but I'm…
Sun, 10/01/2023 - 16:31

I found the part, but I'm not sure how to set it up, could you send a screenshot of how you did it?

Active 1 day ago
Joined May 2022
Points:
1254

User statistics:

  • Modifications: 14
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1142
It's really pretty…
Sun, 10/01/2023 - 16:38

It's really pretty straightforward: you tell the entity the coordinates to go to, and it attempts to go there. In this case, you would set the coordinates to the position of the entity you want it to go to. (You can find 'entity position' in the entity data tab.) It could look something like this:

You'll need to be running this constantly though, (on entity tick), since the target entity will likely be moving.

Active 8 months ago
Joined Jul 2024
Points:
66

User statistics:

  • Modifications: 0
  • Forum topics: 0
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
I tried this and it just…
Wed, 09/25/2024 - 11:07

I tried this and it just crashes 

Active 2 hours ago
Joined Apr 2023
Points:
660

User statistics:

  • Modifications: 4
  • Forum topics: 22
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 540
You forgot the if block that…
Wed, 09/25/2024 - 12:03

You forgot the if block that checks if there is a certain entity type nearby