Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

[BUG] Colors in chat do not work for me

Open AdiletTermux1011 opened this issue 3 years ago • 8 comments

Prerequisites

  • [X] I made sure I am running the latest development build
  • [X] I tried to look for similar issues before opening a new one
  • [X] I have set debugmessages=true in config to diagnose my issue
  • [X] I have redacted session tokens and passwords before attaching screenshots

Minecraft Version

1.16.5

Console Client Version

v1.18.2

Expected Behavior

To make colors work in chat

Actual Behavior

Colors not working in chat

Steps to Reproduce the bug

Attach screenshot here (If applicable)

Screenshot_3

Anythings that could help diagnosing the bug

No response

Device

Laptop

Operating System

Windows

Server Address (If applicable)

No response

AdiletTermux1011 avatar Jun 20 '22 12:06 AdiletTermux1011

[MCSettings]
# Settings below are sent to the server and only affect server-side things like your skin
enabled=true                       # If disabled, settings below are not sent to the server
locale=en_US                       # Use any language implemented in Minecraft
renderdistance=tiny              # Use tiny, short, medium, far, or chunk amount [0 - 255]
difficulty=normal                  # MC 1.7- difficulty. peaceful, easy, normal, difficult
chatmode=enabled                   # Use 'enabled', 'commands', or 'disabled'. Allows to mute yourself...
chatcolors=true                    # Allows disabling chat colors server-side
main_hand=left                     # MC 1.9+ main hand. left or right
skin_cape=true
skin_hat=true
skin_jacket=false
skin_sleeve_left=false
skin_sleeve_right=false
skin_pants_left=false
skin_pants_right=false

AdiletTermux1011 avatar Jun 20 '22 12:06 AdiletTermux1011

Which Windows version are you using? Note that on Windows 7 and 8 colors are not working in the default terminal. Use Alacritty

milutinke avatar Aug 26 '22 15:08 milutinke

Doesn't seem related to #2122.

Colors don't seem to be working because they are using a completely different color scheme. The colors are gradiented in the picture, meaning they are using the new rgb color feature introduced in 20w17a (1.16).

An implementation must be made for this, in both MCC and the console handler.

(On the same vein as #2122, it might be nice to get a fallback color that is nearest to the specified RGB value if the terminal only supports basic color.)

breadbyte avatar Aug 26 '22 16:08 breadbyte

The simplest solution would be to just use the dominant color, eg. convert the hex into rgb and then do manual checks for ranges, maybe there is an utility that could classify a color name based on hex.

milutinke avatar Aug 26 '22 18:08 milutinke

This should do the job:

public static string getColorName(int[] myColor) {
	Dictionary<string, int[]> colors = new Dictionary<string, int[]>();
		
        colors.Add("red", new int[]{255,0,0});
        colors.Add("yellow", new int[]{255,255,0});
        colors.Add("green", new int[]{0,255,0});
        colors.Add("cyan", new int[]{0,255,255});
        colors.Add("blue", new int[]{0,0,255});
        colors.Add("magenta", new int[]{255,0,255});
        colors.Add("white", new int[]{255,255,255});
        colors.Add("grey", new int[]{127,127,127});
        colors.Add("black", new int[]{0,0,0});
		
	double temporaryDistance = double.MaxValue;
	string temporaryName = "";
		
	foreach(KeyValuePair<string, int[]> color in colors) {
		double rDistance = (double)myColor[0] - color.Value[0];
		double gDistance = (double)myColor[1] - color.Value[1];
		double bDistance = (double)myColor[2] - color.Value[2];
			
		double totalDistance = Math.Sqrt((rDistance * rDistance) +  (gDistance * gDistance) + (bDistance * bDistance));
			
		if(totalDistance < temporaryDistance) {
			temporaryName = color.Key;
			temporaryDistance = totalDistance;
		}
	}
		
	return temporaryName;
}

Eg. getColorName(new int[]{51, 153, 255})

milutinke avatar Aug 26 '22 19:08 milutinke

Converting colors back to 16 colors on terminals that do not support other color codes seems a good idea 👍

ORelio avatar Sep 03 '22 13:09 ORelio

@breadbyte Is it fixed?

milutinke avatar Sep 10 '22 18:09 milutinke

@breadbyte Is it fixed?

I am currently working on it.

breadbyte avatar Sep 11 '22 04:09 breadbyte