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

Issue with chat decoding #6

Open
nicoxxl opened this issue May 18, 2021 · 2 comments
Open

Issue with chat decoding #6

nicoxxl opened this issue May 18, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@nicoxxl
Copy link

nicoxxl commented May 18, 2021

Hi, I'm having an error as a client trying to decode chat messages.

First of all, I'm running it on 1.16.5 minecraft server (there is a change in protocol version but I did not see any change in protocol, so I'm not sure if it is not from there).

On my code I used dbg!() on `` and I get this :

[src/engine.rs:51] err = PacketErr {
    err: failed to deserialize packet: failed to deserialize json: "failed to deserialize chat from JSON '{\"translate\":\"chat.type.text\",\"with\":[{\"insertion\":\"nicoxxl\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/tell nicoxxl \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":{\"type\":\"minecraft:player\",\"id\":\"665fbf7d-d38f-3fa1-80a3-3a9a2c7d7220\",\"name\":{\"text\":\"nicoxxl\"}}},\"text\":\"nicoxxl\"},\"Hello BillyBob :)\"]}' :: Error(\"unable to parse one of the translation with entries :: unexpected key in event contents\", line: 1, column: 314)",
}

The formatted JSON looks like that :

{
  "translate": "chat.type.text",
  "with": [
    {
      "clickEvent": {
        "action": "suggest_command",
        "value": "/tell nicoxxl "
      },
      "hoverEvent": {
        "action": "show_entity",
        "contents": {
          "id": "665fbf7d-d38f-3fa1-80a3-3a9a2c7d7220",
          "name": {
            "text": "nicoxxl"
          },
          "type": "minecraft:player"
        }
      },
      "insertion": "nicoxxl",
      "text": "nicoxxl"
    },
    "Hello BillyBob :)"
  ]
}

In the code I saw this :

#[derive(Serialize, Clone, Debug, PartialEq)]
pub struct BaseComponent {
    // Cut some fields above
    #[serde(skip_serializing_if = "Option::is_none")]
    pub click_event: Option<ChatClickEvent>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hover_event: Option<ChatHoverEvent>,
    // Cut some field below
}

You did not used #[serde(rename = "name")] to swith to camelCase, is that an error or the protocol changed ?

@Twister915
Copy link
Owner

Hi, I will have a look at this tonight. I believe I've also run into this issue before. Thanks for submitting this report.

@Twister915 Twister915 self-assigned this May 19, 2021
@Twister915 Twister915 added the bug Something isn't working label May 19, 2021
@regenerativep
Copy link

I recently had this problem. It seems like mcproto is looking for a "value" key in the hoverEvent, but, even though its even specified like that in wiki.vg, that's not the case in the JSON minecraft is sending.
Turning line 1009 in chat.rs from

"value" => {

to

"value" | "contents" => {

appears to fix it for me.

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

No branches or pull requests

3 participants