Git Product home page Git Product logo

kt-mc-packet's Introduction

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:

val minecraftVersion = 578 // 1.15.2

val byteArray: ByteArray = MinecraftProtocol.dump(
    Handshake.serializer(),
    Handshake(
        minecraftVersion,
        "minecraftserver.com",
        25565,
        HandshakePacket.HandshakeNextState.STATUS
    )
)

Deserialize:

val handshake: Handshake = MinecraftProtocol.load(
    Handshake.serializer(),
    byteArrayWithPacketData
)

Images

from src/jvmTest/kotlin/ServerStatusTest.kt

from src/jvmTest/kotlin/ServerLoginTest.kt

kt-mc-packet's People

Contributors

devsrsouza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ktcraft

kt-mc-packet's Issues

kt-mc-packet in Kotlin native projects

Is it possible to use it in Kotlin native projects? When I try to use it I get

Could not determine the dependencies of task ':linkDebugExecutableCentoxCloud'.
> Could not resolve all task dependencies for configuration ':CentoxCloudCompileKlibraries'.
   > Could not resolve br.com.devsrsouza:kt-mc-packet:v0.1.0.
     Required by:
         project :
      > No matching variant of project :kt-mc-packet was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'linux_x64' but:
          - Variant 'jsApiElements' capability br.com.devsrsouza:kt-mc-packet:0.1.0 declares a usage of 'kotlin-api' of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsCompile' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsCompileOnly' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsDefault' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsRuntime' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsRuntimeElements' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsTestCompile' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jsTestRuntime' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmApiElements' capability br.com.devsrsouza:kt-mc-packet:0.1.0 declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmCompile' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmCompileOnly' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmDefault' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmRuntime' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmRuntimeElements' capability br.com.devsrsouza:kt-mc-packet:0.1.0 declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmTestCompile' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'jvmTestRuntime' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'metadataApiElements' capability br.com.devsrsouza:kt-mc-packet:0.1.0 declares a usage of 'kotlin-api' of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'metadataCompile' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'metadataCompileOnly' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')
          - Variant 'metadataDefault' capability br.com.devsrsouza:kt-mc-packet:0.1.0:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its usage (required a usage of 'kotlin-api')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'linux_x64')

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

The future of this library

First of all, let me say that I'm a huge fan of this library, and we're considering using it in the Noxcrew's MC Championship codebase. A Kotlin data class based Minecraft Packet API is exactly what we need, and the design of this one is pretty good.

That being said, this library isn't in a usable state right now - it only supports very few packet types, and the IDs of some packets are outdated as well (PlayerPositionAndLook should have ID 0x34, but has 0x36).

What are your future plans with this library? I'm interested in financially supporting the development. I've tweeted at you, please DM me if you're interested in taking this further :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.