mojira.dev
MC-91006

Some entities lose their name when placed/broken

The bug

Some items which can be used to place the respective entity in the world do not apply the custom item name to the entity. This means once you destroy the entity and pick it up as item it will not have a custom name anymore.

This was fixed for:

  • minecarts

  • armor stands (23w03a)

  • boat

  • chest_boat (MC-249408)

  • ender_pearl

  • eye_of_ender

  • firework_rocket

Affected items / entities

  • ender_crystal

  • fishing_bobber (from fishing rod)

  • item_frame / glow_item_frame

  • leash_knot

  • painting

Code analysis

Code analysis by @unknown can be found in this comment.

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media]
migrated

This is a dupe of MC-1981. Someone changed the title to make it misleading. Its not just arrows.

marcono1234

As I mentioned this is also partwise broken for MinecartCommandBlocks as their NBT does not contain the CustomName but they still have one after breaking them.

Duplicated by:

Relates to:

migrated

It also happens in 1.9

migrated

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

migrated

Confirmed for:

  • armor_stand

  • item_frame

  • ender_crystal

  • firework_rocket(keeps data as an item though? as if dropped onto the floor)

  • leash_knot(idk if that's valid/worth looking at but I'm testing them now anyway 😛)

  • oak_boat(haven't tested the others...)

  • eye_of_ender_signal

  • ender_pearl

  • fishing_bobber (from fishing rod)

  • painting

in 18w02a

Asteraoth

Confirmed for 18w31a

Asteraoth

Confirmed for 18w32a

migrated

I also confirm it for 18w32a. Renamed a fleet of boats by Greek alphabet only to find out the bug 😞

Asteraoth

Confirmed for 18w33a

Asteraoth

Confirmed for 1.13.1-pre1

migrated

Would be nice if the boat names worked. I'm sentimental.

migrated

Still an issue with Armor Stands in 1.14.4, which breaks the datapack I'm working on. I assume other items/entities are also broken.

[media]
pulpetti

Affects 1.16.1 and 20w29a.

migrated

 

The reason this happens for the majority of entities is that the calls to drop the items are just for the item name, and don't store NBT data.

This could be fixed by instead of just spawning in a blank item this.dropItem(Items.PAINTING);, the game also added the CustomName as NBT.

An example of this occurring can be found below:

The following is just for the Boat item and was decompiled using the Yarn mappings and CFR.

In net.minecraft.entity.vehicle.BoatEntity, the condition for the boat to break is declared.

public boolean damage(DamageSource source, float amount) {
    if (this.isInvulnerableTo(source)) {
        return false;
    } else if (!this.world.isClient && !this.removed) {
        this.setDamageWobbleSide(-this.getDamageWobbleSide());
        this.setDamageWobbleTicks(10);
        this.setDamageWobbleStrength(this.getDamageWobbleStrength() + amount * 10.0F);
        this.scheduleVelocityUpdate();
        boolean bl = source.getAttacker() instanceof PlayerEntity && ((PlayerEntity)source.getAttacker()).abilities.creativeMode;
        if (bl || this.getDamageWobbleStrength() > 40.0F) {
            if (!bl && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {


                // This is the line that drops the boat item.
                this.dropItem(this.asItem());
            }

            this.remove();
        }

        return true;
    } else {
        return true;
    }
}

As you can see, the Boat item is dropped using a call to this.dropItem. However, this.asItem does not store the CustomName or any NBT at all, it's just a switch to determine the type of item.

 

The method is seen below.

 

public Item asItem() {
    switch(this.getBoatType()) {
    case OAK:
    default:
        return Items.OAK_BOAT;
    case SPRUCE:
        return Items.SPRUCE_BOAT;
    case BIRCH:
        return Items.BIRCH_BOAT;
    case JUNGLE:
        return Items.JUNGLE_BOAT;
    case ACACIA:
        return Items.ACACIA_BOAT;
    case DARK_OAK:
        return Items.DARK_OAK_BOAT;
    }
}

 

This could be fixed by changing the item to add in the CustomName NBT into its display.Name nbt.

 

Johnibur

Removed bed from the list as this is not placed as an entity.

Avoma

Can confirm in 21w03a.

Avoma

Can confirm in 21w05b.

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 21w07a.

Avoma

I've attached an example video.

Avoma

Can confirm in 1.16.5 and 21w08b.

Avoma

Can confirm in 21w11a.

Avoma

Can confirm in 21w15a.

Avoma

Can confirm in 21w17a.

Avoma

Can confirm in 1.17.

Avoma

Can confirm in 1.17.1.

Avoma

Can confirm in 1.18.1.

Avoma

Can confirm in 1.18.2 and 22w12a.

Avoma

Can confirm in 1.19.

Avoma

Can confirm in 1.19.2.

ampolive

Armor stands were fixed in 23w03a.

Lunarian

Can confirm in 1.20.2 & 23w43b

Bluebird

boats and chest boats keep their name when placed and broken in the latest snapshot (24w12a). Same with Eye of enders, enderpearls, and fireworks rockets also keep their name when thrown / placed. I don't know when these were fixed but they are

I can confirm that end crystals, paintings, item frames / glow item frames, leads / leash knots, fishing rod bobber (fishing rod name),

migrated

Nathan Adams

Confirmed

Platform

Normal

Entities

CustomName, armor_stand, boat, display-Name, entity, item, item_frame, mojang_internal_1, painting

Minecraft 1.8.8, Minecraft 15w42a, Minecraft 1.9, Minecraft 16w36a, Minecraft 1.11, ..., 1.20.4, 24w12a, 24w13a, 1.20.6, 24w20a

Retrieved