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

SNBT can write infinity/NaN, but can't read them (round trip data loss)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.16.3, 20w51a
    • Fix Version/s: None
    • Labels:
      None
    • Confirmation Status:
      Community Consensus
    • Category:
      (Unassigned)

      Description

      The bug

      When a float/double NBT tag is converted to string NBT while containing the floating point values of NaN or infinity, the resulting value is NaNf / NaNd and Infinityf / Infinityd.

      However, when parsing SNBT, those values are read not as floats/doubles, but as strings. Therefore, a round-trip conversion leads to information loss with these values.

      How to reproduce

      /data modify storage test:test test set value 999e999f
      /data get storage test:test test
      /data modify storage test:test test set value Infinityf
      /data get storage test:test test
      

      The first command converts SNBT (999e999f) to an NBT float (infinity)
      The second command converts the NBT float (infinity) back to SNBT (Infinityf)
      The third command converts SNBT (Infinityf) to an NBT string ("Infinityf")
      The fourth command converts the NBT string ("Infinityf") back to SNBT ("Infinityf")

      Another way to test this would be using the server data generator NBT <-> SNBT converters to see the round-trip transformation from infinity/NaN floating point tags to string tags

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            tryashtar [Mod] tryashtar
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              CHK: