Carpet

Carpet

2M Downloads

Integer suggestions fail to follow argument limits

rv3r opened this issue ยท 5 comments

commented

When an arguments for a command is of type int and only has min and max provided, the automatically generated suggestions that appear when using the command do not follow these limits.
To replicate:

  1. make a command with argument of type int, min of 1,max of 500
  2. load into Minecraft and start typing the command, leaving this argument blank

Expected behavior:
3) default suggestions of -123,0,123 are replaced with just 123, the only valid integer of the three

Actual behavior:
3) all default suggestions of -123,0,123 appear, even though two of them are not valid

commented

I can't think of a better method to handle this issue. As long as this behavior would be thoroughly described in the docs, I would be fine with a change like this. Would you agree that if an author provides a suggest or suggester argument, none of these built-in suggestions would appear?

For example, with min of 1 and max of 500:

  • without suggest or suggester arguments
current suggestions -> [-123, 0, 123]
new suggestions ->     [1, 250, 500]
  • with suggest or suggester arguments(say, [1, 100, 200, 300, 400, 500])
current suggestions -> [-123, 0, 123]
new suggestions ->     [1, 100, 200, 300, 400, 500] (250 not included because suggest argument was defined)
commented

k, Ill make it.

commented

Problem is, suggestions currently come from brigadier, they aren't really generated by Carpet.

This would mean adding an extra layer of complexity just for, well, suggestions, that you can change by yourself. Not sure how much is this needed depending on the complexity it ends up adding to the command processor.

commented

Well tbh I can just overwrite a little bit the suggest stuff then, in that if there is no suggestion, and it's a numeric argument

commented

Maybe we could make it so if only min is defined, then make the suggestions to be: min, min + abs(min), min + 2*abs(min).
This way, a negative min like -24 would result in suggestions of -24, 0, 24, and a min of 24 would result in 24, 48, 72. And if only max is defined, then it would be: max, max- abs(max), max- 2*abs(max), so a max of 24 would result in suggestions of 24, 0 and -24, and a max of -24 would result in suggestions of -24, -48, -72.

This doesn't fix it for a min or max of 0, as the only suggestion would in either case be 0, but for that we can add a special check, and then do 0 and + or - 123 (depends on which is appropriate ofc)

And then for a min AND max defined, we would just make the suggestions be: min, (min + max)/2, max

To make it more clear:

{'min' -> -24}               -> [-24, 0, 24]
{'min' -> 0}                 -> [0, 123]
{'min' -> 24}                -> [24, 48, 72] //tbh not too sure abt this one

{'max' -> -24}               -> [-24, -48, -72] //and this one as well
{'max' -> 0}                 -> [0, -123]
{'max' -> 24}                -> [24, 0, -24]

{'min' -> 1, 'max' -> 500}   -> [1, 250, 500]