Files
libmc/README.md
T

19 KiB

libmc

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
  • LinuxX64
  • MacosArm64

libmc-protocol

Use libmc-protocol


Minecraft Protocol Library Status & Roadmap

Implementation details

  • Online Mode Authentication & Encryption: See Implement Encryption
  • Structured TextComponent Parser: TextComponent AST decoder (Some packets fallback 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
  • Slot Data Parsing

Protocol Packet Codecs Mapping

Click to expand

1. Status Stage

Clientbound

  • 0x00 Status Response (ClientboundStatusResponsePacket)
  • 0x01 Pong Response (ClientboundPongResponsePacket)

Serverbound

  • 0x00 Status Request (ServerboundStatusRequestPacket)
  • 0x01 Ping Request (ServerboundPingRequestPacket)

2. Handshake Stage

Serverbound

  • 0x00 Handshake (ServerboundHandshakePacket)

3. Login Stage

Clientbound

  • 0x00 Disconnect (ClientboundDisconnectLoginPacket)
  • 0x01 Encryption Request (ClientboundHelloPacket)
  • 0x02 Login Success (ClientboundLoginSuccessPacket)
  • 0x03 Set Compression (ClientboundSetCompressionPacket)
  • 0x04 Login Plugin Request (ClientboundCustomQueryPacket)
  • 0x05 Cookie Request (ClientboundCookieRequestPacket)

Serverbound

  • 0x00 Login Start (ServerboundLoginStartPacket)
  • 0x01 Encryption Response (ServerboundKeyPacket)
  • 0x02 Login Plugin Response (ServerboundCustomQueryAnswerPacket)
  • 0x03 Login Acknowledged (ServerboundLoginAcknowledgedPacket)
  • 0x04 Cookie Response (ServerboundCookieResponsePacket)

4. Configuration Stage

Clientbound

  • 0x00 Cookie Request (ClientboundCookieRequestPacket)
  • 0x01 Custom Payload (ClientboundCustomPayloadPacket)
  • 0x02 Disconnect (ClientboundDisconnectConfigurationPacket)
  • 0x03 Finish Configuration (ClientboundFinishConfigurationPacket)
  • 0x04 Keep Alive (ClientboundKeepAliveConfigurationPacket)
  • 0x05 Ping (ClientboundPingConfigurationPacket)
  • 0x06 Reset Chat (ClientboundResetChatPacket)
  • 0x07 Registry Data (ClientboundRegistryDataPacket)
  • 0x08 Remove Resource Pack (ClientboundRemoveResourcePackPacket)
  • 0x09 Add Resource Pack (ClientboundAddResourcePackPacket)
  • 0x0A Store Cookie (ClientboundStoreCookiePacket)
  • 0x0B Transfer (ClientboundTransferPacket)
  • 0x0C Update Enabled Features (ClientboundUpdateEnabledFeaturesPacket)
  • 0x0D Update Tags (ClientboundUpdateTagsPacket)
  • 0x0E Select Known Packs (ClientboundSelectKnownPacksPacket)
  • 0x0F Custom Report Details (ClientboundCustomReportDetailsPacket)
  • 0x10 Server Links (ClientboundServerLinksPacket)
  • 0x11 Clear Dialog (ClientboundClearDialogPacket)
  • 0x12 Show Dialog (ClientboundConfigurationShowDialogPacket)
  • 0x13 Code Of Conduct (ClientboundCodeOfConductPacket)

Serverbound

  • 0x00 Client Information (ServerboundCookieResponsePacket)
  • 0x01 Cookie Response (ServerboundCookieResponsePacket)
  • 0x02 Plugin Message (ServerboundCustomPayloadPacket)
  • 0x03 Finish Configuration Acknowledged (ServerboundAckFinishConfigurationPacket)
  • 0x04 Keep Alive Response (ServerboundKeepAliveConfigurationPacket)
  • 0x05 Pong Response (ServerboundPongConfigurationPacket)
  • 0x07 Select Known Packs (ServerboundSelectKnownPacksPacket)
  • 0x08 Custom Click Action (ServerboundCustomClickActionPacket)
  • 0x09 Accept Code Of Conduct (ServerboundAcceptCodeOfConductPacket)

5. Play Stage

Clientbound

  • 0x00 Delimiter (ClientboundDelimiterPacket)
  • 0x01 Spawn Entity (ClientboundSpawnEntityPacket)
  • 0x02 Entity Animation (ClientboundEntityAnimationPacket)
  • 0x03 Award Statistics (ClientboundAwardStatisticsPacket)
  • 0x04 Acknowledge Block Change (ClientboundAcknowledgeBlockChangePacket)
  • 0x05 Block Destruction (ClientboundBlockDestructionPacket)
  • 0x06 Block Entity Data (ClientboundBlockEntityDataPacket)
  • 0x07 Block Event (ClientboundBlockEventPacket)
  • 0x08 Block Update (ClientboundBlockUpdatePacket)
  • 0x09 Boss Event (ClientboundBossEventPacket)
  • 0x0A Change Difficulty (ClientboundChangeDifficultyPacket)
  • 0x0B Chunk Batch Finished (ClientboundChunkBatchFinishedPacket)
  • 0x0C Chunk Batch Start (ClientboundChunkBatchStartPacket)
  • 0x0D Chunks Biomes (ClientboundChunksBiomesPacket)
  • 0x0E Clear Titles (ClientboundClearTitlesPacket)
  • 0x0F Command Suggestions (ClientboundCommandSuggestionsPacket)
  • 0x10 Commands (ClientboundCommandsPacket)
  • 0x11 Container Close (ClientboundContainerClosePacket)
  • 0x12 Container Set Content (ClientboundContainerSetContentPacket)
  • 0x13 Container Set Data (ClientboundContainerSetDataPacket)
  • 0x14 Container Set Slot (ClientboundContainerSetSlotPacket)
  • 0x15 Cookie Request (ClientboundCookieRequestPacket)
  • 0x16 Cooldown (ClientboundCooldownPacket)
  • 0x17 Custom Chat Completions (ClientboundCustomChatCompletionsPacket)
  • 0x18 Custom Payload (ClientboundCustomPayloadPacket)
  • 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)
  • 0x1F Delete Chat (ClientboundDeleteChatPacket)
  • 0x20 Disconnect (ClientboundDisconnectPlayPacket)
  • 0x21 Disguised Chat Message (ClientboundDisguisedChatMessagePacket)
  • 0x22 Entity Event (ClientboundEntityEventPacket)
  • 0x23 Teleport Entity (ClientboundTeleportEntityPacket)
  • 0x24 Explode (ClientboundExplodePacket)
  • 0x25 Unload Chunk (ClientboundUnloadChunkPacket)
  • 0x26 Game Event (ClientboundGameEventPacket)
  • 0x27 Game Rule Values (ClientboundGameRuleValuesPacket)
  • 0x28 Test Highlight Position (ClientboundTestHighlightPositionPacket)
  • 0x29 Open Horse Screen (ClientboundOpenHorseScreenPacket)
  • 0x2A Hurt Animation (ClientboundHurtAnimationPacket)
  • 0x2B Initialize World Border (ClientboundInitializeWorldBorderPacket)
  • 0x2C Keep Alive (ClientboundKeepAlivePlayPacket)
  • 0x2D Level Chunk Update With Light (ClientboundLevelChunkUpdateWithLightPacket)
  • 0x2E Level Event (ClientboundLevelEventPacket)
  • 0x2F Particle (ClientboundParticlePacket)
  • 0x30 Light Update (ClientboundLightUpdatePacket)
  • 0x31 Login Play (ClientboundLoginPlayPacket)
  • 0x32 Low Disk Space Warning (ClientboundLowDiskSpaceWarningPacket)
  • 0x33 Map Item Data (ClientboundMapItemDataPacket)
  • 0x34 Merchant Offers (ClientboundMerchantOffersPacket)
  • 0x35 Update Entity Position (ClientboundUpdateEntityPositionPacket)
  • 0x36 Update Entity Position and Rotation (ClientboundUpdateEntityPositionAndRotationPacket)
  • 0x37 Move Minecart Along Track (ClientboundMoveMinecartAlongTrackPacket)
  • 0x38 Update Entity Rotation (ClientboundUpdateEntityRotationPacket)
  • 0x39 Move Vehicle (ClientboundMoveVehiclePacket)
  • 0x3A Open Book (ClientboundOpenBookPacket)
  • 0x3B Open Screen (ClientboundOpenScreenPacket)
  • 0x3C Open Sign Editor (ClientboundOpenSignEditorPacket)
  • 0x3D Ping (ClientboundPingPacket)
  • 0x3E Pong Response (ClientboundPongResponsePacket)
  • 0x3F Place Ghost Recipe (ClientboundPlaceGhostRecipePacket)
  • 0x40 Player Abilities (ClientboundPlayerAbilitiesPacket)
  • 0x41 Player Chat Message (ClientboundPlayerChatMessagePacket)
  • 0x42 Player End Combat (ClientboundPlayerEndCombatPacket)
  • 0x43 Player Enter Combat (ClientboundPlayerEnterCombatPacket)
  • 0x44 Player Combat Death (ClientboundPlayerCombatDeathPacket)
  • 0x45 Player Info Remove (ClientboundPlayerInfoRemovePacket)
  • 0x46 Player Info Update (ClientboundPlayerInfoUpdatePacket)
  • 0x47 Player Look At (ClientboundPlayerLookAtPacket)
  • 0x48 Synchronize Player Position (ClientboundSynchronizePlayerPositionPacket)
  • 0x49 Player Rotation (ClientboundPlayerRotationPacket)
  • 0x4A Recipe Book Add (ClientboundRecipeBookAddPacket)
  • 0x4B Recipe Book Remove (ClientboundRecipeBookRemovePacket)
  • 0x4C Recipe Book Settings (ClientboundRecipeBookSettingsPacket)
  • 0x4D Remove Entities (ClientboundRemoveEntitiesPacket)
  • 0x4E Remove Entity Effect (ClientboundRemoveEntityEffectPacket)
  • 0x4F Reset Score (ClientboundResetScorePacket)
  • 0x50 Remove Resource Pack (ClientboundRemoveResourcePackPacket)
  • 0x51 Add Resource Pack (ClientboundAddResourcePackPacket)
  • 0x52 Respawn (ClientboundRespawnPacket)
  • 0x53 Set Head Rotation (ClientboundSetHeadRotationPacket)
  • 0x54 Update Section Block (ClientboundUpdateSectionBlockPacket)
  • 0x55 Select Advancements Tab (ClientboundSelectAdvancementsTabPacket)
  • 0x56 Server Data (ClientboundServerDataPacket)
  • 0x57 Set Action Bar Text (ClientboundSetActionBarTextPacket)
  • 0x58 Set Border Center (ClientboundSetBorderCenterPacket)
  • 0x59 Set Border Leap Size (ClientboundSetBorderLeapSizePacket)
  • 0x5A Set Border Size (ClientboundSetBorderSizePacket)
  • 0x5B Set Border Warning Delay (ClientboundSetBorderWarningDelayPacket)
  • 0x5C Set Border Warning Distance (ClientboundSetBorderWarningDistancePacket)
  • 0x5D Set Camera (ClientboundSetCameraPacket)
  • 0x5E Set Center Chunk (ClientboundSetCenterChunkPacket)
  • 0x5F Set Render Distance (ClientboundSetRenderDistancePacket)
  • 0x60 Set Cursor Item (ClientboundSetCursorItemPacket)
  • 0x61 Set Default Spawn Position (ClientboundSetDefaultSpawnPositionPacket)
  • 0x62 Set Display Objective (ClientboundSetDisplayObjectivePacket)
  • 0x63 Set Entity Metadata (ClientboundSetEntityMetadataPacket)
  • 0x64 Link Entities (ClientboundLinkEntitiesPacket)
  • 0x65 Set Entity Velocity (ClientboundSetEntityVelocityPacket)
  • 0x66 Set Equipment (ClientboundSetEquipmentPacket)
  • 0x67 Set Experience (ClientboundSetExperiencePacket)
  • 0x68 Set Health (ClientboundSetHealthPacket)
  • 0x69 Set Carried Item (ClientboundSetCarriedItemPacket)
  • 0x6A Update Objective (ClientboundUpdateObjectivePacket)
  • 0x6B Set Passengers (ClientboundSetPassengersPacket)
  • 0x6C Set Player Inventory Slot (ClientboundSetPlayerInventorySlotPacket)
  • 0x6D Set Player Team (ClientboundSetPlayerTeamPacket)
  • 0x6E Update Score (ClientboundUpdateScorePacket)
  • 0x6F Set Simulation Distance (ClientboundSetSimulationDistancePacket)
  • 0x70 Set Subtitle Text (ClientboundSetSubtitleTextPacket)
  • 0x71 Set Time (ClientboundSetTimePacket)
  • 0x72 Set Title Text (ClientboundSetTitleTextPacket)
  • 0x73 Set Title Animation Times (ClientboundSetTitleAnimationTimesPacket)
  • 0x74 Entity Sound Effect (ClientboundEntitySoundEffectPacket)
  • 0x75 Sound Effect (ClientboundSoundEffectPacket)
  • 0x76 Start Configuration (ClientboundStartConfigurationPacket)
  • 0x77 Stop Sound (ClientboundStopSoundPacket)
  • 0x78 Store Cookie (ClientboundStoreCookiePacket)
  • 0x79 System Chat Message (ClientboundSystemChatMessagePacket)
  • 0x7A Set Tab List Header And Footer (ClientboundSetTabListHeaderAndFooterPacket)
  • 0x7B Tag Query Response (ClientboundTagQueryResponsePacket)
  • 0x7C Pickup Item (ClientboundPickupItemPacket)
  • 0x7D Synchronize Vehicle Position (ClientboundSynchronizeVehiclePositionPacket)
  • 0x7E Test Instance Block Status (ClientboundTestInstanceBlockStatusPacket)
  • 0x7F Set Ticking State (ClientboundSetTickingStatePacket)
  • 0x80 Step Tick (ClientboundStepTickPacket)
  • 0x81 Transfer (ClientboundTransferPacket)
  • 0x82 Update Advancements (ClientboundUpdateAdvancementsPacket)
  • 0x83 Update Attributes (ClientboundUpdateAttributesPacket)
  • 0x84 Entity Effect (ClientboundEntityEffectPacket)
  • 0x85 Update Recipes (ClientboundUpdateRecipesPacket)
  • 0x86 Update Tags (ClientboundUpdateTagsPacket)
  • 0x87 Projectile Power (ClientboundProjectilePowerPacket)
  • 0x88 Custom Report Details (ClientboundCustomReportDetailsPacket)
  • 0x89 Server Links (ClientboundServerLinksPacket)
  • 0x8A Waypoint (ClientboundWaypointPacket)
  • 0x8B Clear Dialog (ClientboundClearDialogPacket)
  • 0x8C Show Dialog (ClientboundShowDialogPacket)

