-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
175 changed files
with
7,098 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
src/main/kotlin/io/layercraft/packetlib/codec/MinecraftCodecs.kt
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...ayercraft/packetlib/packets/v1_19_3/handshaking/serverbound/LegacyServerListPingPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.handshaking.serverbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Legacy Server List Ping | 0xfe | handshaking | serverbound | ||
* | ||
* @param payload payload | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Legacy_Server_List_Ping">https://wiki.vg/Protocol#Legacy_Server_List_Ping</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0xfe, state = PacketState.HANDSHAKING, direction = PacketDirection.SERVERBOUND) | ||
data class LegacyServerListPingPacket( | ||
val payload: UByte, | ||
) : ServerBoundPacket { | ||
companion object : PacketSerializer<LegacyServerListPingPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): LegacyServerListPingPacket { | ||
val payload = input.readUByte() | ||
|
||
return LegacyServerListPingPacket(payload) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: LegacyServerListPingPacket) { | ||
output.writeUByte(value.payload) | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...tlin/io/layercraft/packetlib/packets/v1_19_3/handshaking/serverbound/SetProtocolPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.handshaking.serverbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Handshake | 0x00 | handshaking | serverbound | ||
* | ||
* @param protocolVersion protocolVersion | ||
* @param serverHost serverHost | ||
* @param serverPort serverPort | ||
* @param nextState nextState | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Handshake">https://wiki.vg/Protocol#Handshake</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x00, state = PacketState.HANDSHAKING, direction = PacketDirection.SERVERBOUND) | ||
data class SetProtocolPacket( | ||
val protocolVersion: Int, // varint | ||
val serverHost: String, | ||
val serverPort: UShort, | ||
val nextState: Int, // varint | ||
) : ServerBoundPacket { | ||
companion object : PacketSerializer<SetProtocolPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): SetProtocolPacket { | ||
val protocolVersion = input.readVarInt() | ||
val serverHost = input.readString() | ||
val serverPort = input.readUShort() | ||
val nextState = input.readVarInt() | ||
|
||
return SetProtocolPacket(protocolVersion, serverHost, serverPort, nextState) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: SetProtocolPacket) { | ||
output.writeVarInt(value.protocolVersion) | ||
output.writeString(value.serverHost) | ||
output.writeUShort(value.serverPort) | ||
output.writeVarInt(value.nextState) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/io/layercraft/packetlib/packets/v1_19_3/login/clientbound/CompressPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.clientbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Set Compression | 0x03 | login | clientbound | ||
* | ||
* @param threshold threshold | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Set_Compression">https://wiki.vg/Protocol#Set_Compression</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x03, state = PacketState.LOGIN, direction = PacketDirection.CLIENTBOUND) | ||
data class CompressPacket( | ||
val threshold: Int, // varint | ||
) : ClientBoundPacket { | ||
companion object : PacketSerializer<CompressPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): CompressPacket { | ||
val threshold = input.readVarInt() | ||
|
||
return CompressPacket(threshold) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: CompressPacket) { | ||
output.writeVarInt(value.threshold) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...main/kotlin/io/layercraft/packetlib/packets/v1_19_3/login/clientbound/DisconnectPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.clientbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Disconnect (login) | 0x00 | login | clientbound | ||
* | ||
* @param reason reason | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Disconnect_.28login.29">https://wiki.vg/Protocol#Disconnect_.28login.29</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x00, state = PacketState.LOGIN, direction = PacketDirection.CLIENTBOUND) | ||
data class DisconnectPacket( | ||
val reason: String, | ||
) : ClientBoundPacket { | ||
companion object : PacketSerializer<DisconnectPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): DisconnectPacket { | ||
val reason = input.readString() | ||
|
||
return DisconnectPacket(reason) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: DisconnectPacket) { | ||
output.writeString(value.reason) | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...kotlin/io/layercraft/packetlib/packets/v1_19_3/login/clientbound/EncryptionBeginPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.clientbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Encryption Request | 0x01 | login | clientbound | ||
* | ||
* @param serverId serverId | ||
* @param publicKey publicKey | ||
* @param verifyToken verifyToken | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Encryption_Request">https://wiki.vg/Protocol#Encryption_Request</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x01, state = PacketState.LOGIN, direction = PacketDirection.CLIENTBOUND) | ||
data class EncryptionBeginPacket( | ||
val serverId: String, | ||
val publicKey: ByteArray, | ||
val verifyToken: ByteArray, | ||
) : ClientBoundPacket { | ||
companion object : PacketSerializer<EncryptionBeginPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): EncryptionBeginPacket { | ||
val serverId = input.readString() | ||
val publicKey = input.readVarIntByteArray() | ||
val verifyToken = input.readVarIntByteArray() | ||
|
||
return EncryptionBeginPacket(serverId, publicKey, verifyToken) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: EncryptionBeginPacket) { | ||
output.writeString(value.serverId) | ||
output.writeVarIntByteArray(value.publicKey) | ||
output.writeVarIntByteArray(value.verifyToken) | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...lin/io/layercraft/packetlib/packets/v1_19_3/login/clientbound/LoginPluginRequestPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.clientbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Login Plugin Request | 0x04 | login | clientbound | ||
* | ||
* @param messageId messageId | ||
* @param channel channel | ||
* @param data data | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Login_Plugin_Request">https://wiki.vg/Protocol#Login_Plugin_Request</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x04, state = PacketState.LOGIN, direction = PacketDirection.CLIENTBOUND) | ||
data class LoginPluginRequestPacket( | ||
val messageId: Int, // varint | ||
val channel: String, | ||
val data: ByteArray, | ||
) : ClientBoundPacket { | ||
companion object : PacketSerializer<LoginPluginRequestPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): LoginPluginRequestPacket { | ||
val messageId = input.readVarInt() | ||
val channel = input.readString() | ||
val data = input.readRemainingByteArray() | ||
|
||
return LoginPluginRequestPacket(messageId, channel, data) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: LoginPluginRequestPacket) { | ||
output.writeVarInt(value.messageId) | ||
output.writeString(value.channel) | ||
output.writeRemainingByteArray(value.data) | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/main/kotlin/io/layercraft/packetlib/packets/v1_19_3/login/clientbound/SuccessPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.clientbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
import java.util.UUID | ||
/** | ||
* Login Success | 0x02 | login | clientbound | ||
* | ||
* @param uuid uuid | ||
* @param username username | ||
* @param properties list of SuccessPacketProperties | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Login_Success">https://wiki.vg/Protocol#Login_Success</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x02, state = PacketState.LOGIN, direction = PacketDirection.CLIENTBOUND) | ||
data class SuccessPacket( | ||
val uuid: UUID, | ||
val username: String, | ||
val properties: List<SuccessPacketProperties>, // varint array | ||
) : ClientBoundPacket { | ||
companion object : PacketSerializer<SuccessPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): SuccessPacket { | ||
val uuid = input.readUUID() | ||
val username = input.readString() | ||
val properties = input.readVarIntArray { arrayInput -> | ||
val name = arrayInput.readString() | ||
val value = arrayInput.readString() | ||
val hasSignature = arrayInput.readBoolean() | ||
val signature = if (hasSignature) arrayInput.readString() else null | ||
|
||
return@readVarIntArray SuccessPacketProperties(name, value, hasSignature, signature) | ||
} | ||
|
||
return SuccessPacket(uuid, username, properties) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: SuccessPacket) { | ||
output.writeUUID(value.uuid) | ||
output.writeString(value.username) | ||
|
||
output.writeVarIntArray(value.properties) { arrayValue, arrayOutput -> | ||
arrayOutput.writeString(arrayValue.name) | ||
arrayOutput.writeString(arrayValue.value) | ||
arrayOutput.writeBoolean(arrayValue.hasSignature) | ||
if (arrayValue.hasSignature) arrayOutput.writeString(arrayValue.signature!!) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* SuccessPacketProperties | ||
* | ||
* @param name name | ||
* @param value value | ||
* @param hasSignature signature is present | ||
* @param signature signature | ||
*/ | ||
data class SuccessPacketProperties( | ||
val name: String, | ||
val value: String, | ||
val hasSignature: Boolean, | ||
val signature: String?, | ||
) |
33 changes: 33 additions & 0 deletions
33
...kotlin/io/layercraft/packetlib/packets/v1_19_3/login/serverbound/EncryptionBeginPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.serverbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Encryption Response | 0x01 | login | serverbound | ||
* | ||
* @param sharedSecret sharedSecret | ||
* @param verifyToken verifyToken | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Encryption_Response">https://wiki.vg/Protocol#Encryption_Response</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x01, state = PacketState.LOGIN, direction = PacketDirection.SERVERBOUND) | ||
data class EncryptionBeginPacket( | ||
val sharedSecret: ByteArray, | ||
val verifyToken: ByteArray, | ||
) : ServerBoundPacket { | ||
companion object : PacketSerializer<EncryptionBeginPacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): EncryptionBeginPacket { | ||
val sharedSecret = input.readVarIntByteArray() | ||
val verifyToken = input.readVarIntByteArray() | ||
|
||
return EncryptionBeginPacket(sharedSecret, verifyToken) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: EncryptionBeginPacket) { | ||
output.writeVarIntByteArray(value.sharedSecret) | ||
output.writeVarIntByteArray(value.verifyToken) | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...in/io/layercraft/packetlib/packets/v1_19_3/login/serverbound/LoginPluginResponsePacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.layercraft.packetlib.packets.v1_19_3.login.serverbound | ||
|
||
import io.layercraft.packetlib.packets.* | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolDeserializeInterface | ||
import io.layercraft.packetlib.serialization.MinecraftProtocolSerializeInterface | ||
|
||
/** | ||
* Login Plugin Response | 0x02 | login | serverbound | ||
* | ||
* @param messageId messageId | ||
* @param successful successful | ||
* @param hasData data is present | ||
* @param data data | ||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=17932#Login_Plugin_Response">https://wiki.vg/Protocol#Login_Plugin_Response</a> | ||
*/ | ||
|
||
@MinecraftPacket(id = 0x02, state = PacketState.LOGIN, direction = PacketDirection.SERVERBOUND) | ||
data class LoginPluginResponsePacket( | ||
val messageId: Int, // varint | ||
val successful: Boolean, | ||
val hasData: Boolean, | ||
val data: ByteArray?, | ||
) : ServerBoundPacket { | ||
companion object : PacketSerializer<LoginPluginResponsePacket> { | ||
override fun deserialize(input: MinecraftProtocolDeserializeInterface<*>): LoginPluginResponsePacket { | ||
val messageId = input.readVarInt() | ||
val successful = input.readBoolean() | ||
val hasData = input.readBoolean() | ||
val data = if (hasData) input.readRemainingByteArray() else null | ||
|
||
return LoginPluginResponsePacket(messageId, successful, hasData, data) | ||
} | ||
|
||
override fun serialize(output: MinecraftProtocolSerializeInterface<*>, value: LoginPluginResponsePacket) { | ||
output.writeVarInt(value.messageId) | ||
output.writeBoolean(value.successful) | ||
output.writeBoolean(value.hasData) | ||
if (value.hasData) output.writeRemainingByteArray(value.data!!) | ||
} | ||
} | ||
} |
Oops, something went wrong.