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

Scientific notation not supported in command arguments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.13-pre1, Minecraft 1.13-pre3, Minecraft 1.13-pre6, Minecraft 1.13-pre7, Minecraft 1.13.1, 1.15.1, 1.15.2, 20w10a, 1.16.3, 1.16.4 Pre-release 1, 20w51a, 21w03a, 1.16.5, 21w07a, 21w08b, 1.18.2, 22w16b, 1.19.3, 1.20.4
    • Confirmed
    • Commands

      The bug

      Using scientific notation in a command does not work like it used to in 1.12.
      This should teleport you to z=1000 (and does so in 1.12):

      example
      /tp ~ ~ 1.0E3
      

      In 1.13 this will not make it through the parser

      Analysis and ideas

      Minecraft as a prefilter in place for command parameters such as numbers. For example using the String "01-.439-2" will pass that prefilter for any number, because it only contains characters that are allowed in numbers.

      example
      /particle minecraft:crit ~ ~ ~ 1 1 1 01-.439-2
      

      The command feedback message will be "Invalid float '01-.439-2'".
      If you use other characters, such as letters, e.g. "ThisIsNotANumber" the prefilter will already realize that the argument is not valid and the feedback will be "Expected float".

      example
      /particle minecraft:crit ~ ~ ~ 1 1 1 ThisIsNotANumber
      

       

      So the prefilter checks if the given number only contains valid characters and if so it passes it on to the parseFloat method in this case. If this method throws an Exception, the "invalid float" feedback is given to the player.

      Additionally there is the "Expected whitespace to end one argument, but found trailing data" feedback. This is given to the player whenever the argument starts with a valid number (as defined by the prefilter), but has any invalid characters after that.

      example
      /particle minecraft:crit ~ ~ ~ 1 1 1 123ThisIsNotANumber
      

      The prefilter however does not allow the character 'E' nor 'e'. Due to this, '1.0E5' will not make it through the prefilter to the parseFloat- method and the "Expected whitespace" feedback message is given to the player. If the prefilter for numbers did allow the character 'e'/'E', the scientific notation should work, since Java's parseFloat() and parseDouble() methods already support that.

      Besides that, it is somewhat weird, that command feedback messages will prefer the scientific notation for higher values, while the command does not accept it.

            Unassigned Unassigned
            Schortan [Mod] NeunEinser
            Votes:
            13 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: