We can obtain Book and Quill carrying custom data by crafting the following recipe:
[media]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:
[media]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
[media]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)
Linked issues
is duplicated by 2
Attachments
Comments 6
No, it doesn't appear to support giving the custom data in SNBT.
Confirmed – I'm not 100% sure whether this is a bug or a feature request, but it does seem undesirable that it's not possible to reliably specify the data type there thanks to it needing to be specified in JSON rather than (S)NBT.
Can confirm. Custom data is stored in NBT with various numerical data type, but is specified here with JSON, which makes it impossible to specify the data type. Especially for decimals. A decimal is often converted into an unexpected data type, e.g. 31.75 is converted to a float NBT tag, but 31.85 is converted to a double.
To fix this bug, the custom_data component in JSON should be possible to be specified in SNBT format.
This is also a problem when setting the "minecraft:entity_data", "minecraft:bucket_entity_data", "minecraft:block_entity_data" components, as well as the "minecraft:contents" or "minecraft:bundle_contents" components if they then contain items with those components.
Basically any time you're setting a component that contains unstructured NBT in a JSON context, you're potentially gonna have a bad time with unexpected typing.
Please update the description to include steps to reproduce this issue, as well as expected VS observed results.
Please also attach any needed datapacks, resourcepacks, screenshots, videos or worlds needed to help reproduce this issue.