mojira.dev
MC-195139

Zoglin "IsBaby" entity tag cannot be changed from true to false (1b to 0b) with /data

The bug

Despite MC-65953 being fixed, the IsBaby entity tag for zoglins cannot be changed from true to false (or 1b to 0b) with /data.

Can confirm in 21w07a. Here are some steps to reproduce this issue:

To reproduce:

  1. Summon a baby zoglin

    /summon zoglin ~ ~ ~ {IsBaby:1b}
  2. Run the /data command:

    /data merge entity @e[type=zoglin,limit=1,sort=nearest] {IsBaby:0b}

    → ❌  "Modified entity data of Zoglin" is shown in chat but the mob still remains as a zoglin piglet.

Linked issues

Attachments

Comments 11

Can confirm in 21w03a.

Can confirm in 21w07a. Here are some steps to reproduce this issue:

Steps to Reproduce:

  • Summon a zoglin using a spawn egg.

  • Run the following command to convert the zoglin into a baby:

/data merge entity @e[type=zoglin,limit=1,sort=nearest] {IsBaby:1b}

→ ✔  Notice how the zoglin is now a baby.

  • Run the following command to convert the zoglin back into an adult:

/data merge entity @e[type=zoglin,limit=1,sort=nearest] {IsBaby:0b}

→ ❌  Notice how this does not work.

Can confirm in 21w15a.

Can confirm in 1.16.5 and 1.17 Release Candidate 1.

Can confirm in 1.17.

1 more comments

Can confirm in 1.18.1.

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

I can confirm this issue in Minecraft 1.21 pre-release 1.

Code analysis (Yarn mappings)

The following code in the ZoglinEntity class manages the babiness of zoglins:

@Override
public void writeCustomDataToNbt(NbtCompound nbt) {
	super.writeCustomDataToNbt(nbt);
	if (this.isBaby()) {
		nbt.putBoolean("IsBaby", true);
	}
}

@Override
public void readCustomDataFromNbt(NbtCompound nbt) {
	super.readCustomDataFromNbt(nbt);
	if (nbt.getBoolean("IsBaby")) {
		this.setBaby(true);
	}
}

Notice that the zoglin becomes a baby if the IsBaby field within entity NBT is true. There is no behavior for making the zoglin not a baby if the IsBaby field is false.

Compare to the same methods in other entities with a boolean babiness status (zombies and piglins), where the IsBaby field controls babiness regardless of being true or false:

@Override
public void readCustomDataFromNbt(NbtCompound nbt) {
	super.readCustomDataFromNbt(nbt);
	this.setBaby(nbt.getBoolean("IsBaby"));
}

DrownedZombie

(Unassigned)

Confirmed

Platform

Low

Commands

20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Pre-release 3, ..., 1.20 Release Candidate 1, 1.20, 1.20.1, 1.20.6, 1.21 Pre-Release 1

Retrieved