Skip to content

Update console client to new version

ReinforceZwei edited this page Dec 3, 2021 · 2 revisions

Preparation

You have to gather:

  • Version name (1.x.x)
  • Protocol number
  • New packet types (Inbound and Outbound)
  • Any changes to packet format

You may find those information at wiki.vg.

Here is a pull request of updating from 1.17.1 to 1.18. You may take it as an example.

Step 1

Update MinecraftClient/Protocol/ProtocolHandler.cs.

  1. Find GetProtocolHandler() method
  2. Add protocol number to supportedVersions_Protocol18 array
  3. Find MCVer2ProtocolVersion() method
  4. Add version name to the switch and return correct protocol number
  5. Find ProtocolVersion2MCVer() method
  6. Add protocol number to the switch and return correct version name

Step 2

Update MinecraftClient/Program.cs.

  1. Find constant string MCHighestVersion
  2. Change it to the newest version name

Step 3

Update MinecraftClient/Protocol/Handlers/PacketTypesIn.cs and MinecraftClient/Protocol/Handlers/PacketTypesOut.cs.

Add new packet type to those two enums.

You are not required to delete any removed packet types.

Step 4

Create new packet palette in MinecraftClient/Protocol/Handlers/PacketPalettes/.

  1. You may copy the last version of the packet palette and modify it according to the changes
  2. Add the newly created packet palette to the project in Visual Studio Solution Explorer
  3. Change the class name to match the version name
  4. Add or delete packet ID and packet name to the two typeIn and typeOut dictionaries
  5. You should make sure all packet ID are sorted ascending. You may use PacketPaletteHelper.cs to help you sort them

Step 5

Update MinecraftClient/Protocol/Handlers/PacketType18Handler.cs.

  1. Find GetTypeHandler() method
  2. Add else if (protocol <= Protocol19Handler.MCxxxVersion) above the else at the end of the method
  3. Create the packet palette object created in step 4. (p = new PacketPaletteXXX())

Step 6

Update MinecraftClient/Protocol/Handlers/Protocol18.cs

  1. Create new constant to store the protocol number (you will see a section with MCXXXVersion = xxx; near the top)
  2. Update HandlePacket() method
    1. Packets that must be updated:
      • KeepAlive
      • JoinGame
      • ChatMessage
      • Respawn
      • PlayerPositionAndLook
      • MapData
      • Title
      • PlayerInfo
      • TabComplete
      • PluginMessage
      • Disconnect
      • SetCompression
      • ResourcePackSend
      • TimeUpdate
      • UpdateHealth
      • SetExperience
      • Explosion
      • HeldItemChange
      • ScoreboardObjective
      • UpdateScore
    2. Other packets are related to entities, inventory and terrain and movement. Those can be updated later
  3. You have to maintain backward compatibility when updating the packet format

Step 7

You are very close to completion.

Just have to ensure everything is working.

  1. Download Minecraft vanilla server for that version
  2. Start the server
  3. Build MinecraftClient.exe
  4. Use your build to connect your server
  5. Test sending message from the client
  6. Test sending message to the client (e.g. server console command say some message)

If they work fine and did not crash, you are done!

If not, you have to find out what caused the problem.

Step 8

Thanks for your contribution. You can submit us a pull request <3