There was a change in the 1.17 pre releases that removes any hostility between mobs in peaceful difficulty.
Since this wasn't mentioned in the patch notes and as far as I understand it "peaceful" refers to mobs not attacking the player, I think this might be a bug.
I tested the following mob interactions:
cats don't attack chickens or rabbits
wolves don't attack llamas or foxes
polar bears don't attack foxes
snow golems don't attack shulkers
shulkers don't fight back when attacked by a non player mob
axolotls don't attack squid or fish
iron golems don't attack shulkers or hoglins
ocelots don't attack chickens
There are probably more that I don't think of.
Linked issues
Comments


The player can attack and kill animals. The player can die from fall damage, drowning, lava and so on. I do not think Peaceful is about removing everything of that. I think Peaceful is about removing the Monster mobs (hostile mobs). The gameplay itself should not be limited or the ai of the Animals or other mobs changed.
I say this is a bug.
Why remove something as amazing as watching a fox jump high in the air to hunt a chicken.

As a long-time Peaceful player I would certainly not take 'peaceful' as referring to the dictionary definition. It is simply the name of the difficulty setting.
I wouldn't mind a gamerule/mechanic to be able to turn on and off mob hostility, but I am feeling that this is a bug as it does nothing to directly affect the difficulty of the game for the player as far as I can see.

Code analysis (1.17-pre3, yarn name) TL;DR: LivingEntity.canTarget
should target instanceof PlayerEntity
before doing difficulty check.
Take PolarBearEntity
for example. It has a FollowTargetGoal
that targets a FoxEntity
. FollowTargetGoal
can only start if FollowTargetGoal.findClosestTarget
sets non-null targetEntity
. Since targetClass
is not PlayerEntity
, findClosestTarget
calls EntityView.getClosestEntity
to find the closest fox. Note that entity argument is not null in that call, which is important later.
Let's move the stuff to TargetPredicate
. FollowTargetGoal
's targetPredicate
is "attackable". This target predicate is passed to that getClosestEntity
call, which executes the predicate with the base entity (polar bear) and the target entity (fox).
TargetPredicate.test
has many checks depending on conditions, but the bottom one is problematic. If baseEntity
is non-null (which is always the case here), and if the target predicate is attackable, it calls LivingEntity.canTarget
method. If this method returns false, the target predicate fails.
LivingEntity.canTarget
is overloaded, but the one I want to focus is method_18395
(the one that takes a LivingEntity
as an argument). This method is the one that causes this whole bug. It always checks difficulty is not peaceful, even if the target argument is not player. Oops.
Peaceful means no hostility at all and did you tame the wolf and make him go after the Llama and fox?