Serverbound

  • 0x00 Accept Teleportation (ServerboundAcceptTeleportationPacket)
  • 0x01 Attack Action (ServerboundAttackActionPacket)
  • 0x02 Query Block Entity Tag (ServerboundQueryBlockEntityTagPacket)
  • 0x03 Bundle Item Selected (ServerboundBundleItemSelectedPacket)
  • 0x04 Change Difficulty (ServerboundChangeDifficultyPacket)
  • 0x05 Change Game Mode (ServerboundChangeGameModePacket)
  • 0x06 Acknowledge Chat Message (ServerboundAcknowledgeChatMessagePacket)
  • 0x07 Chat Command (ServerboundChatCommandPacket)
  • 0x08 Signed Chat Command (ServerboundSignedChatCommandPacket)
  • 0x09 Chat Message (ServerboundChatMessagePacket)
  • 0x0A Update Chat Session (ServerboundUpdateChatSessionPacket)
  • 0x0B Chunk Batch Received (ServerboundChunkBatchReceivedPacket)
  • 0x0C Client Command (ServerboundClientCommandPacket)
  • 0x0D Client Tick End (ServerboundClientTickEndPacket)
  • 0x0E Client Information (ServerboundClientInformationPacket)
  • 0x0F Command Suggestion Request (ServerboundCommandSuggestionRequestPacket)
  • 0x10 Configuration Acknowledged (ServerboundConfigurationAcknowledgedPacket)
  • 0x11 Container Click Button (ServerboundContainerClickButtonPacket)
  • 0x12 Container Click (ServerboundContainerClickPacket)
  • 0x13 Container Close (ServerboundContainerClosePacket)
  • 0x14 Change Container Slot State (ServerboundChangeContainerSlotStatePacket)
  • 0x15 Cookie Response (ServerboundCookieResponsePacket)
  • 0x16 Custom Payload (ServerboundCustomPayloadPacket)
  • 0x17 Debug Subscription Request (ServerboundDebugSubscriptionRequestPacket)
  • 0x18 Edit Book (ServerboundEditBookPacket)
  • 0x19 Query Entity Tag (ServerboundQueryEntityTagPacket)
  • 0x1A Interact (ServerboundInteractPacket)
  • 0x1B Jigsaw Generate (ServerboundJigsawGeneratePacket)
  • 0x1C Keep Alive (ServerboundKeepAlivePlayPacket)
  • 0x1D Lock Difficulty (ServerboundLockDifficultyPacket)
  • 0x1E Set Player Position (ServerboundSetPlayerPositionPacket)
  • 0x1F Set Player Position and Rotation (ServerboundSetPlayerPositionAndRotationPacket)
  • 0x20 Set Player Rotation (ServerboundSetPlayerRotationPacket)
  • 0x21 Set Player Movement Flag (ServerboundSetPlayerMovementFlagPacket)
  • 0x22 Move Vehicle (ServerboundMoveVehiclePacket)
  • 0x23 Paddle Boat (ServerboundPaddleBoatPacket)
  • 0x24 Pick Item From Block (ServerboundPickItemFromBlockPacket)
  • 0x25 Pick Item From Entity (ServerboundPickItemFromEntityPacket)
  • 0x26 Ping Request (ServerboundPingRequestPacket)
  • 0x27 Place Recipe (ServerboundPlaceRecipePacket)
  • 0x28 Player Abilities (ServerboundPlayerAbilitiesPacket)
  • 0x29 Player Action (ServerboundPlayerActionPacket)
  • 0x2A Player Command (ServerboundPlayerCommandPacket)
  • 0x2B Player Input (ServerboundPlayerInputPacket)
  • 0x2C Player Loaded (ServerboundPlayerLoadedPacket)
  • 0x2D Pong (ServerboundPongPlayPacket)
  • 0x2E Recipe Book Change Settings (ServerboundRecipeBookChangeSettingsPacket)
  • 0x2F Recipe Book Seen Recipe (ServerboundRecipeBookSeenRecipePacket)
  • 0x30 Rename Item (ServerboundRenameItemPacket)
  • 0x31 Resource Pack Response (ServerboundResourcePackResponsePacket)
  • 0x32 Seen Advancements (ServerboundSeenAdvancementsPacket)
  • 0x33 Select Trade (ServerboundSelectTradePacket)
  • 0x34 Set Beacon (ServerboundSetBeaconPacket)
  • 0x35 Set Carried Item (ServerboundSetCarriedItemPacket)
  • 0x36 Set Command Block (ServerboundSetCommandBlockPacket)
  • 0x37 Set Command Minecart (ServerboundSetCommandMinecartPacket)
  • 0x38 Set Creative Mode Slot (ServerboundSetCreativeModeSlotPacket)
  • 0x39 Set Game Rule (ServerboundSetGameRulePacket)
  • 0x3A Set Jigsaw Block (ServerboundSetJigsawBlockPacket)
  • 0x3B Set Structure Block (ServerboundSetStructureBlockPacket)
  • 0x3C Set Test Block (ServerboundSetTestBlockPacket)
  • 0x3D Sign Update (ServerboundSignUpdatePacket)
  • 0x3E Spectator Action (ServerboundSpectatorActionPacket)
  • 0x3F Swing (ServerboundSwingPacket)
  • 0x40 Teleport To Entity (ServerboundTeleportToEntityPacket)
  • 0x41 Test Instance Block Action (ServerboundTestInstanceBlockActionPacket)
  • 0x42 Use Item On (ServerboundUseItemOnPacket)
  • 0x43 Use Item (ServerboundUseItemPacket)
  • 0x44 Custom Click Action (ServerboundCustomClickActionPacket)

libmc-mcping

A lightweight module to query Minecraft Java and Bedrock server status, MOTD, and latency

Use mcping

libmc-rconlib

Send Command via rcon protocol

Use rconlib

libmc-nbt

NBT reader and writer, compat with network NBT

libmc-snbt

Not completed

Open Source

Open source under Apache-2.0