The bug
Cats won't move either teleport when then they want to sleep or sit in a bed that requires to walk upstairs, open doors or climb up the ladder (or is blocked by blocks). To make them move/follow/teleport you need to move cats while they are sitting or just teleport them using command.
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 10
relates to 1
Attachments
Comments 27
Please check if that's still an issue in the latest 1.16 development snapshot. Currently that is 20w06a.
It does, but when there's a way that cat can climb, it will actually climb or walk it up and go sleep in it. But if you cut off the stairs, the cat still wants the bed and won't tp.
This is still an issue in 1.16.4. Cats seem to prioritize pathfinding to a bed over following or teleporting to the player.
In 1.19.4 I can't right click my cats to make then unsit and follow me. Nothing happens. I can still use a lead but they are sitting and just don't move.
Code Analysis:
MCP Reborn 1.20.2 / net.minecraft.world.entity.animal/Cat
This is likely due to the fact that the 'CatLieOnBedGoal' is placed at position 5 inside of the cat entity's registerGoals(), putting it at a higher priority than most other tasks.
protected void registerGoals() {
this.temptGoal = new Cat.CatTemptGoal(this, 0.6D, TEMPT_INGREDIENT, true);
this.goalSelector.addGoal(1, new FloatGoal(this));
this.goalSelector.addGoal(1, new PanicGoal(this, 1.5D));
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
this.goalSelector.addGoal(3, new Cat.CatRelaxOnOwnerGoal(this));
this.goalSelector.addGoal(4, this.temptGoal);
Issue Start
this.goalSelector.addGoal(5, new CatLieOnBedGoal(this, 1.1D, 8));
Issue End
this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 5.0F, false));
this.goalSelector.addGoal(7, new CatSitOnBlockGoal(this, 0.8D));
this.goalSelector.addGoal(8, new LeapAtTargetGoal(this, 0.3F));
this.goalSelector.addGoal(9, new OcelotAttackGoal(this));
this.goalSelector.addGoal(10, new BreedGoal(this, 0.8D));
this.goalSelector.addGoal(11, new WaterAvoidingRandomStrollGoal(this, 0.8D, 1.0000001E-5F));
this.goalSelector.addGoal(12, new LookAtPlayerGoal(this, Player.class, 10.0F));
this.targetSelector.addGoal(1, new NonTameRandomTargetGoal<>(this, Rabbit.class, false, (Predicate<LivingEntity>)null));
this.targetSelector.addGoal(1, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR));
}
Maybe CatLieOnBedGoal should cancel itself if the pathfinding fails? To me the real "bug" is the cat never reaching the goal and getting mysteriously stuck in corners and such, particularly when the presence of the bed isn't even realized yet. Not so much a cat wanting a catnap, that's typical!
From my somewhat limited and informal testing it does eventually cancel but it takes either a long time or a higher priority goal like SitWhenOrderedToGoal being invoked. Or breaking the bed.
Confirmed in release 1.21.4.
I propose a separate ticket be created for the bug where cats pathfind to the bed on the wrong y-coordinate, despite the bed being easily accessible. I believe the pathfinding priority is a separate issue from the wrong bed coordinates.
I have uploaded 2 clips of the bug in action. One of them shows the cat bringing a morning gift to demonstrate that the gifting behavior also uses the incorrect bed location. I should note that that cat does not stay in this state forever and on occasion will "snap out of it".
I have observed this. Cats get stuck inside or just outside of village houses containing a bed. I eventually put my bed on a two block high tower (so the top is 2.5 blocks above the surrounding blocks) to get them to stop trying to get on it. That is how I was able to confirm that it was bed-related. When the bed was one block above the surrounding blocks (so that the top was 1.5 blocks high) and cats couldn't get on it, they would just be stuck there trying to get on, but after moving it higher the cats would no longer try and could teleport or walk away.