Skip to content

Commit 559454e

Browse files
committed
simplify /hypercube:colors
1 parent d5f4016 commit 559454e

4 files changed

Lines changed: 16 additions & 56 deletions

File tree

src/main/java/io/github/homchom/recode/mod/commands/impl/text/ColorsCommand.java

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,41 @@
66
import io.github.homchom.recode.mod.commands.arguments.ArgBuilder;
77
import io.github.homchom.recode.mod.config.Config;
88
import io.github.homchom.recode.mod.features.commands.ColorsMenu;
9+
import io.github.homchom.recode.multiplayer.LocalPlayerFunctions;
910
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
1011
import net.minecraft.client.Minecraft;
1112
import net.minecraft.commands.CommandBuildContext;
12-
import net.minecraft.network.chat.*;
1313

1414
public 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
}

src/main/java/io/github/homchom/recode/mod/config/impl/CommandsGroup.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,22 @@ public CommandsGroup(String name) {
1313

1414
@Override
1515
public void initialize() {
16-
// Non sub-grouped
16+
// top-level
1717
this.register(new BooleanSetting("dfCommands", true));
1818
this.register(new BooleanSetting("errorSound", true));
19+
this.register(new BooleanSetting("colorReplacePicker", false));
1920

20-
// Auto /msg
21+
// auto /msg
2122
ConfigSubGroup autoMessage = new ConfigSubGroup("automsg");
2223
autoMessage.register(new BooleanSetting("automsg", false));
2324
autoMessage.register(new BooleanSetting("automsg_timeout", true));
2425
autoMessage.register(new LongSetting("automsg_timeoutNumber", 300000L));
2526
this.register(autoMessage);
2627

27-
// Heads
28+
// heads
2829
ConfigSubGroup heads = new ConfigSubGroup("heads");
2930
heads.register(new BooleanSetting("headsEnabled", false));
3031
heads.register(new IntegerSetting("headMenuMaxRender", 1000));
3132
this.register(heads);
32-
33-
// Colors
34-
ConfigSubGroup colors = new ConfigSubGroup("colors");
35-
colors.register(new IntegerSetting("colorMaxRender", 158));
36-
colors.register(new IntegerSetting("colorLines", 5));
37-
colors.register(new BooleanSetting("colorReplacePicker", false));
38-
this.register(colors);
3933
}
4034
}

src/main/java/io/github/homchom/recode/multiplayer/LocalPlayerFunctions.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:JvmName("LocalPlayerFunctions")
2+
13
package io.github.homchom.recode.multiplayer
24

35
import io.github.homchom.recode.RecodeDispatcher

src/main/resources/assets/recode/lang/en_us.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,8 @@
110110
"config.recode.option.headMenuMaxRender": "Maximum Heads in /heads",
111111
"config.recode.option.headMenuMaxRender.tooltip": "Amount of heads to display in the /heads menu.",
112112

113-
"config.recode.subcategory.commands_colors": "/colors Command",
114-
"config.recode.subcategory.commands_colors.tooltip": "Settings that apply to the /colors command.",
115-
"config.recode.option.colorMaxRender": "Maximum Columns",
116-
"config.recode.option.colorMaxRender.tooltip": "Amount of color bars to display in one color line.",
117-
"config.recode.option.colorLines": "Maximum Rows",
118-
"config.recode.option.colorLines.tooltip": "Amount of rows to show in /color.",
119113
"config.recode.option.colorReplacePicker": "Replace Color Picker",
120-
"config.recode.option.colorReplacePicker.tooltip": "Replaces the color picker with\na color menu equivalent of \"/colors 100\".",
114+
"config.recode.option.colorReplacePicker.tooltip": "Replaces the color picker with\nDiamondFire's built-in command\".",
121115

122116
"config.recode.subcategory.keybinds_flightspeed": "Flight Speed Keybind Values",
123117
"config.recode.subcategory.keybinds_flightspeed.tooltip": "Values used for the Flight Speed keybinds found\nin the \"Options -> Controls -> Recode\" menu.",

0 commit comments

Comments
 (0)