This commit is contained in:
Chayapak 2023-07-04 16:26:38 +07:00
parent 0af580f804
commit 49327ce22e

View file

@ -6,8 +6,6 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager; import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.modules.ChatInputGlobals; import land.chipmunk.chipmunkmod.modules.ChatInputGlobals;
import land.chipmunk.chipmunkmod.modules.RainbowName; import land.chipmunk.chipmunkmod.modules.RainbowName;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.MessageIndicator; import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.ChatScreen;
@ -45,19 +43,17 @@ public class ChatHudMixin {
} }
try { try {
final Component component = message.asComponent(); final List<Text> children = message.getSiblings();
final List<Component> children = component.children();
if (children.size() == 0) return; if (children.size() == 0) return;
if (!((TextComponent) children.get(0)).content().equals("chomens_bot_command_suggestion")) return; if (!children.get(0).getString().equals("chomens_bot_command_suggestion")) return;
ci.cancel(); ci.cancel();
final String[] matches = children.subList(2, children.size()) final String[] matches = children.subList(2, children.size())
.stream() .stream()
.map((each) -> ((TextComponent) each).content()) .map(Text::getString)
.toArray(String[]::new); .toArray(String[]::new);
if (!(MinecraftClient.getInstance().currentScreen instanceof ChatScreen chatScreen)) return; if (!(MinecraftClient.getInstance().currentScreen instanceof ChatScreen chatScreen)) return;