Tamed mules will show heart particles after being fed, despite the fact that they are not able to breed.
Steps to Reproduce:
- Run this command twice to summon two tamed mules
/summon mule ~ ~ ~ {Tame:1b}
- Feed both mules an item they like
/give @p golden_carrot
Observed Results:
The mules will both display heart particles.
Expected Results:
The mules would not show heart particles, as they are not in love and will not breed.
Screenshots/Videos:
MC-176758 Current Behavior.mp4
Code Analysis / MCP-Reborn 1.20.2
Here in the handleEntityEvent() method of Animal.java, the game first checks to see if the event id is equal to 18 (18 is the "IN_LOVE_HEARTS" event) and if that is true, then the heart particles are displayed around the entity. However, it never checks to see if that entity is capable of breeding.
Class: net\minecraft\world\entity\animal\Animal.java - Method: handleEntityEvent()
public void handleEntityEvent(byte eventId) { if (eventId == 18) { for(int i = 0; i < 7; ++i) { double z1 = this.random.nextGaussian() * 0.02D; double z2 = this.random.nextGaussian() * 0.02D; double z3 = this.random.nextGaussian() * 0.02D; this.level().addParticle(ParticleTypes.HEART, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), z1, z2, z3); } } else { super.handleEntityEvent(eventId); } }
Possible Fix
A possible fix for this issue, is to do the following two things:
- Add an extra check inside of the handleEntityEvent() method to see if the entity is capable of falling in love before displaying the particles
public void handleEntityEvent(byte eventId) { Fix Start if (eventId == 18 && this.canFallInLove()) { Fix End for(int i = 0; i < 7; ++i) { double d0 = this.random.nextGaussian() * 0.02D; double d1 = this.random.nextGaussian() * 0.02D;double d2 = this.random.nextGaussian() * 0.02D; this.level().addParticle(ParticleTypes.HEART, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), d0, d1, d2); } } else { super.handleEntityEvent(eventId); } }
- Inside the Mule.java class, override the "canFallInLove()" method, and return false.
public boolean canFallInLove() { return false; }
This fix provides the following behavior:
MC-176758 Fix.mp4