mojira.dev
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

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 (

[media]
  1. ).

  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:

[media]

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.

[media]

The same issue happens with HandDropChances.

Linked issues

Attachments

Comments 6

Have you tried "ArmorDropChances":[0.0,0.0,0.0,0.0], does that work?

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

"ArmorDropChances":[0.0,0.0,0.0,0.0] also becomes a B array

For some reason, the only value that gets properly converted into a float is 0.5. All other decimal values between 0 and 1 are converted to doubles and 0 and 1 themselves are converted to bytes.

I have uploaded a data pack with some loot tables with varying values to demonstrate a few different conversions that cause the tag to reset when the mob is spawned. One of the included loot tables, mc-274615:float, is correctly converted to a list of floats.

This can be worked around by using stringified SNBT format (and specifying type) for the entity_data component 🙂 

Thank you for your report!
After consideration, the issue is being closed as Won't Fix.

Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

baffledhedgehog

(Unassigned)

Confirmed

Data Packs, Loot tables

1.21

Retrieved