Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] parseWaypointFromChat从聊天中解析路径点无法点击高亮 #51

Open
1 task done
JavaNuLi opened this issue Dec 29, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working pending Awaiting response from developer

Comments

@JavaNuLi
Copy link

Minecraft Version

1.21

OMMC Version

OhMyMinecraftClient-mc1.21.1-fabric-0.6.362-pull_request.jar

Description

从聊天中解析路径点无法点击高亮,使用O+P发送的坐标,无法点击高亮。开启强制解析也不能点击

To Reproduce

使用O+P发送的坐标,发送的坐标无法高亮,手动在聊天框打出的坐标也无法高亮点击

Expected behavior

No response

Log

No response

Latest CI build tested

  • I confirm that this problem still exists with the latest CI build.
@JavaNuLi JavaNuLi added bug Something isn't working pending Awaiting response from developer labels Dec 29, 2024
@star-bailu
Copy link

star-bailu commented Dec 29, 2024 via email

@JavaNuLi
Copy link
Author

我尝试clone代码并测试后
修复了解析路径点功能,代码如下:
public void parseMessage(@NotNull Component chat) {
chat.getSiblings().forEach(this::parseMessage);

    //#if MC > 11802
    ComponentContents
    //#else MC > 11502
    //$$ BaseComponent
    //#endif
    contents = ComponentUtil.getTextContent((MutableComponent) chat);
    if (
            //#if MC > 11802
            !(contents instanceof TranslatableContents)
            //#else
            //$$ !(contents instanceof TranslatableComponent)
            //#endif
    ) {
        this.updateMessage(chat);
        return;
    }

    //#if MC > 11802
    Object[] args = ((TranslatableContents) contents).getArgs();
    //#else
    //$$ Object[] args = ((TranslatableComponent) contents).getArgs();
    //#endif
    boolean updateTranslatableText = false;

    for (int i = 0; i < args.length; i++) {
        if (args[i] instanceof Component) {
            String string = ((Component) args[i]).getString();
            if (string.startsWith("[")) {
                Component text = ComponentUtil.simple(string);
                if (this.updateMessage(text)) {
                    args[i] = text;
                    updateTranslatableText = true;
                }
            } else {
                this.parseMessage(ComponentUtil.simple(((Component) args[i]).getString()));
            }
        } else if (args[i] instanceof String) {
            Component text = ComponentUtil.simple(args[i]);

            if (this.updateMessage(text)) {
                args[i] = text;
                updateTranslatableText = true;
            }
        }
    }

    if (updateTranslatableText) {
        //#if MC > 11502
        ((AccessorTranslatableComponent) contents).setDecomposedWith(null);
        //#else
        //$$ ((AccessorTranslatableComponent) contents).setDecomposedLanguageTime(-1);
        //#endif
    }

    this.updateMessage(chat);
}
兼容代码写的针对性很强,希望对您有价值。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending Awaiting response from developer
Projects
None yet
Development

No branches or pull requests

2 participants