Jump to content

Make custom mob move towards (x,y,z)


SirXenophon

Recommended Posts

I want to set certain tasks for my custom mob that involve it moving to fixed coordinate (x,y,z). It's seems that the

 

tryMoveToXYZ(x,y,z,speed)

 

method works fine, but only if the mob is within 16 blocks of (x,y,z). Otherwise, it appears that the vanilla code for something like EntityAIMoveIndoors has the mob move in a random direction towards (x,y,z) a number of times until it is within 16 blocks of (x,y,z), at which point it can finally move directly. This has the unfortunate side effect of the mob following a somewhat random walk (not entirely true since the direction vectors are towards (x,y,z) but still not ideal). I suppose I could change the code in RandomPositionGenerator so that the random direction vector and desired direction vector have dot product not just positive but also large enough to ensure the angle between them is less than pi/6 or so. But this seems rather complicated for what should be a simple task. Any ideas?

Link to comment
Share on other sites

I don't work with entities much myself, but it seems to me that the simplest solution would be to calculate a series of coordinates 16 blocks apart, and have it move from one set of coordinates to the next. although, the standard minecraft method of doing it seems pretty good, because you have to be careful to make sure there are no obstructions

If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.

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.

Announcements



×
×
  • Create New...

Important Information

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