Skip to content

Instantly share code, notes, and snippets.

@apple502j
Created May 5, 2022 17:47
Show Gist options
  • Save apple502j/02b1c8fdad72d0b3b86d708f24bc0d29 to your computer and use it in GitHub Desktop.
Save apple502j/02b1c8fdad72d0b3b86d708f24bc0d29 to your computer and use it in GitHub Desktop.
22w18a docs

22w18a docs

Known Bugs

Changes

More Chat Refactor

The big chat refactor continues; this time, they introduced "signed command arguments". This is used by MessageArgumentType and TextArgumentType. The client parses the commands and signs each argument. (see ArgumentSignatures) This also means the packets for commands are now separate from the chat message packet. (see CommandExecutionC2SPacket) Note that you can still use ClientPlayerEntity#sendChatMessage(String) with /-prefixed string to execute commands.

New classes:

  • ChatMessageSignature is the signature for chat messages, containing the UUID, timestamp, and NetworkEncryptionUtils.SignatureData. The none static method returns the bogus signature - use this instead of NetworkEncryptionUtils.SignatureData#NONE. updateSignature method signs the message.
  • SignedChatMessage contains the chat message text and the signature. (This is used in PlayerManager#broadcast, etc.)
  • ChatSigner signs the chat message. (the actual logic is in ChatMessageSignature)
  • CommandArgumentSigner signs the commands.

Decoration and MessageType

To allow custom message texts without breaking signatures, Mojang has introduced custom message types that server sends to clients. They are DRM-managed and defined in data/(namespace)/chat_type in the data packs. The message type contains "chat", "overlay", and "narration" fields, and are interpreted client-side.

The Display for the "chat" and "overlay" and Narration for the "narration" contain the "decoration" field, which specifies the decorations applied to the message. Decoration consists of the translation key, parameters of the translation (can be chosen from sender name, message content, and the team name only for /teammsg), and the style.

Message type can also control the "priority" of the narration. Currently there are only two types - chat and system, where system message narrations interrupt chat message narrations. (Note that this is also used to check if it should narrate in the first place when Narrator option is set to "narrate chat/narrate system".)

Misc changes

  • GameEvent got a new inner class, Info, that contains information about the event (like the emitted event and the emitter).
  • Banner patterns are no longer enums and instead use registry, making custom patterns way easier. The patterns that appear on Loom (the block, not build script) can be controlled by tags.
  • Similarly, goat horn instruments are registry-controlled now.
  • RegistryKeyArgumentType contains new static methods for use with the new /place command.
  • PacketByteBuf: new methods readNullable and writeNullable. Also, BiFunction passed to writers are replaced with PacketByteBuf.PacketWriter and Function passed to readers are replaced with PacketByteBuf.PacketReader, but this only impacts those who extend the interface (like in Java 7) instead of using functional interfaces.
  • asChatSender now exists in Entity rather than PlayerEntity. Again, recompile should be enough.
  • ChatMessageSender record now contains the teamName field. To set the team name use withTeamName.
  • Server resource pack handling has changed, but I haven't reviewed it yet. One thing to note is that resource-pack-hash server property is obsoleted and they should switch to resource-pack-sha1. Not providing the SHA1 hash will also lead to a console warning.
  • ServerCommandSource: isExecutedByPlayer, getChatMessageSender, getSigner (returns the argument signer), and withSigner added.
  • Style now has a codec and the of method that takes Optional instead of nullable constructor. TextColor and Formatting also received codecs.
  • Identifier#of allows constructing an identifier from the namespace and the path, but unlike the constructor it returns null when the arguments are invalid, instead of throwing.
  • JsonHelper got new methods that stringify the JSON object with sorted keys.
  • StringHelper#truncateChat truncates the passed message to at most 256 characters with no ellipsis. This is used by chat.
  • Util#lastIndexGetter is a reinvented wheel that returns value -> Math.max(0, values.lastIndexOf(value)).
  • Uncaught SleepRequiredError: apple502j needs some sleep at ChangelogWriter.java @ 247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment