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

Started by Minecraft_guy881 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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.

Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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.

Joined Jul 2024
Points:

User statistics:

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

I tried this and it just crashes 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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