Jump to content

How can I make an entity walk in a straight line at the direction in which it's looking?


Ninjaguy169

Recommended Posts

Look at MoveToBlockGoal and rework it.

i.e. Replace findNearestBlock() with your own logic.
 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Sorry for the late reply, was doing stuff.

 

So how exactly would it work? Let's say, I want the entity do play an animation, walk in a straight line, then stop at its tracks when the path in front of it is blocked. 

 

I'm also having some trouble trying to get where the entity is facing and set a straight line for it to walk there.

Link to comment
Share on other sites

Quote

So how exactly would it work? 

We are not going to write your mod for you. This is a support forum not a teaching forum.

 

Quote

Let's say, I want the entity do play an animation, walk in a straight line, then stop at its tracks when the path in front of it is blocked. 

You need to look at that code I suggested above.

It's part of the entity AI code which has builtin entity PathNavigation and MoveControl you can use.

 

Quote

I'm also having some trouble trying to get where the entity is facing and set a straight line for it to walk there.

It depends what you mean by "facing".

There is an entity.getViewVector() that tells you which direction the entity is looking

or there is also the LivingEntity's body rotation, see Panda.afterSneeze() for an example usage of this.

 

You can also do "ray tracing" to see what an entity is looking at, e.g. Entity.pick()

This part of your question has been asked and answered in many posts of this forum, so search is your friend if you want a longer answer to this FAQ.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.