mojira.dev
MC-93826

Breeding hearts only show once and not all the time an animal can breed anymore

The bug

In 1.8.8 and maybe later animals which can breed showed hearts the whole time they were able to breed.

Now the hearts are only shown once.

The reason

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

The reason why this happens is because the client never receives the InLove value from the server. In 1.8.9 and earlier the method net.minecraft.entity.EntityAgeable.getGrowingAge() (MCP 9.10) returned for the client the stored value whether or not the animal is a child (for 1.8 entry 12 of the data watcher, for 1.9 net.minecraft.entity.EntityAgeable.field_184751_bv). In 1.9 it returns -1 if the animal is a child, 1 if it is not. This breaks some logic for the net.minecraft.entity.passive.EntityAnimal class.

Besides that the client should receive the InLove value because neither in 1.8.9 nor in the latest versions summoning an animal with InLove greater than 0 shows particles.

/summon pig ~ ~ ~ {InLove:2147483647}

Note: The server should not run the particle spawning code of the method net.minecraft.entity.passive.EntityAnimal.onLivingUpdate().

Linked issues

Attachments

Comments 41

Issue still exists up to latest version, Minecraft 1.9.1-pre3.

I do not quiet understand the reason that was given by Marcono1234. It was working in 1.8 and prior versions, why does it only occur since the 1.9 snapshots? Clients are using an internal server since 1.3, so the issue should have appeared back then already, but it did not. So why now in 1.9?

You are right, I kind of messed up yesterday. The reason seems to be that the client does not receive the InLove value anymore, because in 1.8 the client had the correct InLove value, in 1.9 it does not. I will update the report in a moment.

Still not fixed in 16w15a.

Still present in 1.9.3-pre2.

31 more comments

Can confirm in the 1.20.2 release candidate.

Can confirm in 24w19b and release 1.20.6

Affects 1.21

This is easily fixed

Using Mojmaps 1.20.1
In the aiStep method the code calls the addParticles method but as pointed out by other users the inLove ticks aren't sent client side.

if (this.inLove > 0) {
  --this.inLove;
  if (this.inLove % 10 == 0) {
      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);
  }
}

This can be fixed by checking if the code is running server side and then send the particles to clients

if (this.inLove > 0) {
  --this.inLove;
  if (this.inLove % 10 == 0) {
    double d0 = this.random.nextGaussian() * 0.02D;
    double d1 = this.random.nextGaussian() * 0.02D;
    double d2 = this.random.nextGaussian() * 0.02D;
    //Note, I didn't use the speed calculated above
    if (this.level instanceof ServerLevel serverLevel)
      serverLevel.sendParticles(ParticleTypes.HEART, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 1, 0, 0.1f);
  }
}
Duffy Springpat

Still in 1.21.5 and 1.21.6 snapshots.

marcono1234

(Unassigned)

Confirmed

Gameplay

Low

Mob behaviour

animal, breeding, hearts, particle

Minecraft 15w33c, Minecraft 15w49b, Minecraft 16w06a, Minecraft 1.9.1 Pre-Release 3, Minecraft 16w15a, ..., 22w44a, 22w46a, 1.20.4, 24w11a, 1.21

Retrieved