diff --git a/docs/astro/src/content/docs/docs/developing-plugins/network/packets.md b/docs/astro/src/content/docs/docs/developing-plugins/network/packets.md index e33e009b..536b4522 100644 --- a/docs/astro/src/content/docs/docs/developing-plugins/network/packets.md +++ b/docs/astro/src/content/docs/docs/developing-plugins/network/packets.md @@ -58,6 +58,17 @@ public class SetHeldItemClientboundPacket : IMinecraftClientboundPacket(PacketIdDefinitions.ClientboundSetHeldItem); +} +``` + +You can also define your own mappings for packets you'd like to work with: ```csharp [Subscribe] public void OnPlayerJoinedServer(PlayerJoinedServerEvent @event) @@ -132,7 +143,7 @@ await player.SendPacketAsync(new SetHeldItemClientboundPacket { Slot = slot }, c ### Sending Packets to the Server You can send packets to the server with `ILink.ServerChannel` instance. ```csharp -await player.GetLink().ServerChannel.SendPacketAsync(new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); +await player.Link.ServerChannel.SendPacketAsync(new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); ``` ### Sending Packets to the [**`ILink`**](/docs/developing-plugins/network/links) @@ -143,12 +154,12 @@ You can send packets to the link with `ILink.SendPacketAsync` method. - If the packet has both interfaces, it will be sent only to the client. - If the packet has neither interface, `InvalidOperationException` will be thrown. ```csharp -await player.GetLink().SendPacketAsync(new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); +await player.Link.SendPacketAsync(new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); ``` When you want to explicitly send a packet to the server or client, `SendPacketAsync` has an overload that specifies the destination side. ```csharp -await player.GetLink().SendPacketAsync(Side.Client, new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); +await player.Link.SendPacketAsync(Side.Client, new SetHeldItemClientboundPacket { Slot = slot }, cancellationToken); ``` ## Complete Example diff --git a/docs/astro/src/content/docs/docs/developing-plugins/network/transformations.md b/docs/astro/src/content/docs/docs/developing-plugins/network/transformations.md index a86879a7..972c0536 100644 --- a/docs/astro/src/content/docs/docs/developing-plugins/network/transformations.md +++ b/docs/astro/src/content/docs/docs/developing-plugins/network/transformations.md @@ -134,10 +134,12 @@ public void OnPhaseChanged(PhaseChangedEvent @event) new(0x51, ProtocolVersion.MINECRAFT_1_20_3), new(0x53, ProtocolVersion.MINECRAFT_1_20_5), new(0x63, ProtocolVersion.MINECRAFT_1_21_2), - new(0x62, ProtocolVersion.MINECRAFT_1_21_5) + new(0x62, ProtocolVersion.MINECRAFT_1_21_5), + new(0x67, ProtocolVersion.MINECRAFT_1_21_9) ]); - @event.Player.RegisterTransformations(Transformations); + // Register transformations for the channel that changed phase + @event.Player.RegisterTransformations(@event.Channel, Transformations); } ```