Jump to content

PathNavigate, PathFinders, and More.... ???


Jimmeh

Recommended Posts

Hi!

 

So I've made a custom entity, EntityRock extends EntityMob. I want the rock to follow the player and float in the air while following. I've managed to get it to float in the air (at least, decent enough for now) by copying most of the code a blaze uses.

 

However, I'm having a hard time getting it to follow the player. It just sits in its original position without moving. I've tried making my own follow entity AI behavior copying that of EntityAIFollowOwner, and after testing the methods used, everything is returning true and it seems to be in working state to move.

 

Looking further into EntityMob -> EntityLiving, I see the pathNavigator is being set to a PathNavigateGround, which seemed like an inherent problem if I wanted my entity to "float" and move. But looking at, say, a bat which constantly floats and moves around, it also receives a PathNavigateGround in its constructor. So now I'm just plain confused xD

 

Anyways, after seeing that my floating rock was getting a PathNavigateGround, I decided to make my own PathNavigateFollowAbility, thinking that I could simply extend PathNavigateGround and just override anything that had "isOnGround()".

 

However, that didn't seem to work. It still just sat there without following. So looking further into PathNavigateFollowAbility extends PathNavigateGround, I saw that in the "protected PathFinder getPathFinder()", the PathNavigateFollowAbility's nodeProcessor was being set to a WalkNodeProcessor. Well, that too seemed like a problem.

 

So now I'm trying to make my own AbilityTrackNodeProcessor.

 

And this is where we currently are. I've managed to kind of piece parts together to this point, but now I just have no clue what I'm looking at now. This is like an inception-based movement system that never ends in needing tiny, specific parts xD

 

I figured I'd just outline my thinking before showing code because I'd really just like to understand the process of how NodeProcessor, Path, PathFinder, PathHeap, PathNavigate, PathNodeType and PathPoint work together. This seems rather complicated, perhaps needlessly or perhaps justified. So if anyone can point me to a tutorial, documentation, or be willing to take the time to help me get these concepts understood, I'd really appreciate it!

 

Thanks! :D

Link to comment
Share on other sites

Hi

 

I'd suggest you probably don't need AI for this.  AI is great for complicated behaviours that an Entity might switch between, but probably overkill for a rock which just needs to float to where the player is.  If you want to make it go around obstacles, you could consider 'cheating' by making a record of where the player has been for (say) the last 30 seconds and following that path, if there's something in the way of direct-line-of-sight

 

You could look at EntityShulkerBullet for inspiration.

 

Otherwise, if you're keen to explore AI, I'd suggest you try getting it to follow the owner along the ground like a wolf does, i.e. by using a vanilla AI task.  Once that works, you can modify to follow through the air.  Air should be a lot easier than ground because most of the terrain is not relevant.

 

AI can be tricky to get right.  It will help a lot to add statements that print to the console (or even better a screen overlay) so you can tell what's happening without having to pause the game. 

 

This mod has some good AI examples in it

https://github.com/ata4/dragon-mounts/tree/master/src/main/java/info/ata4/minecraft/dragon/server/entity/ai

 

-TGG

 

 

 

 

Link to comment
Share on other sites

Hi

 

I'd suggest you probably don't need AI for this.  AI is great for complicated behaviours that an Entity might switch between, but probably overkill for a rock which just needs to float to where the player is.  If you want to make it go around obstacles, you could consider 'cheating' by making a record of where the player has been for (say) the last 30 seconds and following that path, if there's something in the way of direct-line-of-sight

 

You could look at EntityShulkerBullet for inspiration.

 

Otherwise, if you're keen to explore AI, I'd suggest you try getting it to follow the owner along the ground like a wolf does, i.e. by using a vanilla AI task.  Once that works, you can modify to follow through the air.  Air should be a lot easier than ground because most of the terrain is not relevant.

 

AI can be tricky to get right.  It will help a lot to add statements that print to the console (or even better a screen overlay) so you can tell what's happening without having to pause the game. 

 

This mod has some good AI examples in it

https://github.com/ata4/dragon-mounts/tree/master/src/main/java/info/ata4/minecraft/dragon/server/entity/ai

 

-TGG

 

I appreciate it! Something simple like this wouldn't really require anything too custom, but this is just a learning experience. I figured it'd be a good way to get introduced to how AI works.

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.