Skip to content

Instantly share code, notes, and snippets.

@apple502j
Created April 28, 2022 18:04
Show Gist options
  • Save apple502j/e28ee8747e340973e9e27c5b68a14ade to your computer and use it in GitHub Desktop.
Save apple502j/e28ee8747e340973e9e27c5b68a14ade to your computer and use it in GitHub Desktop.

22w17a docs

Known issues

  • Loading singleplayer world can sometimes crash the game (potentially related to use of Mojang account) - MC-250974
  • Goat horn appears everywhere in Creative inventory - MC-250926
  • Player gets assigned a new UUID in singleplayer, causing skins, previously saved advancements, etc to not load - MC-250954

Changes

Chat Refactor

Chat is completely re-written. Here is how this works:

  • Client requests Public/Private key pair from Mojang's server on startup.
  • Client, when joining the server, sends the Mojang-private-key-signed public key; if this is missing or invalid and the server enforces secure profile using enforce-secure-profile server.properties value, players will be kicked.
  • During the key exchange, client previously encrypted a nonce using the server's public key which the server tried to verify by decrypting and comparing; while this is still the case for those without the public key, those with public key will now perform the nonce verification by client signing the nonce and server verifying it.
  • Client, when sending a chat message, will now send the Instant the message was sent at, and the RSA/SHA-1 signature composed of nonce, the player UUID, the instant, and the UTF-8 encoded message.
  • The instant value is used as part of the signed message timestamp, but also to discard messages that were delivered too late - 2 minutes in vanilla.
  • The server-side processing (including the filter) has mostly stayed the same.
  • There are new packets for S2C chat messages; "packets" (plural) - one that works like the previous GameMessageS2CPacket and is used for system messages (death, join, leave) and commands (/tellraw, /say, etc), and one for player chat messages. With this the methods for sending/broadcasting chat messages have also been changed.
  • Methods in PlayerManager and ServerPlayerEntity that sent chat messages were split into one for game message and one for chat message. The one taking ChatSender, the timestamp, and NetworkEncryptionUtils.SignatureData (from the packet) is the one for chat messages.
  • There is a new class, ChatSender, that holds the sender's UUID and username and is part of the chat message packet. You'll usually obtain this by calling player.asChatSender().
  • If you want to send an unsigned chat message, you can use NetworkEncryptionUtils.SignatureData#field_39040. Obviously this marks the message as unverifiable.
  • The sent text is unwrapped - previously the text was wrapped in chat.type.text text; now the raw text is sent. (The rendered text is constructed client-side.) This means that you can no longer configure <username> message part fully server-side unless you use the game message packet.
  • Server sends the packet as usual.
  • Client receives the packet, and checks the timestamp and the current time - if the duration between the timestamp and the current time exceeds 4 minutes, it will warn in the log (but does not reject the message). Similarly if the message signature cannot be verified it will warn in the log but does not reject the message.
  • Client uses text.getString() for verifying - which means that while stying changes do not affect the verification, if the server sends a custom text, it will always fail the verification (and can thus spam the log).
  • Final change worth mentioning, the UUID parameter in ClientChatListener#onChatMessage was replaced with ChatSender.

TL;DR:

  • S2C Chat packet split
  • Server sends the raw text, no longer wrapped in chat.type.text, client wraps it
  • sendMessage/broadcast methods changed
  • If you modify the Text the player sends as chat message, the clients will log spam (send as game message instead)

Misc changes

  • NetworkEncryptionUtils has received new methods and classes. SecureRandomUtil provides a secure random instance and SignatureData stores the signature and its nonce. New methods include updateSignature for generating the chat message signature and RSA key serialization and deserialization.
  • PacketByteBuf has received additional methods for reading/writing Either, GameProfile, and authlib Property.
  • Util#waitAndApply was added to run tasks using prepare-apply model, which is used to create SaveLoader in vanilla.
  • Exceptions can now extend TextifiedException to use Text as the exception message.
  • AbstractBlock#onStacksDropped has a new parameter, dropExperience; code that drops experience orbs when broken should check this.
  • AbstractBlockState#onStacksDropped had the same change.
  • Explosions now trigger onStacksDropped. They currently drop experience only if it originates from the player (aka flint-and-steel-lit TNT).
  • InventoryOwner#getInventory now must return SimpleInventory. InventoryOwner also has a new pickUpItem method used by allays and villagers.
  • BufferBuilder#end now returns a new class instance to be passed to various BufferRenderer methods.
  • ScreenHandler#transferSlot is now an abstract method and must be implemented. Screens without slot transfer functonality should override and return ItemStack.EMPTY.
  • Codecs now has a codec for Instant, represented using ISO format string.
  • UseAction#TOOT_HORN was added.
  • RamImpactTask is now goat-specific.
  • LevelStorage#loadSummaries now returns the sorted list.
  • Jigsaw blocks no longer create a temporary structure when generating.
@JanCantCode
Copy link

Nice to see verified what the public key private key signing stuff does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment