mojira.dev
MC-267902

/random error message states incorrect range size

Problem:

When attempting to run /random with a range of 2147483647 (say /random roll 1..), the command will function correctly (as expected) generating a random value within a value range of size 2147483647. However, attempting to roll a larger range (say /random roll 0..) will display the error, "The range of the random value must be at most 2147483646," but the true maximum is 2147483647.

This may be assumed to be correct if the range is defined as the max value minus the min value (as opposed to the number of possible integer outcomes), but if that is true, then it is instead the minimum value is incorrect. Ranges featuring only one number (/random roll 1) produce the error, "The range of the random value must be at least 2," even though /random roll 1..2 works fine (which, in this definition, would have a range size of 1).

No matter which one is meant to be correct, the sizing of the range is inconsistent in these errors. 

Solution:

One of the following measures of range size needs to be consistently applied across these errors:

  1. Range size is the number of possible integer outcomes, given by max value minus min value plus 1 (1..2 has a size of 2, 1..217483647 has a size of 217483647)

  2. Range size is the max value minus min value (1..2 has a size of 1, 1..217483647 has a size of 217483646)

Personally, I think the first definition makes more intuitive sense (especially for lower size ranges).

Comments 1

Confirmed.

random roll 1
[10:25:04] [Server thread/INFO]: The range of the random value must be at least 2
random roll 1..2
[10:25:07] [Server thread/INFO]: Server rolled 2 (from 1 to 2)
random roll 0..
[10:25:12] [Server thread/INFO]: The range of the random value must be at most 2147483646
random roll 1..
[10:25:14] [Server thread/INFO]: Server rolled 1748968310 (from 1 to 2147483647)

This can simply be fixed by changing one of the strings:

"commands.random.error.range_too_large": "The range of the random value must be at most 2147483646",
  "commands.random.error.range_too_small": "The range of the random value must be at least 2",

to

"commands.random.error.range_too_large": "The range of the random value must be at most 2147483647",
  "commands.random.error.range_too_small": "The range of the random value must be at least 1",

(NOT BOTH!)

Seacraft Gaming

(Unassigned)

Confirmed

Platform

Low

Commands

command

1.20.4, 23w51b, 24w03a, 24w03b, 24w04a, 24w05a, 24w05b, 1.20.5 Pre-Release 1, 1.20.6, 1.21 Pre-Release 1

Retrieved