mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
Merge branch 'work/network/22w17a'
This commit is contained in:
commit
8f4239f069
@ -28,9 +28,19 @@ class Goat(connection: PlayConnection, entityType: EntityType, data: EntityData,
|
|||||||
val isScreaming: Boolean
|
val isScreaming: Boolean
|
||||||
get() = data.getBoolean(SCREAMING_DATA, false)
|
get() = data.getBoolean(SCREAMING_DATA, false)
|
||||||
|
|
||||||
|
@get:SynchronizedEntityData
|
||||||
|
val hasLeftHorn: Boolean
|
||||||
|
get() = data.getBoolean(LEFT_HORN_DATA, false)
|
||||||
|
|
||||||
|
@get:SynchronizedEntityData
|
||||||
|
val hasRightHorn: Boolean
|
||||||
|
get() = data.getBoolean(RIGHT_HORN_DATA, false)
|
||||||
|
|
||||||
companion object : EntityFactory<Goat> {
|
companion object : EntityFactory<Goat> {
|
||||||
override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("goat")
|
override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("goat")
|
||||||
private val SCREAMING_DATA = EntityDataField("GOAT_IS_SCREAMING")
|
private val SCREAMING_DATA = EntityDataField("GOAT_IS_SCREAMING")
|
||||||
|
private val LEFT_HORN_DATA = EntityDataField("LEFT_HORN")
|
||||||
|
private val RIGHT_HORN_DATA = EntityDataField("RIGHT_HORN")
|
||||||
|
|
||||||
override fun build(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation): Goat {
|
override fun build(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation): Goat {
|
||||||
return Goat(connection, entityType, data, position, rotation)
|
return Goat(connection, entityType, data, position, rotation)
|
||||||
|
@ -79,7 +79,7 @@ class ArmorStand(connection: PlayConnection, entityType: EntityType, data: Entit
|
|||||||
private val LEFT_ARM_ROTATION_DATA = EntityDataField("ARMOR_STAND_LEFT_ARM_ROTATION")
|
private val LEFT_ARM_ROTATION_DATA = EntityDataField("ARMOR_STAND_LEFT_ARM_ROTATION")
|
||||||
private val RIGHT_ARM_ROTATION_DATA = EntityDataField("ARMOR_STAND_RIGHT_ARM_ROTATION")
|
private val RIGHT_ARM_ROTATION_DATA = EntityDataField("ARMOR_STAND_RIGHT_ARM_ROTATION")
|
||||||
private val LEFT_LEG_ROTATION_DATA = EntityDataField("ARMOR_STAND_LEFT_LEG_ROTATION", "ARMOR_STAND_LEFT_LAG_ROTATION")
|
private val LEFT_LEG_ROTATION_DATA = EntityDataField("ARMOR_STAND_LEFT_LEG_ROTATION", "ARMOR_STAND_LEFT_LAG_ROTATION")
|
||||||
private val RIGHT_LEG_ROTATION_DATA = EntityDataField("ARMOR_STAND_LEFT_LEG_ROTATION", "ARMOR_STAND_RIGHT_LAG_ROTATION")
|
private val RIGHT_LEG_ROTATION_DATA = EntityDataField("ARMOR_STAND_RIGHT_LEG_ROTATION", "ARMOR_STAND_RIGHT_LAG_ROTATION")
|
||||||
|
|
||||||
override fun build(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation): ArmorStand {
|
override fun build(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation): ArmorStand {
|
||||||
return ArmorStand(connection, entityType, data, position, rotation)
|
return ArmorStand(connection, entityType, data, position, rotation)
|
||||||
|
@ -48,7 +48,6 @@ data class PlayerProperties(
|
|||||||
else -> Log.log(LogMessageType.OTHER, LogLevels.WARN) { "Unknown player property $name: ${property["value"].toString()}" }
|
else -> Log.log(LogMessageType.OTHER, LogLevels.WARN) { "Unknown player property $name: ${property["value"].toString()}" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PlayerProperties(
|
return PlayerProperties(
|
||||||
|
@ -61,4 +61,5 @@ class Version(
|
|||||||
val maxPacketLength get() = (versionId < ProtocolVersions.V_1_17_1_RC2).decide(1 shl 21, 1 shl 23)
|
val maxPacketLength get() = (versionId < ProtocolVersions.V_1_17_1_RC2).decide(1 shl 21, 1 shl 23)
|
||||||
val maxChatMessageSize get() = (versionId < ProtocolVersions.V_16W38A).decide(100, 256)
|
val maxChatMessageSize get() = (versionId < ProtocolVersions.V_16W38A).decide(100, 256)
|
||||||
val hasAttackCooldown get() = versionId >= ProtocolVersions.V_15W34A
|
val hasAttackCooldown get() = versionId >= ProtocolVersions.V_15W34A
|
||||||
|
val requiresSignedChat get() = versionId >= ProtocolVersions.V_22W17A
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import de.bixilon.minosoft.modding.event.EventInitiators
|
|||||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.chat.ChatMessageS2CP
|
import de.bixilon.minosoft.protocol.packets.s2c.play.chat.ChatMessageS2CP
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.play.chat.SignedChatMessageS2CP
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.title.HotbarTextS2CP
|
import de.bixilon.minosoft.protocol.packets.s2c.play.title.HotbarTextS2CP
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -33,4 +34,6 @@ class ChatMessageReceiveEvent(
|
|||||||
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.position, packet.sender)
|
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.position, packet.sender)
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: HotbarTextS2CP) : this(connection, EventInitiators.SERVER, packet.text, ChatTextPositions.ABOVE_HOTBAR, null)
|
constructor(connection: PlayConnection, packet: HotbarTextS2CP) : this(connection, EventInitiators.SERVER, packet.text, ChatTextPositions.ABOVE_HOTBAR, null)
|
||||||
|
|
||||||
|
constructor(connection: PlayConnection, packet: SignedChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.position, packet.sender.uuid)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol
|
||||||
|
|
||||||
|
import de.bixilon.kutil.json.JsonObject
|
||||||
|
|
||||||
|
class PlayerPublicKey(
|
||||||
|
val expiresAt: Long,
|
||||||
|
val keyString: String,
|
||||||
|
val signate: String,
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun toNbt(): JsonObject {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
}
|
@ -13,11 +13,14 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.c2s.login
|
package de.bixilon.minosoft.protocol.packets.c2s.login
|
||||||
|
|
||||||
import de.bixilon.kutil.base64.Base64Util.toBase64
|
import de.bixilon.kutil.base64.Base64Util.toBase64
|
||||||
|
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.CryptManager
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.CryptManager
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.SignatureData
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
@ -25,19 +28,32 @@ import java.security.PublicKey
|
|||||||
import javax.crypto.SecretKey
|
import javax.crypto.SecretKey
|
||||||
|
|
||||||
@LoadPacket(state = ProtocolStates.LOGIN)
|
@LoadPacket(state = ProtocolStates.LOGIN)
|
||||||
class EncryptionC2SP(
|
class EncryptionC2SP private constructor(
|
||||||
val secret: ByteArray,
|
val secret: ByteArray,
|
||||||
val token: ByteArray,
|
val nonce: Any,
|
||||||
) : PlayC2SPacket {
|
) : PlayC2SPacket {
|
||||||
|
|
||||||
constructor(secretKey: SecretKey, token: ByteArray, key: PublicKey) : this(CryptManager.encryptData(key, secretKey.encoded), CryptManager.encryptData(key, token))
|
constructor(secretKey: SecretKey, nonce: ByteArray, key: PublicKey) : this(CryptManager.encryptData(key, secretKey.encoded), CryptManager.encryptData(key, nonce))
|
||||||
|
|
||||||
|
constructor(secret: ByteArray, nonce: ByteArray) : this(secret, nonce as Any)
|
||||||
|
constructor(secret: ByteArray, nonce: SignatureData) : this(secret, nonce as Any)
|
||||||
|
|
||||||
override fun write(buffer: PlayOutByteBuffer) {
|
override fun write(buffer: PlayOutByteBuffer) {
|
||||||
buffer.writeByteArray(secret)
|
buffer.writeByteArray(secret)
|
||||||
buffer.writeByteArray(token)
|
if (buffer.versionId < ProtocolVersions.V_22W17A) {
|
||||||
|
buffer.writeByteArray(nonce.nullCast<ByteArray>() ?: throw IllegalArgumentException("In < 22w17a the nonce must be a bytearray!"))
|
||||||
|
} else {
|
||||||
|
if (nonce is ByteArray) {
|
||||||
|
buffer.writeBoolean(true)
|
||||||
|
buffer.writeByteArray(nonce)
|
||||||
|
} else {
|
||||||
|
buffer.writeBoolean(false)
|
||||||
|
buffer.writeSignatureData(nonce as SignatureData)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Encryption response (secret=${secret.toBase64()}, token=${token.toBase64()})" }
|
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Encryption response (secret=${secret.toBase64()}, nonce=$nonce)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.c2s.login
|
package de.bixilon.minosoft.protocol.packets.c2s.login
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.player.LocalPlayerEntity
|
import de.bixilon.minosoft.data.player.LocalPlayerEntity
|
||||||
|
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
@ -24,15 +26,19 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
@LoadPacket(state = ProtocolStates.LOGIN)
|
@LoadPacket(state = ProtocolStates.LOGIN)
|
||||||
class StartC2SP(
|
class StartC2SP(
|
||||||
val username: String,
|
val username: String,
|
||||||
|
val publicKey: PlayerPublicKey? = null,
|
||||||
) : PlayC2SPacket {
|
) : PlayC2SPacket {
|
||||||
|
|
||||||
constructor(player: LocalPlayerEntity) : this(player.name)
|
constructor(player: LocalPlayerEntity) : this(player.name)
|
||||||
|
|
||||||
override fun write(buffer: PlayOutByteBuffer) {
|
override fun write(buffer: PlayOutByteBuffer) {
|
||||||
buffer.writeString(username)
|
buffer.writeString(username)
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_22W17A) {
|
||||||
|
buffer.writeOptional(publicKey) { buffer.writePublicKey(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Login start (username=$username)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Login start (username=$username, publicKey=$publicKey)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
package de.bixilon.minosoft.protocol.packets.c2s.play.chat
|
package de.bixilon.minosoft.protocol.packets.c2s.play.chat
|
||||||
|
|
||||||
|
import de.bixilon.kutil.time.TimeUtil
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.SignatureData
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
@ -22,13 +25,21 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
@LoadPacket(threadSafe = false)
|
@LoadPacket(threadSafe = false)
|
||||||
class ChatMessageC2SP(
|
class ChatMessageC2SP(
|
||||||
val message: String,
|
val message: String,
|
||||||
|
val time: Long = TimeUtil.seconds,
|
||||||
|
val signature: SignatureData? = null,
|
||||||
) : PlayC2SPacket {
|
) : PlayC2SPacket {
|
||||||
|
|
||||||
override fun write(buffer: PlayOutByteBuffer) {
|
override fun write(buffer: PlayOutByteBuffer) {
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_22W17A) {
|
||||||
|
buffer.writeLong(time)
|
||||||
|
}
|
||||||
buffer.writeString(message)
|
buffer.writeString(message)
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_22W17A) {
|
||||||
|
buffer.writeSignatureData(signature ?: SignatureData.EMPTY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Chat message (message=$message)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Chat message (time=${time}, message=$message, signature=$signature)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
|||||||
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
import de.bixilon.minosoft.protocol.protocol.CryptManager
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
import de.bixilon.minosoft.protocol.protocol.ProtocolStates
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.CryptManager
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.login
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||||
|
import de.bixilon.minosoft.data.player.properties.PlayerProperties
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
@ -29,6 +30,7 @@ import java.util.*
|
|||||||
class SuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class SuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val uuid: UUID = (buffer.versionId < ProtocolVersions.V_20W12A).decide({ buffer.readUUIDString() }, { buffer.readUUID() })
|
val uuid: UUID = (buffer.versionId < ProtocolVersions.V_20W12A).decide({ buffer.readUUIDString() }, { buffer.readUUID() })
|
||||||
val name: String = buffer.readString()
|
val name: String = buffer.readString()
|
||||||
|
val properties: PlayerProperties? = if (buffer.versionId >= ProtocolVersions.V_22W17A) buffer.readPlayerProperties() else null
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
connection.network.state = ProtocolStates.PLAY
|
connection.network.state = ProtocolStates.PLAY
|
||||||
@ -41,6 +43,6 @@ class SuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Login success (uuid=$uuid, name=$name)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Login success (uuid=$uuid, name=$name, properties=$properties)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val type: ParticleType = if (buffer.versionId < ProtocolVersions.V_14W19A) {
|
val type: ParticleType = if (buffer.versionId < ProtocolVersions.V_14W19A) {
|
||||||
buffer.connection.registries.particleTypeRegistry[buffer.readResourceLocation()]!!
|
buffer.connection.registries.particleTypeRegistry[buffer.readResourceLocation()]!!
|
||||||
|
} else if (buffer.versionId >= ProtocolVersions.V_22W17A) { // ToDo: maybe this was even earlier, should only differ some snapshots
|
||||||
|
buffer.connection.registries.particleTypeRegistry[buffer.readVarInt()]
|
||||||
} else {
|
} else {
|
||||||
buffer.connection.registries.particleTypeRegistry[buffer.readInt()]
|
buffer.connection.registries.particleTypeRegistry[buffer.readInt()]
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
init {
|
init {
|
||||||
if (buffer.versionId >= ProtocolVersions.V_14W04A) {
|
if (buffer.versionId >= ProtocolVersions.V_14W04A) {
|
||||||
position = ChatTextPositions[buffer.readUnsignedByte()]
|
position = ChatTextPositions[buffer.readUnsignedByte()]
|
||||||
if (buffer.versionId >= ProtocolVersions.V_20W21A) {
|
if (buffer.versionId >= ProtocolVersions.V_20W21A && buffer.versionId < ProtocolVersions.V_22W17A) {
|
||||||
sender = buffer.readUUID()
|
sender = buffer.readUUID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.play.chat
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.ChatTextPositions
|
||||||
|
import de.bixilon.minosoft.modding.event.events.ChatMessageReceiveEvent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
|
@LoadPacket(threadSafe = false)
|
||||||
|
class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
|
val message = buffer.readChatComponent()
|
||||||
|
var position = ChatTextPositions[buffer.readUnsignedByte()]
|
||||||
|
val sender = buffer.readChatMessageSender()
|
||||||
|
val sendingTime = buffer.readLong()
|
||||||
|
val signatureData = buffer.readSignatureData()
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
val event = ChatMessageReceiveEvent(connection, this)
|
||||||
|
if (connection.fireEvent(event)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log(reducedLog: Boolean) {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Chat message (message=\"$message\", position=$position, sender=$sender, sendingTime=$sendingTime, signateDate=$signatureData)" }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.protocol
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ChatMessageSender(
|
||||||
|
val uuid: UUID,
|
||||||
|
val name: ChatComponent,
|
||||||
|
)
|
@ -312,4 +312,9 @@ open class OutByteBuffer() {
|
|||||||
writer(entry)
|
writer(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T> writeOptional(value: T?, writer: (T) -> Unit) {
|
||||||
|
writeBoolean(value != null)
|
||||||
|
value?.let(writer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_19W36A
|
|||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_13_2_PRE1
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_13_2_PRE1
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_9_1_PRE1
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_9_1_PRE1
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W28A
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W28A
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.SignatureData
|
||||||
import de.bixilon.minosoft.recipes.Ingredient
|
import de.bixilon.minosoft.recipes.Ingredient
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
@ -254,4 +255,12 @@ class PlayInByteBuffer : InByteBuffer {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun readChatMessageSender(): ChatMessageSender {
|
||||||
|
return ChatMessageSender(readUUID(), readChatComponent())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun readSignatureData(): SignatureData {
|
||||||
|
return SignatureData(readLong(), readByteArray())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,10 @@ package de.bixilon.minosoft.protocol.protocol
|
|||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||||
|
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W43A
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W43A
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.encryption.SignatureData
|
||||||
|
|
||||||
class PlayOutByteBuffer(val connection: PlayConnection) : OutByteBuffer() {
|
class PlayOutByteBuffer(val connection: PlayConnection) : OutByteBuffer() {
|
||||||
val versionId = connection.version.versionId
|
val versionId = connection.version.versionId
|
||||||
@ -72,4 +74,13 @@ class PlayOutByteBuffer(val connection: PlayConnection) : OutByteBuffer() {
|
|||||||
fun writeNBT(nbt: Any?) {
|
fun writeNBT(nbt: Any?) {
|
||||||
return writeNBT(nbt, versionId < ProtocolVersions.V_14W28B)
|
return writeNBT(nbt, versionId < ProtocolVersions.V_14W28B)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun writePublicKey(key: PlayerPublicKey) {
|
||||||
|
writeNBT(key.toNbt())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun writeSignatureData(signature: SignatureData) {
|
||||||
|
writeLong(signature.salt)
|
||||||
|
writeByteArray(signature.signature)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ package de.bixilon.minosoft.protocol.protocol
|
|||||||
|
|
||||||
@Suppress("UNUSED")
|
@Suppress("UNUSED")
|
||||||
object ProtocolVersions {
|
object ProtocolVersions {
|
||||||
|
const val V_22W17A = 838
|
||||||
const val V_22W16B = 837
|
const val V_22W16B = 837
|
||||||
const val V_22W16A = 836
|
const val V_22W16A = 836
|
||||||
const val V_22W15A = 835
|
const val V_22W15A = 835
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
package de.bixilon.minosoft.protocol.protocol
|
package de.bixilon.minosoft.protocol.protocol.encryption
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.security.Key
|
import java.security.Key
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.protocol.encryption
|
||||||
|
|
||||||
|
class SignatureData(
|
||||||
|
val salt: Long,
|
||||||
|
val signature: ByteArray,
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
val EMPTY = SignatureData(0L, byteArrayOf())
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,14 @@
|
|||||||
{
|
{
|
||||||
|
"838": {
|
||||||
|
"name": "22w17a",
|
||||||
|
"protocol_id": 1073741906,
|
||||||
|
"packets": {
|
||||||
|
"c2s": ["confirm_teleport", "block_nbt", "difficulty", "chat_message", "client_action", "settings", "chat_suggestions", "container_button", "container_click", "close_container", "plugin", "book", "entity_nbt", "entity_interact", "generate_structure", "heartbeat", "lock_difficulty", "position", "position_rotation", "rotation", "ground_change", "move_vehicle", "steer_boat", "item_pick", "crafting_recipe", "toggle_fly", "player_action", "entity_action", "steer_vehicle", "pong", "displayed_recipe", "recipe_book", "anvil_item_name", "resourcepack", "advancement_tab", "trade", "beacon_effect", "hotbar_slot", "command_block", "minecart_command_block", "item_stack_create", "jigsaw_block", "structure_block", "sign_text", "swing_arm", "entity_spectate", "block_interact", "use_item"],
|
||||||
|
"s2c": [
|
||||||
|
"entity_object_spawn", "entity_experience_orb", "entity_player", "entity_animation", "statistics", "block_break", "block_break_animation", "block_data", "block_action", "block", "bossbar", "difficulty", "clear_title", "chat_suggestions", "commands", "close_container", "container_items", "container_properties", "container_item", "item_cooldown", "plugin", "named_sound", "kick", "entity_status", "explosion", "unload_chunk", "game_event", "open_horse_container", "initialize_world_border", "heartbeat", "chunk", "world_event", "particle", "chunk_light", "initialize", "map", "villager_trades", "relative_move", "movement_rotation", "rotation", "move_vehicle", "book", "open_container", "sign_editor", "ping", "crafting_recipe", "player_abilities", "signed_chat_message", "end_combat_event", "enter_combat_event", "kill_combat_event", "tab_list", "player_face", "position_rotation", "unlock_recipes", "entity_destroy", "entity_remove_effect", "resourcepack", "respawn", "head_rotation", "blocks", "advancement_tab", "hotbar_text", "center_world_border", "interpolate_world_border", "size_world_border", "warn_time_world_border", "warn_blocks_world_border", "camera", "hotbar_slot", "chunk_center", "view_distance", "compass_position", "objective_position", "entity_data", "entity_attach", "velocity", "entity_equipment", "experience", "health", "objective", "entity_passenger", "teams", "scoreboard_score", "simulation_distance", "subtitle", "time", "title_text", "title_times", "entity_sound", "sound_event", "stop_sound", "chat_message", "tab_list_text", "nbt_response", "entity_collect", "teleport", "advancements", "entity_attributes", "entity_effect", "recipes", "tags"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"837": {
|
"837": {
|
||||||
"name": "22w16b",
|
"name": "22w16b",
|
||||||
"protocol_id": 1073741905,
|
"protocol_id": 1073741905,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user