Add packet codecs across Handshake, Login, Configuration, and Play stages

This commit is contained in:
2026-09-06 21:42:13 +08:00
parent 4a9f35ffdd
commit a88888ba4d
261 files changed
+4387 -343

No files matched your search

+344 -71
View File
@@ -1,98 +1,371 @@
# libmc
A lightweight minecraft related library, such as rcon client, motd ping and more for kotlin multiplatform and java, no
dependencies in `jvm` target except `kotlin-stdlib`
native platforms required `ktor-network` and `kotlinx-io`
A lightweight minecraft client-side protocol library and related library, including `rcon client`, `motd ping`,
`nbt parser`. All module require `kotlin-stdlib`, `libmc-protocol` require `kotlin-stdlib` and `kotlinx-coroutines`
# Supported targets
- jvm 1.8
- mingwX64
- linuxArm64
- liunxX64
- JVM 1.8
- MingwX64
- LinuxArm64
- LinuxX64
- iosArm64
- iosSimulatorArm64
- macosArm64
- MacosArm64
# Get started
# libmc-protocol
[Use mcping module](https://repo.rtast.cn/packages/-/cn.rtast.libmc:mcping/)
---
[Use rconlib module](https://repo.rtast.cn/packages/-/cn.rtast.libmc:rconlib/)
# Minecraft Protocol Library Status & Roadmap
# MC Ping
## Unimplemented features
## Kotlin example
- [ ] **Online Mode Authentication & Encryption**: Full Mojang/Microsoft auth pipeline, JoinServer request, and AES-CFB8
stream cipher stream wrapper.
- [ ] **Structured `TextComponent` Parser**: Rich Chat Component AST decoder (currently falling back to raw
`NBTCompound`).
- [ ] **Command Tree Parser (0x10)**: Full binary graph decoder for brigadier nodes, argument types, and suggestions.
- [ ] **Recipe Book & Recipe Data (0x3F, 0x4A, 0x4B, 0x4C, 0x85)**: Recipe layout declarations and client-side recipe
settings.
- [ ] **Chunk & World Data (0x2D)**: Level Chunk Data with Light decoder (Bitsets, Paletted Containers, Direct/Indirect
Palettes).
- [ ] **Light Engine Update (0x30)**: Sky & Block light nibble array parser.
- [ ] **Explosion Event Decoder (0x24)**: Knockback vectors and destroyed block offsets array.
- [ ] **Debug Packets Parsing (0x1A - 0x1E)**: Debug subs, block/entity states, and game performance sample events.
- [ ] **Particle parsing**
```kotlin
fun main() {
val sm = SelectorManager(Dispatchers.IO)
// context is not required, if not passed, default context will be used
// ping java server
val response: PingResponse =
mcping(host = "org.mc-complex.com", port = 25565, type = ServerType.Java, context = LibMCContext(sm))
println(response.content)
println(response.latency)
---
// ping bedrock
val response = mcping("play.wildnetwork.net", 19132, ServerType.Bedrock)
println(response.toBedrockResponse())
}
```
## Protocol Packet Codecs Mapping
## Java example
<details>
<summary>Click to expand</summary>
```java
void main() {
// ping java server
String testJavaHost = "org.mc-complex.com";
PingResponse javaResponse = McPing.mcping(testJavaHost, 25565);
### 1. Status Stage
// ping bedrock server
String testBedrockHost = "play.wildnetwork.net";
PingResponse bedrockResponse = McPing.mcping(testBedrockHost, 19132, ServerType.Bedrock);
System.out.println(bedrockResponse.toBedrockResponse());
}
```
#### Clientbound
> java consumers should not manually pass the context parameter
- [x] `0x00` Status Response (`ClientboundStatusResponsePacket`)
- [x] `0x01` Pong Response (`ClientboundPongResponsePacket`)
## Other resources
#### Serverbound
> An example of java ping json response can be found at [ping-response-example](example/java-ping-response.json)
> (Formatted),
> a raw response of bedrock ping response can be found
> at [bedrock-pinng-raw-response](example/bedrock-pinng-raw-response.txt)
- [x] `0x00` Status Request (`ServerboundStatusRequestPacket`)
- [x] `0x01` Ping Request (`ServerboundPingRequestPacket`)
# rcon client
---
```kotlin
fun main() {
val host = "127.0.0.1"
val port = 25575
val client = rconClient(host, port)
val authed = client.connect("123456")
if (authed) println(client.command("list")) else throw IllegalArgumentException("incorrect password")
}
```
### 2. Handshake Stage
> also supports java
#### Serverbound
```java
void main() {
String host = "127.0.0.1";
int port = 25575;
String password = "123456";
RCONClient rconClient = Rconlib.rconClient(host, port);
boolean authed = rconClient.connect(password);
if (authed) {
System.out.println(rconClient.command("list"));
} else {
throw new IllegalStateException("incorrect password");
}
}
```
- [x] `0x00` Handshake (`ServerboundHandshakePacket`)
---
### 3. Login Stage
#### Clientbound
- [x] `0x00` Disconnect (`ClientboundDisconnectLoginPacket`)
- [x] `0x01` Encryption Request (`ClientboundHelloPacket`)
- [x] `0x02` Login Success (`ClientboundLoginSuccessPacket`)
- [x] `0x03` Set Compression (`ClientboundSetCompressionPacket`)
- [x] `0x04` Login Plugin Request (`ClientboundCustomQueryPacket`)
- [x] `0x05` Cookie Request (`ClientboundCookieRequestPacket`)
#### Serverbound
- [x] `0x00` Login Start (`ServerboundLoginStartPacket`)
- [x] `0x01` Encryption Response (`ServerboundKeyPacket`)
- [x] `0x02` Login Plugin Response (`ServerboundCustomQueryAnswerPacket`)
- [x] `0x03` Login Acknowledged (`ServerboundLoginAcknowledgedPacket`)
- [x] `0x04` Cookie Response (`ServerboundCookieResponsePacket`)
---
### 4. Configuration Stage
#### Clientbound
- [x] `0x00` Cookie Request (`ClientboundCookieRequestPacket`)
- [x] `0x01` Custom Payload (`ClientboundCustomPayloadPacket`)
- [x] `0x02` Disconnect (`ClientboundDisconnectConfigurationPacket`)
- [x] `0x03` Finish Configuration (`ClientboundFinishConfigurationPacket`)
- [x] `0x04` Keep Alive (`ClientboundKeepAliveConfigurationPacket`)
- [x] `0x05` Ping (`ClientboundPingConfigurationPacket`)
- [x] `0x06` Reset Chat (`ClientboundResetChatPacket`)
- [x] `0x07` Registry Data (`ClientboundRegistryDataPacket`)
- [x] `0x08` Remove Resource Pack (`ClientboundRemoveResourcePackPacket`)
- [x] `0x09` Add Resource Pack (`ClientboundAddResourcePackPacket`)
- [x] `0x0A` Store Cookie (`ClientboundStoreCookiePacket`)
- [x] `0x0B` Transfer (`ClientboundTransferPacket`)
- [x] `0x0C` Update Enabled Features (`ClientboundUpdateEnabledFeaturesPacket`)
- [x] `0x0D` Update Tags (`ClientboundUpdateTagsPacket`)
- [x] `0x0E` Select Known Packs (`ClientboundSelectKnownPacksPacket`)
- [x] `0x0F` Custom Report Details (`ClientboundCustomReportDetailsPacket`)
- [x] `0x10` Server Links (`ClientboundServerLinksPacket`)
- [x] `0x11` Clear Dialog (`ClientboundClearDialogPacket`)
- [x] `0x12` Show Dialog (`ClientboundConfigurationShowDialogPacket`)
- [x] `0x13` Code Of Conduct (`ClientboundCodeOfConductPacket`)
#### Serverbound
- [x] `0x00` Client Information (`ServerboundCookieResponsePacket`)
- [x] `0x01` Cookie Response (`ServerboundCookieResponsePacket`)
- [x] `0x02` Plugin Message (`ServerboundCustomPayloadPacket`)
- [x] `0x03` Finish Configuration Acknowledged (`ServerboundAckFinishConfigurationPacket`)
- [x] `0x04` Keep Alive Response (`ServerboundKeepAliveConfigurationPacket`)
- [x] `0x05` Pong Response (`ServerboundPongConfigurationPacket`)
- [x] `0x07` Select Known Packs (`ServerboundSelectKnownPacksPacket`)
- [x] `0x08` Custom Click Action (`ServerboundCustomClickActionPacket`)
- [x] `0x09` Accept Code Of Conduct (`ServerboundAcceptCodeOfConductPacket`)
---
### 5. Play Stage
#### Clientbound
- [x] `0x00` Delimiter (`ClientboundDelimiterPacket`)
- [x] `0x01` Spawn Entity (`ClientboundSpawnEntityPacket`)
- [x] `0x02` Entity Animation (`ClientboundEntityAnimationPacket`)
- [x] `0x03` Award Statistics (`ClientboundAwardStatisticsPacket`)
- [x] `0x04` Acknowledge Block Change (`ClientboundAcknowledgeBlockChangePacket`)
- [x] `0x05` Block Destruction (`ClientboundBlockDestructionPacket`)
- [x] `0x06` Block Entity Data (`ClientboundBlockEntityDataPacket`)
- [x] `0x07` Block Event (`ClientboundBlockEventPacket`)
- [x] `0x08` Block Update (`ClientboundBlockUpdatePacket`)
- [x] `0x09` Boss Event (`ClientboundBossEventPacket`)
- [x] `0x0A` Change Difficulty (`ClientboundChangeDifficultyPacket`)
- [x] `0x0B` Chunk Batch Finished (`ClientboundChunkBatchFinishedPacket`)
- [x] `0x0C` Chunk Batch Start (`ClientboundChunkBatchStartPacket`)
- [x] `0x0D` Chunks Biomes (`ClientboundChunksBiomesPacket`)
- [x] `0x0E` Clear Titles (`ClientboundClearTitlesPacket`)
- [x] `0x0F` Command Suggestions (`ClientboundCommandSuggestionsPacket`)
- [ ] `0x10` Commands (`ClientboundCommandsPacket`)
- [x] `0x11` Container Close (`ClientboundContainerClosePacket`)
- [x] `0x12` Container Set Content (`ClientboundContainerSetContentPacket`)
- [x] `0x13` Container Set Data (`ClientboundContainerSetDataPacket`)
- [x] `0x14` Container Set Slot (`ClientboundContainerSetSlotPacket`)
- [x] `0x15` Cookie Request (`ClientboundCookieRequestPacket`)
- [x] `0x16` Cooldown (`ClientboundCooldownPacket`)
- [x] `0x17` Custom Chat Completions (`ClientboundCustomChatCompletionsPacket`)
- [x] `0x18` Custom Payload (`ClientboundCustomPayloadPacket`)
- [x] `0x19` Damage Event (`ClientboundDamageEventPacket`)
- [ ] `0x1A` Debug Block Value (`ClientboundDebugBlockValuePacket`)
- [ ] `0x1B` Debug Chunk Value (`ClientboundDebugChunkValuePacket`)
- [ ] `0x1C` Debug Entity Value (`ClientboundDebugEntityValuePacket`)
- [ ] `0x1D` Debug Event (`ClientboundDebugEventPacket`)
- [ ] `0x1E` Debug Sample (`ClientboundDebugSamplePacket`)
- [x] `0x1F` Delete Chat (`ClientboundDeleteChatPacket`)
- [x] `0x20` Disconnect (`ClientboundDisconnectPlayPacket`)
- [x] `0x21` Disguised Chat Message (`ClientboundDisguisedChatMessagePacket`)
- [x] `0x22` Entity Event (`ClientboundEntityEventPacket`)
- [x] `0x23` Teleport Entity (`ClientboundTeleportEntityPacket`)
- [ ] `0x24` Explode (`ClientboundExplodePacket`)
- [x] `0x25` Unload Chunk (`ClientboundUnloadChunkPacket`)
- [x] `0x26` Game Event (`ClientboundGameEventPacket`)
- [x] `0x27` Game Rule Values (`ClientboundGameRuleValuesPacket`)
- [x] `0x28` Test Highlight Position (`ClientboundTestHighlightPositionPacket`)
- [x] `0x29` Open Horse Screen (`ClientboundOpenHorseScreenPacket`)
- [x] `0x2A` Hurt Animation (`ClientboundHurtAnimationPacket`)
- [x] `0x2B` Initialize World Border (`ClientboundInitializeWorldBorderPacket`)
- [x] `0x2C` Keep Alive (`ClientboundKeepAlivePlayPacket`)
- [ ] `0x2D` Level Chunk Update With Light (`ClientboundLevelChunkUpdateWithLightPacket`)
- [x] `0x2E` Level Event (`ClientboundLevelEventPacket`)
- [ ] `0x2F` Particle (`ClientboundParticlePacket`)
- [ ] `0x30` Light Update (`ClientboundLightUpdatePacket`)
- [x] `0x31` Login Play (`ClientboundLoginPlayPacket`)
- [x] `0x32` Low Disk Space Warning (`ClientboundLowDiskSpaceWarningPacket`)
- [ ] `0x33` Map Item Data (`ClientboundMapItemDataPacket`)
- [ ] `0x34` Merchant Offers (`ClientboundMerchantOffersPacket`)
- [x] `0x35` Update Entity Position (`ClientboundUpdateEntityPositionPacket`)
- [x] `0x36` Update Entity Position and Rotation (`ClientboundUpdateEntityPositionAndRotationPacket`)
- [x] `0x37` Move Minecart Along Track (`ClientboundMoveMinecartAlongTrackPacket`)
- [x] `0x38` Update Entity Rotation (`ClientboundUpdateEntityRotationPacket`)
- [x] `0x39` Move Vehicle (`ClientboundMoveVehiclePacket`)
- [x] `0x3A` Open Book (`ClientboundOpenBookPacket`)
- [x] `0x3B` Open Screen (`ClientboundOpenScreenPacket`)
- [x] `0x3C` Open Sign Editor (`ClientboundOpenSignEditorPacket`)
- [x] `0x3D` Ping (`ClientboundPingPacket`)
- [x] `0x3E` Pong Response (`ClientboundPongResponsePacket`)
- [ ] `0x3F` Place Ghost Recipe (`ClientboundPlaceGhostRecipePacket`)
- [x] `0x40` Player Abilities (`ClientboundPlayerAbilitiesPacket`)
- [x] `0x41` Player Chat Message (`ClientboundPlayerChatMessagePacket`)
- [x] `0x42` Player End Combat (`ClientboundPlayerEndCombatPacket`)
- [x] `0x43` Player Enter Combat (`ClientboundPlayerEnterCombatPacket`)
- [x] `0x44` Player Combat Death (`ClientboundPlayerCombatDeathPacket`)
- [x] `0x45` Player Info Remove (`ClientboundPlayerInfoRemovePacket`)
- [ ] `0x46` Player Info Update (`ClientboundPlayerInfoUpdatePacket`)
- [x] `0x47` Player Look At (`ClientboundPlayerLookAtPacket`)
- [x] `0x48` Synchronize Player Position (`ClientboundSynchronizePlayerPositionPacket`)
- [x] `0x49` Player Rotation (`ClientboundPlayerRotationPacket`)
- [ ] `0x4A` Recipe Book Add (`ClientboundRecipeBookAddPacket`)
- [ ] `0x4B` Recipe Book Remove (`ClientboundRecipeBookRemovePacket`)
- [ ] `0x4C` Recipe Book Settings (`ClientboundRecipeBookSettingsPacket`)
- [x] `0x4D` Remove Entities (`ClientboundRemoveEntitiesPacket`)
- [x] `0x4E` Remove Entity Effect (`ClientboundRemoveEntityEffectPacket`)
- [x] `0x4F` Reset Score (`ClientboundResetScorePacket`)
- [x] `0x50` Remove Resource Pack (`ClientboundRemoveResourcePackPacket`)
- [x] `0x51` Add Resource Pack (`ClientboundAddResourcePackPacket`)
- [x] `0x52` Respawn (`ClientboundRespawnPacket`)
- [x] `0x53` Set Head Rotation (`ClientboundSetHeadRotationPacket`)
- [x] `0x54` Update Section Block (`ClientboundUpdateSectionBlockPacket`)
- [x] `0x55` Select Advancements Tab (`ClientboundSelectAdvancementsTabPacket`)
- [x] `0x56` Server Data (`ClientboundServerDataPacket`)
- [x] `0x57` Set Action Bar Text (`ClientboundSetActionBarTextPacket`)
- [x] `0x58` Set Border Center (`ClientboundSetBorderCenterPacket`)
- [x] `0x59` Set Border Leap Size (`ClientboundSetBorderLeapSizePacket`)
- [x] `0x5A` Set Border Size (`ClientboundSetBorderSizePacket`)
- [x] `0x5B` Set Border Warning Delay (`ClientboundSetBorderWarningDelayPacket`)
- [x] `0x5C` Set Border Warning Distance (`ClientboundSetBorderWarningDistancePacket`)
- [x] `0x5D` Set Camera (`ClientboundSetCameraPacket`)
- [x] `0x5E` Set Center Chunk (`ClientboundSetCenterChunkPacket`)
- [x] `0x5F` Set Render Distance (`ClientboundSetRenderDistancePacket`)
- [x] `0x60` Set Cursor Item (`ClientboundSetCursorItemPacket`)
- [x] `0x61` Set Default Spawn Position (`ClientboundSetDefaultSpawnPositionPacket`)
- [x] `0x62` Set Display Objective (`ClientboundSetDisplayObjectivePacket`)
- [ ] `0x63` Set Entity Metadata (`ClientboundSetEntityMetadataPacket`)
- [x] `0x64` Link Entities (`ClientboundLinkEntitiesPacket`)
- [x] `0x65` Set Entity Velocity (`ClientboundSetEntityVelocityPacket`)
- [x] `0x66` Set Equipment (`ClientboundSetEquipmentPacket`)
- [x] `0x67` Set Experience (`ClientboundSetExperiencePacket`)
- [x] `0x68` Set Health (`ClientboundSetHealthPacket`)
- [x] `0x69` Set Carried Item (`ClientboundSetCarriedItemPacket`)
- [x] `0x6A` Update Objective (`ClientboundUpdateObjectivePacket`)
- [x] `0x6B` Set Passengers (`ClientboundSetPassengersPacket`)
- [x] `0x6C` Set Player Inventory Slot (`ClientboundSetPlayerInventorySlotPacket`)
- [ ] `0x6D` Set Player Team (`ClientboundSetPlayerTeamPacket`)
- [x] `0x6E` Update Score (`ClientboundUpdateScorePacket`)
- [x] `0x6F` Set Simulation Distance (`ClientboundSetSimulationDistancePacket`)
- [x] `0x70` Set Subtitle Text (`ClientboundSetSubtitleTextPacket`)
- [x] `0x71` Set Time (`ClientboundSetTimePacket`)
- [x] `0x72` Set Title Text (`ClientboundSetTitleTextPacket`)
- [x] `0x73` Set Title Animation Times (`ClientboundSetTitleAnimationTimesPacket`)
- [x] `0x74` Entity Sound Effect (`ClientboundEntitySoundEffectPacket`)
- [x] `0x75` Sound Effect (`ClientboundSoundEffectPacket`)
- [x] `0x76` Start Configuration (`ClientboundStartConfigurationPacket`)
- [x] `0x77` Stop Sound (`ClientboundStopSoundPacket`)
- [x] `0x78` Store Cookie (`ClientboundStoreCookiePacket`)
- [x] `0x79` System Chat Message (`ClientboundSystemChatMessagePacket`)
- [x] `0x7A` Set Tab List Header And Footer (`ClientboundSetTabListHeaderAndFooterPacket`)
- [x] `0x7B` Tag Query Response (`ClientboundTagQueryResponsePacket`)
- [x] `0x7C` Pickup Item (`ClientboundPickupItemPacket`)
- [x] `0x7D` Synchronize Vehicle Position (`ClientboundSynchronizeVehiclePositionPacket`)
- [x] `0x7E` Test Instance Block Status (`ClientboundTestInstanceBlockStatusPacket`)
- [x] `0x7F` Set Ticking State (`ClientboundSetTickingStatePacket`)
- [x] `0x80` Step Tick (`ClientboundStepTickPacket`)
- [x] `0x81` Transfer (`ClientboundTransferPacket`)
- [ ] `0x82` Update Advancements (`ClientboundUpdateAdvancementsPacket`)
- [x] `0x83` Update Attributes (`ClientboundUpdateAttributesPacket`)
- [x] `0x84` Entity Effect (`ClientboundEntityEffectPacket`)
- [ ] `0x85` Update Recipes (`ClientboundUpdateRecipesPacket`)
- [x] `0x86` Update Tags (`ClientboundUpdateTagsPacket`)
- [x] `0x87` Projectile Power (`ClientboundProjectilePowerPacket`)
- [x] `0x88` Custom Report Details (`ClientboundCustomReportDetailsPacket`)
- [x] `0x89` Server Links (`ClientboundServerLinksPacket`)
- [ ] `0x8A` Waypoint (`ClientboundWaypointPacket`)
- [x] `0x8B` Clear Dialog (`ClientboundClearDialogPacket`)
- [x] `0x8C` Show Dialog (`ClientboundShowDialogPacket`)
#### Serverbound
- [x] `0x00` Accept Teleportation (`ServerboundAcceptTeleportationPacket`)
- [x] `0x01` Attack Action (`ServerboundAttackActionPacket`)
- [x] `0x02` Query Block Entity Tag (`ServerboundQueryBlockEntityTagPacket`)
- [x] `0x03` Bundle Item Selected (`ServerboundBundleItemSelectedPacket`)
- [x] `0x04` Change Difficulty (`ServerboundChangeDifficultyPacket`)
- [x] `0x05` Change Game Mode (`ServerboundChangeGameModePacket`)
- [x] `0x06` Acknowledge Chat Message (`ServerboundAcknowledgeChatMessagePacket`)
- [x] `0x07` Chat Command (`ServerboundChatCommandPacket`)
- [x] `0x08` Signed Chat Command (`ServerboundSignedChatCommandPacket`)
- [x] `0x09` Chat Message (`ServerboundChatMessagePacket`)
- [x] `0x0A` Update Chat Session (`ServerboundUpdateChatSessionPacket`)
- [x] `0x0B` Chunk Batch Received (`ServerboundChunkBatchReceivedPacket`)
- [x] `0x0C` Client Command (`ServerboundClientCommandPacket`)
- [x] `0x0D` Client Tick End (`ServerboundClientTickEndPacket`)
- [x] `0x0E` Client Information (`ServerboundClientInformationPacket`)
- [x] `0x0F` Command Suggestion Request (`ServerboundCommandSuggestionRequestPacket`)
- [x] `0x10` Configuration Acknowledged (`ServerboundConfigurationAcknowledgedPacket`)
- [x] `0x11` Container Click Button (`ServerboundContainerClickButtonPacket`)
- [x] `0x12` Container Click (`ServerboundContainerClickPacket`)
- [x] `0x13` Container Close (`ServerboundContainerClosePacket`)
- [x] `0x14` Change Container Slot State (`ServerboundChangeContainerSlotStatePacket`)
- [x] `0x15` Cookie Response (`ServerboundCookieResponsePacket`)
- [x] `0x16` Custom Payload (`ServerboundCustomPayloadPacket`)
- [ ] `0x17` Debug Subscription Request (`ServerboundDebugSubscriptionRequestPacket`)
- [x] `0x18` Edit Book (`ServerboundEditBookPacket`)
- [x] `0x19` Query Entity Tag (`ServerboundQueryEntityTagPacket`)
- [x] `0x1A` Interact (`ServerboundInteractPacket`)
- [x] `0x1B` Jigsaw Generate (`ServerboundJigsawGeneratePacket`)
- [x] `0x1C` Keep Alive (`ServerboundKeepAlivePlayPacket`)
- [x] `0x1D` Lock Difficulty (`ServerboundLockDifficultyPacket`)
- [x] `0x1E` Set Player Position (`ServerboundSetPlayerPositionPacket`)
- [x] `0x1F` Set Player Position and Rotation (`ServerboundSetPlayerPositionAndRotationPacket`)
- [x] `0x20` Set Player Rotation (`ServerboundSetPlayerRotationPacket`)
- [x] `0x21` Set Player Movement Flag (`ServerboundSetPlayerMovementFlagPacket`)
- [x] `0x22` Move Vehicle (`ServerboundMoveVehiclePacket`)
- [x] `0x23` Paddle Boat (`ServerboundPaddleBoatPacket`)
- [x] `0x24` Pick Item From Block (`ServerboundPickItemFromBlockPacket`)
- [x] `0x25` Pick Item From Entity (`ServerboundPickItemFromEntityPacket`)
- [x] `0x26` Ping Request (`ServerboundPingRequestPacket`)
- [x] `0x27` Place Recipe (`ServerboundPlaceRecipePacket`)
- [x] `0x28` Player Abilities (`ServerboundPlayerAbilitiesPacket`)
- [x] `0x29` Player Action (`ServerboundPlayerActionPacket`)
- [x] `0x2A` Player Command (`ServerboundPlayerCommandPacket`)
- [x] `0x2B` Player Input (`ServerboundPlayerInputPacket`)
- [x] `0x2C` Player Loaded (`ServerboundPlayerLoadedPacket`)
- [x] `0x2D` Pong (`ServerboundPongPlayPacket`)
- [x] `0x2E` Recipe Book Change Settings (`ServerboundRecipeBookChangeSettingsPacket`)
- [x] `0x2F` Recipe Book Seen Recipe (`ServerboundRecipeBookSeenRecipePacket`)
- [x] `0x30` Rename Item (`ServerboundRenameItemPacket`)
- [x] `0x31` Resource Pack Response (`ServerboundResourcePackResponsePacket`)
- [x] `0x32` Seen Advancements (`ServerboundSeenAdvancementsPacket`)
- [x] `0x33` Select Trade (`ServerboundSelectTradePacket`)
- [x] `0x34` Set Beacon (`ServerboundSetBeaconPacket`)
- [x] `0x35` Set Carried Item (`ServerboundSetCarriedItemPacket`)
- [x] `0x36` Set Command Block (`ServerboundSetCommandBlockPacket`)
- [x] `0x37` Set Command Minecart (`ServerboundSetCommandMinecartPacket`)
- [x] `0x38` Set Creative Mode Slot (`ServerboundSetCreativeModeSlotPacket`)
- [x] `0x39` Set Game Rule (`ServerboundSetGameRulePacket`)
- [x] `0x3A` Set Jigsaw Block (`ServerboundSetJigsawBlockPacket`)
- [x] `0x3B` Set Structure Block (`ServerboundSetStructureBlockPacket`)
- [x] `0x3C` Set Test Block (`ServerboundSetTestBlockPacket`)
- [x] `0x3D` Sign Update (`ServerboundSignUpdatePacket`)
- [x] `0x3E` Spectator Action (`ServerboundSpectatorActionPacket`)
- [x] `0x3F` Swing (`ServerboundSwingPacket`)
- [x] `0x40` Teleport To Entity (`ServerboundTeleportToEntityPacket`)
- [x] `0x41` Test Instance Block Action (`ServerboundTestInstanceBlockActionPacket`)
- [x] `0x42` Use Item On (`ServerboundUseItemOnPacket`)
- [x] `0x43` Use Item (`ServerboundUseItemPacket`)
- [x] `0x44` Custom Click Action (`ServerboundCustomClickActionPacket`)
</details>
---
# libmc-mcping
A lightweight module to query Minecraft Java and Bedrock server status, MOTD, and latency
[Use mcping](https://repo.rtast.cn/packages/-/cn.rtast.libmc:mcping)
# libmc-rconlib
Send Command via rcon protocol
[Use rconlib](https://repo.rtast.cn/packages/-/cn.rtast.libmc:rconlib)
# libmc-nbt
NBT reader and writer, compat with network NBT
# libmc-snbt
> Not completed
# Open Source
@@ -21,6 +21,7 @@ public expect class BytesBuffer {
public fun writeBoolean(value: Boolean)
public fun readByte(): Byte
public fun readUByte(): UByte
public fun readShort(endian: ByteOrder = ByteOrder.BIG_ENDIAN): Short
public fun readInt(endian: ByteOrder = ByteOrder.BIG_ENDIAN): Int
public fun readLong(endian: ByteOrder = ByteOrder.BIG_ENDIAN): Long
@@ -9,18 +9,10 @@ package cn.rtast.libmc.common
public interface Encoder<in T> {
public fun encode(buffer: BytesBuffer, value: T)
public fun encodeToByteArray(value: T): ByteArray {
val buf = BytesBuffer()
encode(buf, value)
return buf.toByteArray()
}
}
public interface Decoder<out T> {
public fun decode(buffer: BytesBuffer): T
public fun decodeFromByteArray(bytes: ByteArray): T = decode(bytes.wrap())
}
public interface PacketCodec<T> : Encoder<T>, Decoder<T>
@@ -130,14 +130,6 @@ public fun BytesBuffer.writePrefixedByteArray(data: ByteArray) {
this.writeBytes(data)
}
public fun BytesBuffer.readOptionalPrefixedByteArray(): ByteArray? {
val isPresent = this.readBoolean()
return if (isPresent) {
val length = this.readVarInt()
this.readBytes(length)
} else null
}
public fun BytesBuffer.writeOptionalPrefixedByteArray(data: ByteArray?) {
if (data != null) {
this.writeBoolean(true)
@@ -146,18 +138,6 @@ public fun BytesBuffer.writeOptionalPrefixedByteArray(data: ByteArray?) {
} else this.writeBoolean(false)
}
public fun BytesBuffer.readPrefixedVarIntArray(): List<Int> {
val length = readVarInt()
val list = ArrayList<Int>(length)
repeat(length) { list.add(readVarInt()) }
return list
}
public fun BytesBuffer.writePrefixedVarIntArray(value: List<Int>) {
writeVarInt(value.size)
for (item in value) writeVarInt(item)
}
public fun BytesBuffer.readPrefixedStringArray(): List<String> {
val length = readVarInt()
val list = ArrayList<String>(length)
@@ -170,7 +150,83 @@ public fun BytesBuffer.writePrefixedStringArray(value: List<String>) {
for (item in value) writeMcString(item)
}
public inline fun <T> BytesBuffer.writePrefixedArray(value: List<T>, writeItem: BytesBuffer.(T) -> Unit) {
writeVarInt(value.size)
for (item in value) writeItem(item)
public inline fun <T> BytesBuffer.readOptional(block: BytesBuffer.() -> T): T? {
val hasData = this.readBoolean()
return if (hasData) block.invoke(this) else null
}
/**
* buffer.writeOptional(value.someValue) { writeBlockPos(it) }
*/
public inline fun <T> BytesBuffer.writeOptional(value: T?, block: BytesBuffer.(T) -> Unit) {
if (value != null) {
this.writeBoolean(true)
block.invoke(this, value)
} else this.writeBoolean(false)
}
public inline fun <T> BytesBuffer.readPrefixed(reader: BytesBuffer.() -> T): List<T> {
val count = this.readVarInt()
val list = ArrayList<T>(count)
repeat(count) { _ -> list.add(this.reader()) }
return list
}
public inline fun <T> BytesBuffer.writePrefixed(list: List<T>, writer: BytesBuffer.(T) -> Unit) {
this.writeVarInt(list.size)
for (item in list) this.writer(item)
}
public fun BytesBuffer.readBitSet(): LongArray {
val count = this.readVarInt()
return LongArray(count) { this.readLong() }
}
public fun BytesBuffer.writeBitSet(data: LongArray) {
this.writeVarInt(data.size)
for (i in data.indices) this.writeLong(data[i])
}
public fun LongArray.countSetBits(): Int {
var count = 0
for (i in indices) count += this[i].countOneBits()
return count
}
public fun LongArray.getBit(bitIndex: Int): Boolean {
val longIndex = bitIndex shr 6
if (longIndex !in this.indices) return false
val bitOffset = bitIndex and 63
return (this[longIndex] and (1L shl bitOffset)) != 0L
}
public sealed interface IdSet {
public data class Tag(val tagName: String) : IdSet
public data class Entries(val ids: List<Int>) : IdSet
}
public fun BytesBuffer.readIdSet(): IdSet {
val type = this.readVarInt()
return if (type == 0) {
IdSet.Tag(tagName = this.readMcString())
} else {
val count = type - 1
val ids = ArrayList<Int>(count)
(0 until count).forEach { _ -> ids.add(this.readVarInt()) }
IdSet.Entries(ids)
}
}
public fun BytesBuffer.writeIdSet(idSet: IdSet) {
when (idSet) {
is IdSet.Tag -> {
this.writeVarInt(0)
this.writeMcString(idSet.tagName)
}
is IdSet.Entries -> {
this.writeVarInt(idSet.ids.size + 1)
for (id in idSet.ids) this.writeVarInt(id)
}
}
}
@@ -90,6 +90,7 @@ public actual class BytesBuffer {
return array[readOffset++]
}
public actual fun readUByte(): UByte = this.readByte().toUByte()
public actual fun readShort(endian: ByteOrder): Short = readBytes(2).toShort(endian)
public actual fun readInt(endian: ByteOrder): Int = readBytes(4).toInt(endian)
public actual fun readLong(endian: ByteOrder): Long = readBytes(8).toLong(endian)
@@ -47,6 +47,7 @@ public actual class BytesBuffer {
public actual fun writeBoolean(value: Boolean): Unit = _delegateBuf.writeByte(if (value) 0x01 else 0x00)
public actual fun readByte(): Byte = _delegateBuf.readByte()
public actual fun readUByte(): UByte = this.readByte().toUByte()
public actual fun readShort(endian: ByteOrder): Short =
if (endian == ByteOrder.BIG_ENDIAN) _delegateBuf.readShort() else _delegateBuf.readShortLe()
@@ -15,7 +15,7 @@ public fun NBTInput.readStringTag(): String {
public fun NBTInput.readListTag(): NBTTag.ListTag {
val elementTypeId = readByte().toInt() and 0xFF
val elementType = NBTType.fromId(elementTypeId)
val elementType = NBTType.fromID(elementTypeId)
val length = readInt()
val list = ArrayList<NBTTag>(length)
repeat(length) { list += readTagPayload(elementType) }
@@ -28,7 +28,7 @@ public fun NBTInput.readCompoundTag(): NBTTag.CompoundTag {
val typeId = readByte().toInt() and 0xFF
if (typeId == 0) break // TAG_End
val name = readStringTag()
val type = NBTType.fromId(typeId)
val type = NBTType.fromID(typeId)
val payload = readTagPayload(type)
map[name] = payload
}
@@ -56,7 +56,7 @@ public fun NBTInput.readCompound(): NBTTag {
val map = LinkedHashMap<String, NBTTag>()
while (true) {
val typeId = readByte().toInt()
val type = NBTType.fromId(typeId)
val type = NBTType.fromID(typeId)
if (type == NBTType.End) break
val nameLen = readShort().toInt() and 0xFFFF
val nameBytes = readBytes(nameLen)
@@ -68,7 +68,7 @@ public fun NBTInput.readCompound(): NBTTag {
}
public fun NBTInput.readRootCompound(): NBTCompound {
val rootType = NBTType.fromId(readByte().toInt())
val rootType = NBTType.fromID(readByte().toInt())
require(rootType == NBTType.Compound) { "Root tag must be TAG_Compound" }
val nameLen = readShort().toInt() and 0xFFFF
val name = readBytes(nameLen).decodeToString()
@@ -77,7 +77,7 @@ public fun NBTInput.readRootCompound(): NBTCompound {
}
public fun NBTInput.readNetworkCompound(): NBTCompound {
return when (val type = NBTType.fromId(readByte().toInt() and 0xFF)) {
return when (val type = NBTType.fromID(readByte().toInt() and 0xFF)) {
NBTType.Compound -> NBTCompound("", readCompoundTag())
NBTType.String -> NBTCompound("", NBTTag.CompoundTag(linkedMapOf("text" to NBTTag.StringTag(readStringTag()))))
else -> throw UnsupportedOperationException("Unsupported network nbt tag 0x${type.id.toString(16).uppercase()}")
@@ -14,7 +14,7 @@ public enum class NBTType(public val id: Byte) {
IntArray(11), LongArray(12);
public companion object {
public fun fromId(id: Int): NBTType =
public fun fromID(id: Int): NBTType =
entries.firstOrNull { it.id.toInt() == id } ?: error("Unknown NBT type id: $id")
}
}
-2
View File
@@ -20,8 +20,6 @@ kotlin {
commonMain.dependencies {
api(project(":common"))
api(project(":nbt"))
api(libs.kotlinx.serialization.core)
api(libs.kotlinx.serialization.json)
api(libs.kotlinx.coroutines)
}
@@ -124,6 +124,15 @@ internal class InternalPacketDispatcher(private val client: MinecraftClient) {
is ClientboundEntityAnimationPacket -> {}
is ClientboundSpawnEntityPacket -> {}
is ClientboundShowDialogPacket -> {}
is ClientboundBlockEventPacket -> TODO()
is ClientboundBlockUpdatePacket -> TODO()
is ClientboundBossEventPacket -> TODO()
is ClientboundChangeDifficultyPacket -> TODO()
is ClientboundChunkBatchFinishedPacket -> TODO()
ClientboundChunkBatchStartPacket -> TODO()
is ClientboundChunksBiomesPacket -> TODO()
is ClientboundClearTitlesPacket -> TODO()
is ClientboundCommandSuggestionsPacket -> TODO()
}
}
}
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readMcString
import cn.rtast.libmc.common.writeMcString
public data class KnownPacks(val namespace: String, val id: String, val version: String) {
public companion object Codec : PacketCodec<KnownPacks> {
internal companion object Codec : PacketCodec<KnownPacks> {
override fun encode(buffer: BytesBuffer, value: KnownPacks) {
buffer.writeMcString(value.namespace)
buffer.writeMcString(value.id)
@@ -19,7 +19,7 @@ public data class ClientboundAddResourcePackPacket(
val forced: Boolean,
val prompt: NBTCompound,
) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundAddResourcePackPacket> {
internal companion object Codec : PacketCodec<ClientboundAddResourcePackPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundAddResourcePackPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundAddResourcePackPacket {
val uuid = buffer.readUuid()
@@ -12,7 +12,7 @@ import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readMcString
public data class ClientboundCodeOfConductPacket(val codeOfConduct: String) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundCodeOfConductPacket> {
internal companion object Codec : PacketCodec<ClientboundCodeOfConductPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCodeOfConductPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCodeOfConductPacket {
return ClientboundCodeOfConductPacket(buffer.readMcString())
@@ -13,7 +13,7 @@ import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundConfigurationShowDialogPacket(val dialog: NBTCompound) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundConfigurationShowDialogPacket> {
internal companion object Codec : PacketCodec<ClientboundConfigurationShowDialogPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundConfigurationShowDialogPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundConfigurationShowDialogPacket {
return ClientboundConfigurationShowDialogPacket(buffer.readNetworkNBTCompound())
@@ -13,7 +13,7 @@ import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
public data class ClientboundCookieRequestPacket(val key: Identifier) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundCookieRequestPacket> {
internal companion object Codec : PacketCodec<ClientboundCookieRequestPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCookieRequestPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCookieRequestPacket {
return ClientboundCookieRequestPacket(key = buffer.readIdentifier())
@@ -9,14 +9,15 @@ package cn.rtast.libmc.protocol.packet.configuration.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
public data class ClientboundCustomPayloadPacket(
val channel: Identifier,
val data: ByteArray,
) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundCustomPayloadPacket> {
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundCustomPayloadPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCustomPayloadPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCustomPayloadPacket {
val channel = buffer.readIdentifier()
@@ -8,13 +8,11 @@
package cn.rtast.libmc.protocol.packet.configuration.clientbound
import cn.rtast.libmc.common.*
import kotlinx.serialization.Serializable
public data class ClientboundCustomReportDetailsPacket(val details: List<ReportDetail>) :
ClientboundConfigurationPacket {
@Serializable
public data class ReportDetail(val title: String, val description: String) {
public companion object Codec : PacketCodec<ReportDetail> {
internal companion object Codec : PacketCodec<ReportDetail> {
override fun encode(buffer: BytesBuffer, value: ReportDetail) {
buffer.writeMcString(value.title)
buffer.writeMcString(value.description)
@@ -28,7 +26,7 @@ public data class ClientboundCustomReportDetailsPacket(val details: List<ReportD
}
}
public companion object Codec : PacketCodec<ClientboundCustomReportDetailsPacket> {
internal companion object Codec : PacketCodec<ClientboundCustomReportDetailsPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCustomReportDetailsPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCustomReportDetailsPacket {
val detailCount = buffer.readVarInt()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundDisconnectConfigurationPacket(val reason: NBTCompound) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundDisconnectConfigurationPacket> {
internal companion object Codec : PacketCodec<ClientboundDisconnectConfigurationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDisconnectConfigurationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDisconnectConfigurationPacket {
return ClientboundDisconnectConfigurationPacket(reason = buffer.readNetworkNBTCompound())
@@ -11,7 +11,7 @@ import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data class ClientboundKeepAliveConfigurationPacket(val id: Long) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundKeepAliveConfigurationPacket> {
internal companion object Codec : PacketCodec<ClientboundKeepAliveConfigurationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundKeepAliveConfigurationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundKeepAliveConfigurationPacket {
return ClientboundKeepAliveConfigurationPacket(buffer.readLong())
@@ -11,7 +11,7 @@ import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data class ClientboundPingConfigurationPacket(val id: Int) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundPingConfigurationPacket> {
internal companion object Codec : PacketCodec<ClientboundPingConfigurationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPingConfigurationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPingConfigurationPacket {
return ClientboundPingConfigurationPacket(id = buffer.readInt())
@@ -21,7 +21,7 @@ public data class ClientboundRegistryDataPacket(
val registryId: Identifier,
val entries: List<RegistryEntry>,
) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundRegistryDataPacket> {
internal companion object Codec : PacketCodec<ClientboundRegistryDataPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundRegistryDataPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundRegistryDataPacket {
val id = buffer.readIdentifier()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readUuid
import kotlin.uuid.Uuid
public data class ClientboundRemoveResourcePackPacket(val uuid: Uuid) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundRemoveResourcePackPacket> {
internal companion object Codec : PacketCodec<ClientboundRemoveResourcePackPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundRemoveResourcePackPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundRemoveResourcePackPacket {
val uuid = buffer.readUuid()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.packet.configuration.KnownPacks
public data class ClientboundSelectKnownPacksPacket(val knownPacks: List<KnownPacks>) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundSelectKnownPacksPacket> {
internal companion object Codec : PacketCodec<ClientboundSelectKnownPacksPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundSelectKnownPacksPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundSelectKnownPacksPacket {
val packsCount = buffer.readVarInt()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.registry.report.ServerLink
public data class ClientboundServerLinksPacket(val links: List<ServerLink>) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundServerLinksPacket> {
internal companion object Codec : PacketCodec<ClientboundServerLinksPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundServerLinksPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundServerLinksPacket {
val count = buffer.readVarInt()
@@ -20,7 +20,7 @@ public data class ClientboundStoreCookiePacket(
*/
val payload: ByteArray,
) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundStoreCookiePacket> {
internal companion object Codec : PacketCodec<ClientboundStoreCookiePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundStoreCookiePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundStoreCookiePacket {
val key = buffer.readIdentifier()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readMcString
import cn.rtast.libmc.common.readVarInt
public data class ClientboundTransferPacket(val host: String, val port: Int) : ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundTransferPacket> {
internal companion object Codec : PacketCodec<ClientboundTransferPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundTransferPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundTransferPacket {
val host = buffer.readMcString()
@@ -15,7 +15,7 @@ import cn.rtast.libmc.protocol.protocol.game.readIdentifier
public data class ClientboundUpdateEnabledFeaturesPacket(val features: List<Identifier>) :
ClientboundConfigurationPacket {
public companion object Codec : PacketCodec<ClientboundUpdateEnabledFeaturesPacket> {
internal companion object Codec : PacketCodec<ClientboundUpdateEnabledFeaturesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundUpdateEnabledFeaturesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundUpdateEnabledFeaturesPacket {
val featureCount = buffer.readVarInt()
@@ -14,12 +14,10 @@ import cn.rtast.libmc.common.writeVarInt
import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
import cn.rtast.libmc.protocol.protocol.game.writeIdentifier
import kotlinx.serialization.Serializable
public data class ClientboundUpdateTagsPacket(val registries: List<TaggedRegistry>) : ClientboundConfigurationPacket {
@Serializable
public data class TaggedRegistry(val registryId: Identifier, val tags: List<Tag>) {
public companion object Codec : PacketCodec<TaggedRegistry> {
internal companion object Codec : PacketCodec<TaggedRegistry> {
override fun encode(buffer: BytesBuffer, value: TaggedRegistry) {
buffer.writeIdentifier(value.registryId)
buffer.writeVarInt(value.tags.size)
@@ -36,9 +34,8 @@ public data class ClientboundUpdateTagsPacket(val registries: List<TaggedRegistr
}
}
@Serializable
public data class Tag(val name: Identifier, val entries: IntArray) {
public companion object Codec : PacketCodec<Tag> {
internal companion object Codec : PacketCodec<Tag> {
override fun encode(buffer: BytesBuffer, value: Tag) {
buffer.writeIdentifier(value.name)
buffer.writeVarInt(value.entries.size)
@@ -70,7 +67,7 @@ public data class ClientboundUpdateTagsPacket(val registries: List<TaggedRegistr
}
}
public companion object Codec : PacketCodec<ClientboundUpdateTagsPacket> {
internal companion object Codec : PacketCodec<ClientboundUpdateTagsPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundUpdateTagsPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundUpdateTagsPacket {
val registryCount = buffer.readVarInt()
@@ -15,7 +15,7 @@ import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.writeIdentifier
public data class ServerboundCookieResponsePacket(val key: Identifier, val payload: ByteArray?) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundCookieResponsePacket> {
internal companion object Codec : PacketCodec<ServerboundCookieResponsePacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundCookieResponsePacket) {
buffer.writeIdentifier(value.key)
if (value.payload != null) {
@@ -12,7 +12,7 @@ import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ServerboundKeepAliveConfigurationPacket(val id: Long) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundKeepAliveConfigurationPacket> {
internal companion object Codec : PacketCodec<ServerboundKeepAliveConfigurationPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundKeepAliveConfigurationPacket) {
buffer.writeLong(value.id)
}
@@ -12,7 +12,7 @@ import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ServerboundPongConfigurationPacket(val id: Int) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundPongConfigurationPacket> {
internal companion object Codec : PacketCodec<ServerboundPongConfigurationPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundPongConfigurationPacket) {
buffer.writeInt(value.id)
}
@@ -14,7 +14,7 @@ import cn.rtast.libmc.common.writeVarInt
import cn.rtast.libmc.protocol.packet.configuration.KnownPacks
public data class ServerboundSelectKnownPacksPacket(val knownPacks: List<KnownPacks>) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundSelectKnownPacksPacket> {
internal companion object Codec : PacketCodec<ServerboundSelectKnownPacksPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundSelectKnownPacksPacket) {
buffer.writeVarInt(value.knownPacks.size)
value.knownPacks.forEach { KnownPacks.encode(buffer, it) }
@@ -20,7 +20,7 @@ public data class ServerboundHandshakePacket(
val serverPort: UShort,
val intent: HandshakeIntent,
) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundHandshakePacket> {
internal companion object Codec : PacketCodec<ServerboundHandshakePacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundHandshakePacket) {
buffer.writeVarInt(value.protocolVersion)
buffer.writeMcString(value.serverAddress)
@@ -18,7 +18,7 @@ public data class ClientboundCustomQueryPacket(
val channel: Identifier,
val data: ByteArray,
) : ClientboundLoginPacket {
public companion object Codec : PacketCodec<ClientboundCustomQueryPacket> {
internal companion object Codec : PacketCodec<ClientboundCustomQueryPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCustomQueryPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCustomQueryPacket {
val messageId = buffer.readVarInt()
@@ -13,7 +13,7 @@ import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundDisconnectLoginPacket(val reason: NBTCompound) : ClientboundLoginPacket {
public companion object Codec : PacketCodec<ClientboundDisconnectLoginPacket> {
internal companion object Codec : PacketCodec<ClientboundDisconnectLoginPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDisconnectLoginPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDisconnectLoginPacket {
return ClientboundDisconnectLoginPacket(reason = buffer.readNetworkNBTCompound())
@@ -25,7 +25,7 @@ public data class ClientboundHelloPacket(
*/
val shouldAuthenticate: Boolean,
) : ClientboundLoginPacket {
public companion object Codec : PacketCodec<ClientboundHelloPacket> {
internal companion object Codec : PacketCodec<ClientboundHelloPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundHelloPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundHelloPacket {
val serverId = buffer.readMcString()
@@ -15,7 +15,7 @@ import kotlin.uuid.Uuid
public data class ClientboundLoginSuccessPacket(val gameProfile: GameProfile, val sessionId: Uuid) :
ClientboundLoginPacket {
public companion object Codec : PacketCodec<ClientboundLoginSuccessPacket> {
internal companion object Codec : PacketCodec<ClientboundLoginSuccessPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundLoginSuccessPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundLoginSuccessPacket {
val gameProfile = GameProfile.decode(buffer)
@@ -13,7 +13,7 @@ import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.common.writeVarInt
public data class ClientboundSetCompressionPacket(val threshold: Int) : ClientboundLoginPacket {
public companion object Codec : PacketCodec<ClientboundSetCompressionPacket> {
internal companion object Codec : PacketCodec<ClientboundSetCompressionPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundSetCompressionPacket) {
buffer.writeVarInt(value.threshold)
}
@@ -14,7 +14,7 @@ import cn.rtast.libmc.common.writeOptionalPrefixedByteArray
import cn.rtast.libmc.common.writeVarInt
public data class ServerboundCustomQueryAnswerPacket(val messageId: Int, val data: ByteArray?) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundCustomQueryAnswerPacket> {
internal companion object Codec : PacketCodec<ServerboundCustomQueryAnswerPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundCustomQueryAnswerPacket) {
buffer.writeVarInt(value.messageId)
buffer.writeOptionalPrefixedByteArray(value.data)
@@ -16,7 +16,7 @@ import cn.rtast.libmc.common.writePrefixedByteArray
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Encryption
*/
public data class ServerboundKeyPacket(val sharedSecret: ByteArray, val verifyToken: ByteArray) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundKeyPacket> {
internal companion object Codec : PacketCodec<ServerboundKeyPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundKeyPacket) {
buffer.writePrefixedByteArray(value.sharedSecret)
buffer.writePrefixedByteArray(value.verifyToken)
@@ -15,7 +15,7 @@ import cn.rtast.libmc.common.writeUuid
import kotlin.uuid.Uuid
public data class ServerboundLoginStartPacket(val username: String, val playerUuid: Uuid) : MinecraftPacket {
public companion object Codec : PacketCodec<ServerboundLoginStartPacket> {
internal companion object Codec : PacketCodec<ServerboundLoginStartPacket> {
override fun encode(buffer: BytesBuffer, value: ServerboundLoginStartPacket) {
buffer.writeMcString(value.username)
buffer.writeUuid(value.playerUuid)
@@ -15,7 +15,7 @@ import cn.rtast.libmc.common.readVarInt
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Packets#Acknowledge_Block_Change
*/
public data class ClientboundAcknowledgeBlockChangePacket(val sequenceId: Int) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundAcknowledgeBlockChangePacket> {
internal companion object Codec : PacketCodec<ClientboundAcknowledgeBlockChangePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundAcknowledgeBlockChangePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundAcknowledgeBlockChangePacket {
return ClientboundAcknowledgeBlockChangePacket(buffer.readVarInt())
@@ -16,7 +16,7 @@ import cn.rtast.libmc.protocol.protocol.game.StatisticsEntry
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Packets#Award_Statistics
*/
public data class ClientboundAwardStatisticsPacket(val stats: List<StatisticsEntry>) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundAwardStatisticsPacket> {
internal companion object Codec : PacketCodec<ClientboundAwardStatisticsPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundAwardStatisticsPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundAwardStatisticsPacket {
val count = buffer.readVarInt()
@@ -22,7 +22,7 @@ public data class ClientboundBlockDestructionPacket(
val location: BlockPos,
val stage: BlockDestroyStage,
) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundBlockDestructionPacket> {
internal companion object Codec : PacketCodec<ClientboundBlockDestructionPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundBlockDestructionPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundBlockDestructionPacket {
val entityId = buffer.readVarInt()
@@ -17,7 +17,7 @@ import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundBlockEntityDataPacket(val location: BlockPos, val type: Int, val data: NBTCompound) :
ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundBlockEntityDataPacket> {
internal companion object Codec : PacketCodec<ClientboundBlockEntityDataPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundBlockEntityDataPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundBlockEntityDataPacket {
val location = buffer.readBlockPos()
@@ -0,0 +1,43 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.block.BlockPos
import cn.rtast.libmc.protocol.protocol.game.block.readBlockPos
public data class ClientboundBlockEventPacket(
val location: BlockPos,
/**
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Block_actions
*/
val actionId: UByte,
/**
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Block_actions
*/
val actionParameter: UByte,
/**
* ID in the minecraft:block registry.
* This value is unused by the vanilla client,
* as it will infer the type of block based on the given position.
*/
val blockType: Int,
) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundBlockEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundBlockEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundBlockEventPacket {
val location = buffer.readBlockPos()
val actionId = buffer.readUByte()
val actionParameter = buffer.readUByte()
val blockType = buffer.readVarInt()
return ClientboundBlockEventPacket(location, actionId, actionParameter, blockType)
}
}
}
@@ -0,0 +1,25 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.block.BlockPos
import cn.rtast.libmc.protocol.protocol.game.block.readBlockPos
public data class ClientboundBlockUpdatePacket(val location: BlockPos, val blockId: Int) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundBlockUpdatePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundBlockUpdatePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundBlockUpdatePacket {
val position = buffer.readBlockPos()
val blockId = buffer.readVarInt()
return ClientboundBlockUpdatePacket(position, blockId)
}
}
}
@@ -0,0 +1,53 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readUuid
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.bossbar.BossBarAction
import cn.rtast.libmc.protocol.protocol.game.bossbar.BossBarColor
import cn.rtast.libmc.protocol.protocol.game.bossbar.BossBarDivision
import cn.rtast.libmc.protocol.protocol.game.bossbar.BossBarFlags
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
import kotlin.uuid.Uuid
public data class ClientboundBossEventPacket(val uuid: Uuid, val action: BossBarAction) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundBossEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundBossEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundBossEventPacket {
val uuid = buffer.readUuid()
val action = when (val actionId = buffer.readVarInt()) {
BossBarAction.ADD_ID -> {
val title = buffer.readNetworkNBTCompound()
val health = buffer.readFloat()
val color = BossBarColor.fromID(buffer.readVarInt())
val division = BossBarDivision.fromID(buffer.readVarInt())
val flags = BossBarFlags.fromBitmask(buffer.readByte().toInt() and 0xFF)
BossBarAction.Add(title, health, color, division, flags)
}
BossBarAction.REMOVE_ID -> BossBarAction.Remove
BossBarAction.UPDATE_TITLE_ID -> BossBarAction.UpdateTitle(buffer.readNetworkNBTCompound())
BossBarAction.UPDATE_STYLE_ID -> {
val color = BossBarColor.fromID(buffer.readVarInt())
val division = BossBarDivision.fromID(buffer.readVarInt())
BossBarAction.UpdateStyle(color, division)
}
BossBarAction.UPDATE_FLAGS_ID -> {
BossBarAction.UpdateFlags(BossBarFlags.fromBitmask(buffer.readByte().toInt() and 0xFF))
}
else -> throw IllegalArgumentException("Unknown action $actionId")
}
return ClientboundBossEventPacket(uuid, action)
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.protocol.registry.GameDifficulty
public data class ClientboundChangeDifficultyPacket(val difficulty: GameDifficulty, val locked: Boolean) :
ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundChangeDifficultyPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundChangeDifficultyPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundChangeDifficultyPacket {
val difficulty = GameDifficulty.fromID(buffer.readByte())
val locked = buffer.readBoolean()
return ClientboundChangeDifficultyPacket(difficulty, locked)
}
}
}
@@ -0,0 +1,21 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
public data class ClientboundChunkBatchFinishedPacket(val batchSize: Int) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundChunkBatchFinishedPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundChunkBatchFinishedPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundChunkBatchFinishedPacket {
return ClientboundChunkBatchFinishedPacket(buffer.readVarInt())
}
}
}
@@ -0,0 +1,17 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data object ClientboundChunkBatchStartPacket : ClientboundPlayPacket,
PacketCodec<ClientboundChunkBatchStartPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundChunkBatchStartPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundChunkBatchStartPacket = ClientboundChunkBatchStartPacket
}
@@ -0,0 +1,25 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.chunk.ChunkBiomeData
public data class ClientboundChunksBiomesPacket(val chunkBiomes: List<ChunkBiomeData>) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundChunksBiomesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundChunksBiomesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundChunksBiomesPacket {
val chunkCount = buffer.readVarInt()
val chunks = ArrayList<ChunkBiomeData>(chunkCount)
repeat(chunkCount) { chunks.add(ChunkBiomeData.decode(buffer)) }
return ClientboundChunksBiomesPacket(chunks)
}
}
}
@@ -0,0 +1,20 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data class ClientboundClearTitlesPacket(val reset: Boolean) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundClearTitlesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundClearTitlesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundClearTitlesPacket {
return ClientboundClearTitlesPacket(buffer.readBoolean())
}
}
}
@@ -0,0 +1,50 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.*
import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
import cn.rtast.libmc.protocol.protocol.util.writeNetworkNBTCompound
public data class ClientboundCommandSuggestionsPacket(
val id: Int,
val start: Int,
val length: Int,
val matches: List<CommandSuggestionMatch>,
) : ClientboundPlayPacket {
public data class CommandSuggestionMatch(val match: String, val tooltip: NBTCompound?) {
internal companion object Codec : PacketCodec<CommandSuggestionMatch> {
override fun encode(buffer: BytesBuffer, value: CommandSuggestionMatch) {
buffer.writeMcString(value.match)
buffer.writeBoolean(value.tooltip != null)
if (value.tooltip != null) buffer.writeNetworkNBTCompound(value.tooltip)
}
override fun decode(buffer: BytesBuffer): CommandSuggestionMatch {
val match = buffer.readMcString()
val hasTooltip = buffer.readBoolean()
val tooltip = if (hasTooltip) buffer.readNetworkNBTCompound() else null
return CommandSuggestionMatch(match, tooltip)
}
}
}
internal companion object Codec : PacketCodec<ClientboundCommandSuggestionsPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCommandSuggestionsPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCommandSuggestionsPacket {
val id = buffer.readVarInt()
val start = buffer.readVarInt()
val length = buffer.readVarInt()
val matchCount = buffer.readVarInt()
val matches = ArrayList<CommandSuggestionMatch>(matchCount)
repeat(matchCount) { matches.add(CommandSuggestionMatch.decode(buffer)) }
return ClientboundCommandSuggestionsPacket(id, start, length, matches)
}
}
}
@@ -0,0 +1,25 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
/**
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Packets#Close_Container
* This is the ID of the window that was closed. 0 for inventory.
*/
public data class ClientboundContainerClosePacket(val windowId: Int) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundContainerClosePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundContainerClosePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundContainerClosePacket {
return ClientboundContainerClosePacket(buffer.readVarInt())
}
}
}
@@ -0,0 +1,38 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.inventory.Slot
import cn.rtast.libmc.protocol.protocol.game.inventory.readSlot
public data class ClientboundContainerSetContentPacket(
val windowId: Int,
/**
* A server-managed sequence number used to avoid desynchronization
* see https://minecraft.wiki/w/Java_Edition_protocol/Packets#Click_Container
*/
val stateId: Int,
val slotData: List<Slot>,
val carriedItem: Slot,
) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundContainerSetContentPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundContainerSetContentPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundContainerSetContentPacket {
val windowId = buffer.readVarInt()
val stateId = buffer.readVarInt()
val slotDataCount = buffer.readVarInt()
val slotData = ArrayList<Slot>(slotDataCount)
repeat(slotDataCount) { slotData.add(buffer.readSlot()) }
val carriedItem = buffer.readSlot()
return ClientboundContainerSetContentPacket(windowId, stateId, slotData, carriedItem)
}
}
}
@@ -0,0 +1,31 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
/**
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Packets#Set_Container_Property
*/
public data class ClientboundContainerSetDataPacket(
val windowId: Int,
val property: Short,
val value: Short,
) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundContainerSetDataPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundContainerSetDataPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundContainerSetDataPacket {
val windowId = buffer.readVarInt()
val property = buffer.readShort()
val value = buffer.readShort()
return ClientboundContainerSetDataPacket(windowId, property, value)
}
}
}
@@ -0,0 +1,32 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.inventory.Slot
import cn.rtast.libmc.protocol.protocol.game.inventory.readSlot
public data class ClientboundContainerSetSlotPacket(
val windowId: Int,
val stateId: Int,
val slot: Short,
val slotData: Slot,
) : ClientboundPlayPacket {
internal companion object Codec : PacketCodec<ClientboundContainerSetSlotPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundContainerSetSlotPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundContainerSetSlotPacket {
val windowId = buffer.readVarInt()
val stateId = buffer.readVarInt()
val slot = buffer.readShort()
val slotData = buffer.readSlot()
return ClientboundContainerSetSlotPacket(windowId, stateId, slot, slotData)
}
}
}
@@ -0,0 +1,32 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
public data class ClientboundCooldownPacket(
val group: Identifier,
/**
* 0 to clear the cooldown.
*/
val ticks: Int,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundCooldownPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCooldownPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCooldownPacket {
val group = buffer.readIdentifier()
val ticks = buffer.readVarInt()
return ClientboundCooldownPacket(group, ticks)
}
}
}
@@ -0,0 +1,27 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readPrefixedStringArray
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.chat.ChatAction
public data class ClientboundCustomChatCompletionsPacket(val action: ChatAction, val entries: List<String>) :
MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundCustomChatCompletionsPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundCustomChatCompletionsPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundCustomChatCompletionsPacket {
val action = ChatAction.fromID(buffer.readVarInt())
val entries = buffer.readPrefixedStringArray()
return ClientboundCustomChatCompletionsPacket(action, entries)
}
}
}
@@ -0,0 +1,37 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.math.Vec3d
import cn.rtast.libmc.protocol.protocol.game.math.readVec3d
public data class ClientboundDamageEventPacket(
val entityId: Int,
val sourceTypeId: Int,
val sourceCauseId: Int?,
val sourceDirectId: Int?,
val position: Vec3d?,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundDamageEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDamageEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDamageEventPacket {
val entityId = buffer.readVarInt()
val sourceTypeId = buffer.readVarInt()
val rawCauseId = buffer.readVarInt()
val sourceCauseId = if (rawCauseId > 0) rawCauseId - 1 else null
val rawDirectId = buffer.readVarInt()
val sourceDirectId = if (rawDirectId > 0) rawDirectId - 1 else null
val position = buffer.readVec3d(true)
return ClientboundDamageEventPacket(entityId, sourceTypeId, sourceCauseId, sourceDirectId, position)
}
}
}
@@ -0,0 +1,43 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readOptional
import cn.rtast.libmc.common.readVarInt
public data class ClientboundDeleteChatPacket(val messageId: Int, val signature: ByteArray?) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundDeleteChatPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDeleteChatPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDeleteChatPacket {
val messageId = buffer.readVarInt()
val signature = buffer.readOptional { buffer.readBytes(256) }
return ClientboundDeleteChatPacket(messageId, signature)
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as ClientboundDeleteChatPacket
if (messageId != other.messageId) return false
if (!signature.contentEquals(other.signature)) return false
return true
}
override fun hashCode(): Int {
var result = messageId
result = 31 * result + (signature?.contentHashCode() ?: 0)
return result
}
}
@@ -13,7 +13,7 @@ import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundDisconnectPlayPacket(val reason: NBTCompound) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundDisconnectPlayPacket> {
internal companion object Codec : PacketCodec<ClientboundDisconnectPlayPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDisconnectPlayPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDisconnectPlayPacket {
return ClientboundDisconnectPlayPacket(reason = buffer.readNetworkNBTCompound())
@@ -0,0 +1,33 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.*
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.game.chat.InlineChatType
import cn.rtast.libmc.protocol.protocol.game.chat.readInlineChatType
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundDisguisedChatMessagePacket(
val message: NBTCompound,
val chatType: IdOrX<InlineChatType>,
val senderName: NBTCompound,
val targetName: NBTCompound?,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundDisguisedChatMessagePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundDisguisedChatMessagePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundDisguisedChatMessagePacket {
val message = buffer.readNetworkNBTCompound()
val chatType = buffer.readIdOrX { readInlineChatType() }
val senderName = buffer.readNetworkNBTCompound()
val targetName = buffer.readOptional { readNetworkNBTCompound() }
return ClientboundDisguisedChatMessagePacket(message, chatType, senderName, targetName)
}
}
}
@@ -17,7 +17,7 @@ import cn.rtast.libmc.protocol.protocol.game.Animations
*/
public data class ClientboundEntityAnimationPacket(val entityId: Int, val animation: Animations) :
ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundEntityAnimationPacket> {
internal companion object Codec : PacketCodec<ClientboundEntityAnimationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundEntityAnimationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundEntityAnimationPacket {
val entityId = buffer.readVarInt()
@@ -0,0 +1,38 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.effect.EntityEffectFlags
import cn.rtast.libmc.protocol.tick.ticks
import kotlin.time.Duration
public data class ClientboundEntityEffectPacket(
val entityId: Int,
val effectId: Int,
val amplifier: Int,
val durationTicks: Int,
val flags: EntityEffectFlags,
) : MinecraftPacket {
public val duration: Duration get() = if (durationTicks == -1) Duration.INFINITE else durationTicks.ticks
internal companion object Codec : PacketCodec<ClientboundEntityEffectPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundEntityEffectPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundEntityEffectPacket {
val entityId = buffer.readVarInt()
val effectId = buffer.readVarInt()
val amplifier = buffer.readVarInt()
val durationTicks = buffer.readVarInt()
val flags = EntityEffectFlags.fromByte(buffer.readByte())
return ClientboundEntityEffectPacket(entityId, effectId, amplifier, durationTicks, flags)
}
}
}
@@ -0,0 +1,30 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ClientboundEntityEventPacket(
val entityId: Int,
/**
* to get status id,
* see https://minecraft.wiki/w/Java_Edition_protocol/Entity_statuses#Entity_statuses
*/
val status: Byte,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundEntityEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundEntityEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundEntityEventPacket {
val entityId = buffer.readInt()
val status = buffer.readByte()
return ClientboundEntityEventPacket(entityId, status)
}
}
}
@@ -0,0 +1,36 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.*
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.sound.SoundCategory
import cn.rtast.libmc.protocol.protocol.game.sound.SoundEvent
import cn.rtast.libmc.protocol.protocol.game.sound.readSoundEvent
public data class ClientboundEntitySoundEffectPacket(
val soundEvent: IdOrX<SoundEvent>,
val category: SoundCategory,
val entityId: Int,
val volume: Float,
val pitch: Float,
val seed: Long,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundEntitySoundEffectPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundEntitySoundEffectPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundEntitySoundEffectPacket {
val soundEvent = buffer.readIdOrX { readSoundEvent() }
val category = SoundCategory.fromID(buffer.readVarInt())
val entityId = buffer.readVarInt()
val volume = buffer.readFloat()
val pitch = buffer.readFloat()
val seed = buffer.readLong()
return ClientboundEntitySoundEffectPacket(soundEvent, category, entityId, volume, pitch, seed)
}
}
}
@@ -0,0 +1,26 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
/**
* ref: https://minecraft.wiki/w/Java_Edition_protocol/Packets#Game_Event
*/
public data class ClientboundGameEventPacket(val event: UByte, val value: Float) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundGameEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundGameEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundGameEventPacket {
val event = buffer.readUByte()
val value = buffer.readFloat()
return ClientboundGameEventPacket(event, value)
}
}
}
@@ -0,0 +1,27 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.gamerule.GameRuleEntry
import cn.rtast.libmc.protocol.protocol.game.gamerule.readGameRule
public data class ClientboundGameRuleValuesPacket(val rules: List<GameRuleEntry>) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundGameRuleValuesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundGameRuleValuesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundGameRuleValuesPacket {
val count = buffer.readVarInt()
val rules = ArrayList<GameRuleEntry>(count)
repeat(count) { rules.add(buffer.readGameRule()) }
return ClientboundGameRuleValuesPacket(rules)
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
public data class ClientboundHurtAnimationPacket(val entityId: Int, val yaw: Float) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundHurtAnimationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundHurtAnimationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundHurtAnimationPacket {
val entityId = buffer.readVarInt()
val yaw = buffer.readFloat()
return ClientboundHurtAnimationPacket(entityId, yaw)
}
}
}
@@ -0,0 +1,45 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.common.readVarLong
public data class ClientboundInitializeWorldBorderPacket(
val centerX: Double,
val centerZ: Double,
val oldDiameter: Double,
val newDiameter: Double,
val speed: Long,
val portalTeleportBoundary: Int,
val warningBlocks: Int,
val warningTime: Int,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundInitializeWorldBorderPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundInitializeWorldBorderPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundInitializeWorldBorderPacket {
val centerX = buffer.readDouble()
val centerZ = buffer.readDouble()
val oldDiameter = buffer.readDouble()
val newDiameter = buffer.readDouble()
val speed = buffer.readVarLong()
val portalTeleportBoundary = buffer.readVarInt()
val warningBlocks = buffer.readVarInt()
val warningTime = buffer.readVarInt()
return ClientboundInitializeWorldBorderPacket(
centerX, centerZ, oldDiameter,
newDiameter, speed,
portalTeleportBoundary,
warningBlocks, warningTime
)
}
}
}
@@ -11,11 +11,8 @@ import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data class ClientboundKeepAlivePlayPacket(val id: Long) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundKeepAlivePlayPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundKeepAlivePlayPacket) {
buffer.writeLong(value.id)
}
internal companion object Codec : PacketCodec<ClientboundKeepAlivePlayPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundKeepAlivePlayPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundKeepAlivePlayPacket =
ClientboundKeepAlivePlayPacket(buffer.readLong())
}
@@ -0,0 +1,35 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.block.BlockPos
import cn.rtast.libmc.protocol.protocol.game.block.readBlockPos
public data class ClientboundLevelEventPacket(
/**
* see https://minecraft.wiki/w/Java_Edition_protocol/Packets#World_Event
*/
val eventId: Int,
val location: BlockPos,
val data: Int,
val disableRelativeVolume: Boolean,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundLevelEventPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundLevelEventPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundLevelEventPacket {
val eventId = buffer.readInt()
val location = buffer.readBlockPos()
val data = buffer.readInt()
val disableRelativeVolume = buffer.readBoolean()
return ClientboundLevelEventPacket(eventId, location, data, disableRelativeVolume)
}
}
}
@@ -0,0 +1,23 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ClientboundLinkEntitiesPacket(val attachedEntityId: Int, val holdingEntityId: Int) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundLinkEntitiesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundLinkEntitiesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundLinkEntitiesPacket {
val attachedEntityId = buffer.readInt()
val holdingEntityId = buffer.readInt()
return ClientboundLinkEntitiesPacket(attachedEntityId, holdingEntityId)
}
}
}
@@ -41,7 +41,7 @@ public data class ClientboundLoginPlayPacket(
val isOnlineMode: Boolean,
val enforceSecureChat: Boolean,
) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundLoginPlayPacket> {
internal companion object Codec : PacketCodec<ClientboundLoginPlayPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundLoginPlayPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundLoginPlayPacket {
val entityId = buffer.readInt()
@@ -57,7 +57,7 @@ public data class ClientboundLoginPlayPacket(
val dimensionType = buffer.readVarInt()
val dimensionName = buffer.readIdentifier()
val hashedSeed = buffer.readLong()
val gameMode = GameMode.fromID(buffer.readByte().toUByte())
val gameMode = GameMode.fromID(buffer.readUByte())
val previousGameMode = GameMode.fromID(buffer.readByte())
val isDebug = buffer.readBoolean()
val isFlat = buffer.readBoolean()
@@ -0,0 +1,19 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data object ClientboundLowDiskSpaceWarningPacket : MinecraftPacket,
PacketCodec<ClientboundLowDiskSpaceWarningPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundLowDiskSpaceWarningPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundLowDiskSpaceWarningPacket =
ClientboundLowDiskSpaceWarningPacket
}
@@ -0,0 +1,29 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.entity.MinecartStep
import cn.rtast.libmc.protocol.protocol.game.entity.readMinecartStep
public data class ClientboundMoveMinecartAlongTrackPacket(val entityId: Int, val steps: List<MinecartStep>) :
MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundMoveMinecartAlongTrackPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundMoveMinecartAlongTrackPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundMoveMinecartAlongTrackPacket {
val entityId = buffer.readVarInt()
val stepCount = buffer.readVarInt()
val steps = ArrayList<MinecartStep>()
repeat(stepCount) { steps.add(buffer.readMinecartStep()) }
return ClientboundMoveMinecartAlongTrackPacket(entityId, steps)
}
}
}
@@ -0,0 +1,27 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.math.Vec3d
import cn.rtast.libmc.protocol.protocol.game.math.readVec3d
public data class ClientboundMoveVehiclePacket(val position: Vec3d, val yaw: Float, val pitch: Float) :
MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundMoveVehiclePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundMoveVehiclePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundMoveVehiclePacket {
val position = buffer.readVec3d()!!
val yaw = buffer.readFloat()
val pitch = buffer.readFloat()
return ClientboundMoveVehiclePacket(position, yaw, pitch)
}
}
}
@@ -0,0 +1,23 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.player.Hand
public data class ClientboundOpenBookPacket(val hand: Hand) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundOpenBookPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundOpenBookPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundOpenBookPacket {
return ClientboundOpenBookPacket(Hand.fromID(buffer.readVarInt()))
}
}
}
@@ -0,0 +1,29 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
public data class ClientboundOpenHorseScreenPacket(
val windowId: Int,
val columnsCount: Int,
val entityId: Int,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundOpenHorseScreenPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundOpenHorseScreenPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundOpenHorseScreenPacket {
val windowId = buffer.readVarInt()
val columnsCount = buffer.readVarInt()
val entityId = buffer.readInt()
return ClientboundOpenHorseScreenPacket(windowId, columnsCount, entityId)
}
}
}
@@ -0,0 +1,31 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundOpenScreenPacket(
val windowId: Int,
val windowType: Int,
val title: NBTCompound,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundOpenScreenPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundOpenScreenPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundOpenScreenPacket {
val windowId = buffer.readVarInt()
val windowType = buffer.readVarInt()
val title = buffer.readNetworkNBTCompound()
return ClientboundOpenScreenPacket(windowId, windowType, title)
}
}
}
@@ -0,0 +1,25 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.block.BlockPos
import cn.rtast.libmc.protocol.protocol.game.block.readBlockPos
public data class ClientboundOpenSignEditorPacket(val location: BlockPos, val isFrontText: Boolean) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundOpenSignEditorPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundOpenSignEditorPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundOpenSignEditorPacket {
val location = buffer.readBlockPos()
val isFrontText = buffer.readBoolean()
return ClientboundOpenSignEditorPacket(location, isFrontText)
}
}
}
@@ -0,0 +1,32 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
public data class ClientboundPickupItemPacket(
val collectedEntityId: Int,
val collectorEntityId: Int,
/**
* Seems to be 1 for XP orbs, otherwise the number of items in the stack.
*/
val itemCount: Int,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPickupItemPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPickupItemPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPickupItemPacket {
val collectedEntityId = buffer.readVarInt()
val collectorEntityId = buffer.readVarInt()
val itemCount = buffer.readVarInt()
return ClientboundPickupItemPacket(collectedEntityId, collectorEntityId, itemCount)
}
}
}
@@ -11,7 +11,7 @@ import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
public data class ClientboundPingPacket(val id: Int) : ClientboundPlayPacket {
public companion object Codec : PacketCodec<ClientboundPingPacket> {
internal companion object Codec : PacketCodec<ClientboundPingPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPingPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPingPacket {
return ClientboundPingPacket(id = buffer.readInt())
@@ -9,4 +9,7 @@ package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.packet.MinecraftPacket
/**
* mark a packet that is used when join to the server
*/
public sealed interface ClientboundPlayPacket : MinecraftPacket
@@ -0,0 +1,29 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.protocol.protocol.game.player.PlayerAbilities
public data class ClientboundPlayerAbilitiesPacket(
val flags: PlayerAbilities,
val flyingSpeed: Float,
val fovModifier: Float,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPlayerAbilitiesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerAbilitiesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerAbilitiesPacket {
val flag = PlayerAbilities.fromByte(buffer.readByte())
val flyingSpeed = buffer.readFloat()
val fovModifier = buffer.readFloat()
return ClientboundPlayerAbilitiesPacket(flag, flyingSpeed, fovModifier)
}
}
}
@@ -36,14 +36,14 @@ public data class ClientboundPlayerChatMessagePacket(
FULLY_FILTERED(1),
PARTIALLY_FILTERED(2);
public companion object {
public fun fromId(id: Int): ChatFilterType =
internal companion object {
fun fromID(id: Int): ChatFilterType =
entries.firstOrNull { it.id == id } ?: PASS_THROUGH
}
}
public data class PreviousMessageEntry(val messageId: Int, val signature: ByteArray?) {
public companion object Codec : PacketCodec<PreviousMessageEntry> {
internal companion object Codec : PacketCodec<PreviousMessageEntry> {
override fun encode(buffer: BytesBuffer, value: PreviousMessageEntry) {}
override fun decode(buffer: BytesBuffer): PreviousMessageEntry {
val messageId = buffer.readVarInt()
@@ -68,7 +68,7 @@ public data class ClientboundPlayerChatMessagePacket(
}
}
public companion object Codec : PacketCodec<ClientboundPlayerChatMessagePacket> {
internal companion object Codec : PacketCodec<ClientboundPlayerChatMessagePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerChatMessagePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerChatMessagePacket {
val globalIndex = buffer.readVarInt()
@@ -88,7 +88,7 @@ public data class ClientboundPlayerChatMessagePacket(
val unsignedContent = if (hasUnsignedContent) buffer.readNetworkNBTCompound() else null // ?
val filterTypeId = buffer.readVarInt()
val filterType = ChatFilterType.fromId(filterTypeId)
val filterType = ChatFilterType.fromID(filterTypeId)
val filterMaskBits = if (filterType == ChatFilterType.PARTIALLY_FILTERED) {
val bitSetLen = buffer.readVarInt()
@@ -0,0 +1,26 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.nbt.NBTCompound
import cn.rtast.libmc.protocol.protocol.util.readNetworkNBTCompound
public data class ClientboundPlayerCombatDeathPacket(val playerId: Int, val message: NBTCompound) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPlayerCombatDeathPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerCombatDeathPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerCombatDeathPacket {
val playerId = buffer.readVarInt()
val message = buffer.readNetworkNBTCompound()
return ClientboundPlayerCombatDeathPacket(playerId, message)
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.tick.ticks
import kotlin.time.Duration
public data class ClientboundPlayerEndCombatPacket(val duration: Duration) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPlayerEndCombatPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerEndCombatPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerEndCombatPacket {
return ClientboundPlayerEndCombatPacket(buffer.readVarInt().ticks) // convert int to minecraft ticks
}
}
}
@@ -0,0 +1,18 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data object ClientboundPlayerEnterCombatPacket : MinecraftPacket,
PacketCodec<ClientboundPlayerEnterCombatPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerEnterCombatPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerEnterCombatPacket = ClientboundPlayerEnterCombatPacket
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readPrefixed
import cn.rtast.libmc.common.readUuid
import kotlin.uuid.Uuid
public data class ClientboundPlayerInfoRemovePacket(val uuids: List<Uuid>) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPlayerInfoRemovePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerInfoRemovePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerInfoRemovePacket {
return ClientboundPlayerInfoRemovePacket(buffer.readPrefixed { readUuid() })
}
}
}
@@ -0,0 +1,46 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.math.Vec3d
import cn.rtast.libmc.protocol.protocol.game.math.readVec3d
import cn.rtast.libmc.protocol.protocol.game.player.AnchorPoint
public data class ClientboundPlayerLookAtPacket(
val fromAnchor: AnchorPoint,
val targetPosition: Vec3d,
val entityTarget: EntityLookAtTarget?,
) : MinecraftPacket {
public data class EntityLookAtTarget(
val entityId: Int,
val entityAnchor: AnchorPoint,
)
internal companion object Codec : PacketCodec<ClientboundPlayerLookAtPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerLookAtPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerLookAtPacket {
val fromAnchor = AnchorPoint.fromID(buffer.readVarInt())
val targetPosition = buffer.readVec3d()!!
val isEntity = buffer.readBoolean()
val entityTarget = if (isEntity) {
val entityId = buffer.readVarInt()
val entityAnchor = AnchorPoint.fromID(buffer.readVarInt())
EntityLookAtTarget(entityId, entityAnchor)
} else null
return ClientboundPlayerLookAtPacket(
fromAnchor = fromAnchor,
targetPosition = targetPosition,
entityTarget = entityTarget
)
}
}
}
@@ -0,0 +1,30 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ClientboundPlayerRotationPacket(
val yaw: Float,
val relativeYaw: Boolean,
val pitch: Float,
val relativePitch: Boolean,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundPlayerRotationPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundPlayerRotationPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundPlayerRotationPacket {
val yaw = buffer.readFloat()
val relativeYaw = buffer.readBoolean()
val pitch = buffer.readFloat()
val relativePitch = buffer.readBoolean()
return ClientboundPlayerRotationPacket(yaw, relativeYaw, pitch, relativePitch)
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
public data class ClientboundProjectilePowerPacket(val entityId: Int, val power: Double) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundProjectilePowerPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundProjectilePowerPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundProjectilePowerPacket {
val entityId = buffer.readVarInt()
val power = buffer.readDouble()
return ClientboundProjectilePowerPacket(entityId, power)
}
}
}
@@ -0,0 +1,23 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readPrefixed
import cn.rtast.libmc.common.readVarInt
public data class ClientboundRemoveEntitiesPacket(val entityIds: List<Int>): MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundRemoveEntitiesPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundRemoveEntitiesPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundRemoveEntitiesPacket {
return ClientboundRemoveEntitiesPacket(buffer.readPrefixed { readVarInt() })
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readVarInt
public data class ClientboundRemoveEntityEffectPacket(val entityId: Int, val effectId: Int) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundRemoveEntityEffectPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundRemoveEntityEffectPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundRemoveEntityEffectPacket {
val entityId = buffer.readVarInt()
val effectId = buffer.readVarInt()
return ClientboundRemoveEntityEffectPacket(entityId, effectId)
}
}
}
@@ -0,0 +1,22 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.*
import cn.rtast.libmc.common.packet.MinecraftPacket
public data class ClientboundResetScorePacket(val entityName: String, val objectiveName: String?) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundResetScorePacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundResetScorePacket) {}
override fun decode(buffer: BytesBuffer): ClientboundResetScorePacket {
val entityName = buffer.readMcString()
val objectiveName = buffer.readPrefixed { readOptional { readMcString() } }.first() // ?
return ClientboundResetScorePacket(entityName, objectiveName)
}
}
}
@@ -0,0 +1,62 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readOptional
import cn.rtast.libmc.common.readVarInt
import cn.rtast.libmc.protocol.protocol.game.GameMode
import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.block.BlockPos
import cn.rtast.libmc.protocol.protocol.game.block.readBlockPos
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
import cn.rtast.libmc.protocol.protocol.game.world.RespawnDataToKeep
public data class ClientboundRespawnPacket(
val dimensionType: Int,
val dimensionName: Identifier,
val hashedSeed: Long,
val gameMode: GameMode,
val previousGameMode: GameMode,
val isDebug: Boolean,
val isFlat: Boolean,
val hasDeathLocation: Boolean,
val deathDimensionName: Identifier?,
val deathLocation: BlockPos?,
val portalCooldown: Int,
val seaLevel: Int,
val dataKept: RespawnDataToKeep,
) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundRespawnPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundRespawnPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundRespawnPacket {
val dimensionType = buffer.readVarInt()
val dimensionName = buffer.readIdentifier()
val hashedSeed = buffer.readLong()
val gameMode = GameMode.fromID(buffer.readUByte())
val previousGameMode = GameMode.fromID(buffer.readByte())
val isDebug = buffer.readBoolean()
val isFlat = buffer.readBoolean()
val hasDeathLocation = buffer.readBoolean()
val deathDimensionName = buffer.readOptional { readIdentifier() }
val deathLocation = buffer.readOptional { readBlockPos() }
val portalCooldown = buffer.readVarInt()
val seaLevel = buffer.readVarInt()
val dataKept = RespawnDataToKeep.fromByte(buffer.readByte())
return ClientboundRespawnPacket(
dimensionType, dimensionName, hashedSeed,
gameMode, previousGameMode, isDebug,
isFlat, hasDeathLocation,
deathDimensionName, deathLocation,
portalCooldown, seaLevel, dataKept
)
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright © 2026 RTAkland
* Author: RTAkland
* Date: 2026/9/6
*/
package cn.rtast.libmc.protocol.packet.play.clientbound
import cn.rtast.libmc.common.BytesBuffer
import cn.rtast.libmc.common.PacketCodec
import cn.rtast.libmc.common.packet.MinecraftPacket
import cn.rtast.libmc.common.readOptional
import cn.rtast.libmc.protocol.protocol.game.Identifier
import cn.rtast.libmc.protocol.protocol.game.readIdentifier
public data class ClientboundSelectAdvancementsTabPacket(val tabId: Identifier?) : MinecraftPacket {
internal companion object Codec : PacketCodec<ClientboundSelectAdvancementsTabPacket> {
override fun encode(buffer: BytesBuffer, value: ClientboundSelectAdvancementsTabPacket) {}
override fun decode(buffer: BytesBuffer): ClientboundSelectAdvancementsTabPacket {
return ClientboundSelectAdvancementsTabPacket(buffer.readOptional { readIdentifier() })
}
}
}
Loaded 100 of 261 files, more files were not shown because too many files have changed in this diff. Show more