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

ArmorDropChances and HandDropChances in spawn egg data from loot tables are not converted into lists of floats, causing them to reset when a mob is spawned from the spawn egg

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • None
    • 1.21
    • None
    • Confirmed
    • Data Packs, Loot tables

      A loot table that returns a spawn egg with the entity_data component containing either ArmorDropChances or HandDropChances set to a JSON array of values does not convert the JSON array to a list of float values, causing the tag to reset on any mobs spawned by using that spawn egg.

      How to reproduce:

      1. Create a world with the attached data pack (MC-274615.zip).
      2. Execute the following command:
        /loot give @s loot mc-274615:byte_array
      3. While holding the spawn egg you were given, execute the following command:
        /data get entity @s SelectedItem.components."minecraft:entity_data".ArmorDropChances
      4. Look at the list of values returned in the chat.
      5. Use the spawn egg to spawn a zombie.
      6. Execute the following command:
        /data get entity @n[type=minecraft:zombie]
      7. Notice that the list of values returned is different from the ones stored in the spawn egg itself.

      Expected result:

      A mob spawned from a spawn egg with an incorrectly converted ArmorDropChances or HandDropChances tag would use the stored values for that tag.

      Observed result:

      A mob spawned from a spawn egg with an incorrectly converted ArmorDropChances or HandDropChances tag resets the tag to its default value.


      Original description:

      Using the following loot table:

      {
          "pools": [{
              "rolls": 1,
              "entries": [{
                  "type": "item",
                  "weight": 1,
                  "name": "minecraft:zombie_spawn_egg",
                  "functions": [
                      {"function": "set_count", "count": 1},
                      {
                          "function": "set_components",
                          "components": {
                              "minecraft:entity_data": {
                                  "id": "minecraft:zombie",
                                  "ArmorItems": [{}, {}, {}, {"id": "minecraft:iron_helmet", "count": 1}],
                                  "ArmorDropChances": [0, 0, 0, 0]
                              }
                          }
                      }
                  ]
              }]
          }]
      }
      

       
      It gives spawn egg with entity data like this, which means it got converted into a byte array instead of a list of floats:

      The same happens when using "ArmorDropChances": [0.0, 0.0, 0.0, 0.0]. Using a non-zero values like [0.001, 0.001, 0.001, 0.001] anywhere in this list does cause same issue but with 4 doubles instead of floats (also incorrect data type)

      When spawning a mob from this item, the ArmorDropChances get overriden with the default value of 0.085f, ignoring array with the incorrect data type.

      The same issue happens with HandDropChances.

            Unassigned Unassigned
            baffledhedgehog baffledhedgehog
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: