Invalid color check fails.
viwty opened this issue ยท 1 comments
Minecraft Version
1.20.x
Version
1.109.6
Details
This was found by a different person in the discord guild.
When trying to set the background/text color to something invalid, like 100, advanced computers error as they should.
However, this is not the case with basic computers and monitors.
(The monitor color does change)
I assume this is the case because multishell checks if the color is valid, but the native terminal errors silently.
So there's a mismatch here between what the various term
implementations do:
- The native (Java) terminal, uses the highest bit to find the colour (this is also what
color.toBlit
does). - Meanwhile the
window
API just uses a lookup table on the "correct" colours.
The term.Redirect
contract is a little underspecified here in terms of what values are supported. I think we probably need to make the following changes:
window
should usecolor.toBlit
(or probably an inlined version, to minimise the performance cost).color.toBlit
should perform bounds checks -color.toBlit(2 ^ 16)
will currently return"10"
, when it should error.- Update the
term.Redirect
documentation to specify the expected behaviour:- Callers of
set.*Colou?r
functions should only pass in valid colours. - Implementations may accept invalid colours, following the conversion logic in
colors.toBlit
.
- Callers of