Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-269005

Player heads from previous versions cause game crash and/or are converted incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w10a
    • 24w09a
    • None
    • Confirmed
    • Commands, Crash, Datafixer
    • Very Important
    • Platform

      Incorrect Conversion

      Player heads in previous versions could have a SkullOwner.Name set to an invalid username, such as a string with spaces, special characters, or more than 16 characters. This was commonly used to allow head names to persist when placed and broken again, due to MC-174496. When updating a world to the latest snapshot, all items with such data turn into plain player heads with no skin texture information, due to the entire minecraft:profile item component being invalidated.

      Even if invalid usernames must be removed during conversion, the skin texture should at least remain. Currently it does not.

      Game Crashes

      Despite that, player heads placed down in block form remain the same: they are able to keep their texture and invalid player name. Therefore, when the player head block is broken, it drops a player head item with an invalid component:

      Trying to use /data get entity @s SelectedItem while holding this invalid item results in the following error:

      Furthermore, trying to save & quit the world results in a game crash:

      Reproduction Steps

      1.  In a 1.20.4 creative world, use a command block to run the following command. This gives you the Elder Guardian head from the https://vanillatweaks.net/ "More Mob Heads" data pack (meaning many players will have this exact item in survival mode).
        give @p minecraft:player_head{SkullOwner:{Id:[I;1449915152,-149469738,-1161669070,1520260531],Name:"Elder Guardian",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGEyZDY0ZjRhMDBlOWM4NWY2NzI2MmVkY2FjYjg0NTIzNTgxYWUwZjM3YmRhYjIyZGQ3MDQ1MjRmNjJlMTY5ZiJ9fX0="}]}},BlockEntityTag:{note_block_sound:"minecraft:entity.elder_guardian.ambient"}}
        
      1. Place the head down, but keep it in your inventory too.
      2. Upgrade the world to the latest snapshot.
      3. Observe that all the head in your inventory has become a plain player head with no profile component texture at all.
      4. Enter /gamemode survival.
      5. Break the head and pick it up.
      6. Log out of the world. The game crashes.

      Possible Solutions

      I believe the most backwards-compatible solution would be to once again allow invalid player names on player heads. (With the Vanilla Tweaks "More Mob Heads" pack, for example, this allows newly obtained mob heads to continue stacking with old heads, and perfectionist players who want the "real" head won't be dissatisfied with a mob head merely called "Player Head".)

      But if for some reason that can't be done, then at worst, the conversion should only remove the player name part of the component, rather than deleting the entire head texture, because otherwise a lot of heads will just be lost. And at best, the old player name could somehow be converted into a display name on the item, provided there isn't already one set. (Using "More Mob Heads" as an example again, otherwise this would result in a lot of upset players losing difficult-to-obtain mob heads in their head collections. They will just turn into Steve.)

      If necessary, the same conversion should be applied to player head block entity data as well, to prevent invalid item components from being generated when the block is broken.

        1. image-2024-03-01-19-39-57-086.png
          10 kB
          Grant Gryczan
        2. image-2024-03-01-19-40-16-021.png
          5 kB
          Grant Gryczan
        3. image-2024-03-01-19-42-27-397.png
          6 kB
          Grant Gryczan

            gegy1000 [Mojang] Gegy
            GrantGryczan Grant Gryczan
            Votes:
            15 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: