Jump to content

Recommended Posts

Posted

Hi,

i have a pet that follows the player around and goes to a specific location on right click. I don't want it to teleport so i wrote a custom goal just to move there without teleporting:

entity.getNavigation().moveTo(x, y, z);

But the problem is, that it sometimes gets stuck somewhere, so I want to make custom pathfinding for the pet, but I have no idea where to start

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Posted (edited)

minecraft has good path finding...
but if you want to make one create a Class extending PathNavigation

public class FlappingNavigation extends FlyingPathNavigation {
		public FlappingNavigation(Mob p_01_, Level p_02_) { super(p_01_, p_02_);
... } }


then on add on stats

public void setStartStat() {
        this.navigation = new FlyingPathNavigation(this, this.level);
... }

but i didnt change how it path find, i just adjusted how it detects Y, since it's flying (with gravity)
vanilla path find has a count on when it's stuck, when it is stuck it stops navi... (if that helps)


you could also change the ai by extending
 

static class WanderFloater extends WaterAvoidingRandomStrollGoal {
		public WanderFloater(TyFlyer p_01_, double p_02_) { super(p_01_, p_02_); }

@Nullable
		private Vec3 findPos() {
... } }

u can change how it finds the next position... maybe make it shorter???

sorry if it's already 2 days passed

Edited by spiritfilled
Posted

orrrrr.  u can change Aistep
(maybe change how it walks to preventing getting stuck, like how the spider get stuck for being chunky)

 

public void aiStep() {... dont super .. do your walk/fly/swim}

 

Posted (edited)

you can also change the way probability of walking on certain blocks, 

public BbBird(EntityType<? extends PathfinderMob> p_35267_, Level p_35268_) {
      this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, -1.0F);
...}

 

Edited by spiritfilled
Posted (edited)

Hi @spiritfilled,

i did it by overriding the customServerAIStep in my Entity and applying some changes to the Navigation, like recalculatePath, but thank you for your help :-)

Edited by OutCraft
Misspelling :-)

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

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.