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

The data type of the "minecraft:custom_data" component of the recipe result will be forcibly modified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w19a
    • 1.20.5 Release Candidate 2, 1.20.5
    • None
    • Confirmed
    • Data Packs, Items
    • Normal
    • Platform

      We can obtain Book and Quill carrying custom data by crafting the following recipe:

      We specify a value of 1 for "isNamebook" in the "minecraft:custom_data" component of the item.

      Use the following command to get the mainhand item data:

      /data get entity @s SelectedItem 

      We get the following output:

      I would expect "isNamebook" to have a value of 1, however it has a value of 1b.
      I found that the data is converted as follows:

      • true -> 1b
      • 1 -> 1b
      • 0 -> 0b
      • 0.5 -> 0.5f
      • 1.2 -> 1.2d
      • -2147483648 -> -2147483648
      • -2147483649 -> -2147483649L

      This follows the same pattern as the wiki description of the conversion of nbt from json files:
      NBT_format#Conversion_from_JSON

      This means that only 1b can exist in the "minecraft:custom_data" component of a recipe output item, not 1s, 1, 1l, 1.0f, 1.0d.

      I've provided the datapack in the attachment (it's the zip)

        1. 20240420221340.png
          20240420221340.png
          108 kB
        2. 20240420221613.png
          20240420221613.png
          79 kB
        3. test_custom_data.zip
          1 kB
        4. 20240420225736.png
          20240420225736.png
          157 kB

            gegy1000 [Mojang] Gegy
            Mini_Ye Mini_Ye
            Votes:
            5 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: