MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.65k stars 399 forks source link

Logs in to server and gets logged out due to can't process JoinGame packet correctly #2741

Open BurkenDev opened 4 months ago

BurkenDev commented 4 months ago

Prerequisites

Minecraft Version

1.20.6 / 1.20.4 / 1.21

Console Client Version

Latest

Expected Behavior

Logged in correctly

Actual Behavior

Logging in, you see the new character enter the game, 0.5 seconds later quits with this message:

Unhandled exception. System.IO.InvalidDataException: Failed to process incoming packet of type JoinGame. (PacketID: 40, Protocol: 763, LoginPhase: False, InnerException: System.Collections.Generic.KeyNotFoundException). ---> System.Collections.Generic.KeyNotFoundException: The given key 'minecraft:chat_type' was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at MinecraftClient.Protocol.Message.ChatParser.ReadChatType(Dictionary2 registryCodec) at MinecraftClient.Protocol.Handlers.Protocol18Handler.HandlePlayPackets(Int32 packetId, Queue1 packetData) at MinecraftClient.Protocol.Handlers.Protocol18Handler.HandlePacket(Int32 packetId, Queue1 packetData) --- End of inner exception stack trace --- at MinecraftClient.Protocol.Handlers.Protocol18Handler.HandlePacket(Int32 packetId, Queue`1 packetData) at MinecraftClient.Protocol.Handlers.Protocol18Handler.Updater(Object o) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) Aborted

Steps to Reproduce the bug

  1. login to a server using the client

Attach screenshot here (If applicable)

No response

Anythings that could help diagnosing the bug

No response

Device

Other

Operating System

Linux

Server Address (If applicable)

No response

breadbyte commented 4 months ago

1.20.4+ is not fully supported yet. There has been some work in progress but no ETA as of the moment since there are major changes and additions to the minecraft protocol.

milutinke commented 4 months ago

1.20.4+ is not fully supported yet. There has been some work in progress but no ETA as of the moment since there are major changes and additions to the minecraft protocol.

1.20.4 is supported, 1.20.6 is not yet supported.

@BurkenDev This is a problem with the server using a chat plugin that modifies the chat and sends a different non-vanilla chat structure and format, thus the MCC crashes because it only processes a vanilla packets.

If it's your server, get rid of the chat plugins, if it's not you'll have to download the code of the client, change a method and re-compile it. In ChatParser.cs, replace the ParseText method with the following code:

public static string ParseText(string json, List<string>? links = null)
{
  var isJson = false;

  try
  {
    isJson = JsonDocument.Parse(json) != null;
  }
  catch
  {
    isJson = false;
  }

  return !isJson ? json : JSONData2String(Json.ParseJson(json), "", links);
}

Follow the instructions on how to build/compile the project from the source code here: https://mccteam.github.io/guide/installation.html#building-from-the-source-code

milutinke commented 4 months ago

I don't consider this as a bug, because it's not vanilla behavior and I only heard of 2 people having this issue. I'll add the "fix" to MCC with the 1.20.6 + 1.21 update

Yiniau commented 3 months ago

same question in wynncraft server