Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

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

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}

 

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.