Skip to content

Instantly share code, notes, and snippets.

@apple502j
Last active May 20, 2022 05:31
Show Gist options
  • Save apple502j/4c15d9360f29214bc894ba93d21a9d5e to your computer and use it in GitHub Desktop.
Save apple502j/4c15d9360f29214bc894ba93d21a9d5e to your computer and use it in GitHub Desktop.

1.19-pre1 docs

Known Issues

  • Armor equipping sound plays when they shouldn't (e.g. villagers holding trades, armors getting damaged, using /item)
  • Leading slash causes commands from books to fail (MC-251890)

Changes

Note: this references Yarn names that are subject to changes before merging.

Chat & Networking

Yet another networking changes.

Most notably, ChatDecorator's signature has changed to return a CompletableFuture<Text>. Those who implement the interface should make sure the return value is CompletableFuture, e.g. by wrapping it in CompletableFuture.completedFuture. This allows the chat decorator to call external APIs without blocking the server thread.

ChatDecorator decorator = (sender, message) -> CompletableFuture.completedFuture(message.copy().formatted(Formatting.RED));

Another change worth mentioning is that the game now allows properly previewing commands - this is used by for example /msg. In this case chat decorators decorate the message argument, indicated by a new interface DecoratableArgumentType.

The game now also checks if the chat message/commands were received in order. Like the expiration check (which is moved to ServerPlayNetworkHandler from individual packets), this discards the message. This relies on the "last message timestamp" which is bound to a player's network handler, so this should not have an effect on high-traffic servers.

There are 3 interfaces related to signing in general; they all live in the net.minecraft.network.encryption package. Signer and SignatureVerifier do what they say - they sign and verify. One interface, SignatureUpdatable, is interesting; SignatureUpdatable is a functional interface that can update the signature. Its sole parameter, SignatureUpdater, is the interface responsible for updating the signature. For example,

SignatureUpdatable updatable = updater -> {
  updater.update(new bytes{1, 2, 3, 4});
}

updatable.update(signature::update);

SignatureVerifier is used to verify the signature for Mojang API-signed public keys and chat messages.

Let's wrap this up with client-side changes. ChatPreviewer was split; the previewer still handles the response, but the requesting part was moved to a new class, ChatPreviewRequester. This also means that pendingRequestQuery is gone (because the message is either sent instantly or stored as ChatPreviewer as a pending String.) - however the basics are still the same. Chat previews can also be toggled dynamically per-player by the new S2C packet ChatPreviewStateChangeS2CPacket. This is not used by vanilla but is handled by vanilla clients. Servers that use this packet will still trigger the chat preview warning screen, but toasts only show when the preview is actually requested.

And new things that may be useful:

  • ChatScreen#tryRequestPreview tries to request the chat preview. tryRequestChatPreview and tryRequestCommandPreview also exist.
  • CommandSuggestor#getNodeAt gets the node at the given cursor position, which is used for previewing multi-argument commands.
  • ServerInfo#copyFrom no longer copies the settings (e.g. custom resource pack, chat preview) - use copyWithSettingsFrom instead.
  • ProfileKeys#getSigner which returns a Signer for signing with the client's private key.
  • FilteredMessage, previously known as TextStream.Message, got new methods such as map and filteredOrElse.

ServerList changes

This is technically a networking change, but this may be interesting for other players.

The game now stores up to 16 servers connected directly in the servers.dat file, like with other servers. This is probably to save the chat preview settings even if you are connected directly. If you do not want to save the server info for some reason, you should either use NBT editing software to remove any entries with "hidden": 1b, or just delete the servers.dat file.

PacketByteBuf changes

PacketByteBuf#writeString validated the string length in bytes while readString validated it using characters - which is bad, because 1 character can take up to 3 bytes in UTF-8. This, along with some other issues, has caused several game exploits. The game now validates the string length in bytes.

Misc changes

  • Slot#setStack now triggers callbacks for equipping armor. (This causes the "gear equipped" noise.) The new method, setStackNoCallbacks, is implemented the same way as setStack but subclasses do not call callbacks. Expect changes in pre-release 2 though.
  • StructureManager can now load SNBT files under gameteststructures directory, if SharedConstants.isDevelopment is true. It is unclear whether the Fabric API adapts to this changes.
  • PlacedFeatureIndexer is a new class with the feature indexing method previously located in BiomeSource. This is also the one that threw the "feature order cycle" error. While nothing has changed implementation-wise, the refactor (and the new javadoc) should make the error easier to understand.
  • PendingTaskRunner, used in chat decorators, is now CompletableFuture-based.
  • ApiServices is a new record holding several authlib class instances such as UserCache. The instance is stored on MinecraftServer. However, the getters for individual elements still exist in that class.
  • CommandManager has a new method, executeWithPrefix, which allows slash-prefixed commands. execute method no longer accepts slash-prefixed commands. (This is also why books need prefixed commands.)
  • LargeEntitySpawnHelper can use the custom spawning requirements defined by Requirements innerclass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment