66import io .github .homchom .recode .mod .commands .arguments .ArgBuilder ;
77import io .github .homchom .recode .mod .config .Config ;
88import io .github .homchom .recode .mod .features .commands .ColorsMenu ;
9+ import io .github .homchom .recode .multiplayer .LocalPlayerFunctions ;
910import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
1011import net .minecraft .client .Minecraft ;
1112import net .minecraft .commands .CommandBuildContext ;
12- import net .minecraft .network .chat .*;
1313
1414public class ColorsCommand extends Command {
15-
16- private final Minecraft mc = Minecraft .getInstance ();
17-
1815 @ Override
1916 public void register (Minecraft mc , CommandDispatcher <FabricClientCommandSource > cd , CommandBuildContext context ) {
2017 cd .register (ArgBuilder .literal ("colors" ).executes ((ctx ) -> {
2118 if (Config .getBoolean ("colorReplacePicker" )) {
22- showColorPalette ( 1 );
19+ LocalPlayerFunctions . sendCommand ( "hypercube:colors" );
2320 } else {
2421 ColorsMenu colorsGui = new ColorsMenu ();
2522 colorsGui .scheduleOpenGui (colorsGui , "" );
26- //showColorPalette(1);
2723 }
2824 return 1 ;
2925 })
3026 .then (ArgBuilder .argument ("Saturation(%)" , IntegerArgumentType .integer (0 , 100 )).executes ((ctx ) -> {
31- float saturation = ( float ) IntegerArgumentType .getInteger (ctx , "Saturation(%)" );
32- showColorPalette ( saturation / 100f );
27+ int saturation = IntegerArgumentType .getInteger (ctx , "Saturation(%)" );
28+ LocalPlayerFunctions . sendCommand ( "hypercube:colors " + saturation );
3329 return 1 ;
3430 })));
3531 }
3632
3733 @ Override
3834 public String getDescription () {
39- return "[blue]/colors [saturation][reset]\n "
40- + "\n "
41- + "Shows the color picker menu.\n "
42- + "When Saturation value is specified, it will show you the old color picker in chat." ;
35+ return """
36+ [blue]/colors [saturation][reset]
37+
38+ Shows the color picker menu.
39+ When Saturation value is specified, it will show you the old color picker in chat.""" ;
4340 }
4441
4542 @ Override
4643 public String getName () {
4744 return "/colors" ;
4845 }
49-
50- private void showColorPalette (float saturation ) {
51- int maxColors = Config .getInteger ("colorMaxRender" );
52- int lines = Config .getInteger ("colorLines" );
53-
54- for (int j = 0 ; j < lines ; j ++) {
55- Component base = Component .literal ("" );
56- float b = 1f - ((1f / lines ) * j );
57- for (int i = 0 ; i < maxColors ; i ++) {
58- float index = (360 / maxColors ) * i ;
59-
60- java .awt .Color color = java .awt .Color .getHSBColor (index / 360 , saturation , b );
61- String colorName = "#" + Integer .toHexString (color .getRGB ()).substring (2 );
62-
63- Style colorStyle = Style .EMPTY .withColor (TextColor .fromRgb (color .getRGB ()));
64- MutableComponent extra = Component .literal ("|" );
65- MutableComponent hover = Component .literal (colorName );
66- hover .append ("\n §7Click to copy!" );
67- extra .setStyle (colorStyle );
68- hover .setStyle (colorStyle );
69- extra .withStyle ((style ) -> style .withClickEvent (new ClickEvent (ClickEvent .Action .RUN_COMMAND , "/color hex " + colorName )));
70- extra .withStyle ((style ) -> style .withHoverEvent (HoverEvent .Action .SHOW_TEXT .deserializeFromLegacy (hover )));
71- base .getSiblings ().add (extra );
72- }
73- mc .player .displayClientMessage (base , false );
74- }
75- }
7646}
0 commit comments