https://github.com/devsrsouza/kt-mc-packet
A Minecraft Protocol library for Kotlin Multiplatform
https://github.com/devsrsouza/kt-mc-packet
kotlin kotlin-multiplatform kotlinx-serialization minecraft minecraft-api
Last synced: 2 months ago
JSON representation
A Minecraft Protocol library for Kotlin Multiplatform
- Host: GitHub
- URL: https://github.com/devsrsouza/kt-mc-packet
- Owner: DevSrSouza
- License: mit
- Created: 2020-04-01T22:09:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-03T13:16:17.000Z (about 4 years ago)
- Last Synced: 2025-03-17T19:46:46.601Z (2 months ago)
- Topics: kotlin, kotlin-multiplatform, kotlinx-serialization, minecraft, minecraft-api
- Language: Kotlin
- Homepage:
- Size: 223 KB
- Stars: 30
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kt-mc-packet
A Minecraft Java Edition Protocol library for Kotlin multiplatform that uses Kotlinx.serialization
to Encode and Decode Minecraft packets as kotlin data classes.## Usage
Serialize:
```kotlin
val minecraftVersion = 578 // 1.15.2val byteArray: ByteArray = MinecraftProtocol.dump(
Handshake.serializer(),
Handshake(
minecraftVersion,
"minecraftserver.com",
25565,
HandshakePacket.HandshakeNextState.STATUS
)
)
```Deserialize:
```kotlin
val handshake: Handshake = MinecraftProtocol.load(
Handshake.serializer(),
byteArrayWithPacketData
)
```## Images
from `src/jvmTest/kotlin/ServerStatusTest.kt`
from `src/jvmTest/kotlin/ServerLoginTest.kt`
