Posted November 7, 20213 yr 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 Also: PLEASE use SPOILERS for logs!
November 9, 20213 yr 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 November 9, 20213 yr by spiritfilled
November 9, 20213 yr 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}
November 9, 20213 yr 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 November 9, 20213 yr by spiritfilled
November 9, 20213 yr 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 November 9, 20213 yr by OutCraft Misspelling :-) Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can 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.