Compare commits
8 Commits
master
...
lazymc-v1_
Author | SHA1 | Date | |
---|---|---|---|
|
6d1ef0b27d | ||
|
356ea54243 | ||
|
a14b40ea9d | ||
|
4e6a1f9380 | ||
|
d26a525c7b | ||
|
bef4fa8c00 | ||
|
a4fc2bcf7b | ||
|
39751ce604 |
@ -8,6 +8,7 @@ pub struct ServerStatus {
|
|||||||
pub version: ServerVersion,
|
pub version: ServerVersion,
|
||||||
pub players: OnlinePlayers,
|
pub players: OnlinePlayers,
|
||||||
pub description: Message,
|
pub description: Message,
|
||||||
|
pub favicon: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
@ -222,6 +222,22 @@ impl Decoder for Vec<CompoundTag> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Decoder for Vec<String> {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
let length = reader.read_var_i32()? as usize;
|
||||||
|
let mut vec = Vec::with_capacity(length);
|
||||||
|
|
||||||
|
for _ in 0..length {
|
||||||
|
let identifier = reader.read_string(32767)?;
|
||||||
|
vec.push(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod var_int {
|
pub mod var_int {
|
||||||
use crate::decoder::DecoderReadExt;
|
use crate::decoder::DecoderReadExt;
|
||||||
use crate::error::DecodeError;
|
use crate::error::DecodeError;
|
||||||
@ -261,8 +277,17 @@ pub mod uuid_hyp_str {
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub fn decode<R: Read>(reader: &mut R) -> Result<Uuid, DecodeError> {
|
pub fn decode<R: Read>(reader: &mut R) -> Result<Uuid, DecodeError> {
|
||||||
let uuid_hyphenated_string = reader.read_string(36)?;
|
// TODO(timvisee): use custom encoder for this, rather than putting this in uuid_hyp_str
|
||||||
let uuid = Uuid::parse_str(&uuid_hyphenated_string)?;
|
|
||||||
|
let data = [reader.read_var_i64()?, reader.read_var_i64()?];
|
||||||
|
|
||||||
|
// TODO(timvisee): remove unsafe
|
||||||
|
let raw = unsafe { std::mem::transmute(data) };
|
||||||
|
|
||||||
|
let uuid = Uuid::from_bytes(raw);
|
||||||
|
|
||||||
|
// let uuid_hyphenated_string = reader.read_string(36)?;
|
||||||
|
// let uuid = Uuid::parse_str(&uuid_hyphenated_string)?;
|
||||||
|
|
||||||
Ok(uuid)
|
Ok(uuid)
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,19 @@ impl Encoder for Vec<CompoundTag> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): identifier encoder, we might want a custom type
|
||||||
|
impl Encoder for Vec<String> {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
writer.write_var_i32(self.len() as i32)?;
|
||||||
|
|
||||||
|
for s in self {
|
||||||
|
writer.write_string(&s, 32767)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod var_int {
|
pub mod var_int {
|
||||||
use crate::encoder::EncoderWriteExt;
|
use crate::encoder::EncoderWriteExt;
|
||||||
use crate::error::EncodeError;
|
use crate::error::EncodeError;
|
||||||
@ -222,11 +235,19 @@ pub mod uuid_hyp_str {
|
|||||||
use crate::encoder::EncoderWriteExt;
|
use crate::encoder::EncoderWriteExt;
|
||||||
use crate::error::EncodeError;
|
use crate::error::EncodeError;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use uuid::Uuid;
|
use uuid::{Uuid, Version};
|
||||||
|
|
||||||
pub fn encode<W: Write>(value: &Uuid, writer: &mut W) -> Result<(), EncodeError> {
|
pub fn encode<W: Write>(value: &Uuid, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
let uuid_hyphenated_string = value.to_hyphenated().to_string();
|
// TODO(timvisee): use custom encoder for this, rather than putting this in uuid_hyp_str
|
||||||
writer.write_string(&uuid_hyphenated_string, 36)?;
|
match value.get_version() {
|
||||||
|
Some(Version::Md5) => {
|
||||||
|
writer.write_all(value.as_bytes())?;
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let uuid_hyphenated_string = value.to_hyphenated().to_string();
|
||||||
|
writer.write_string(&uuid_hyphenated_string, 36)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1 +1,19 @@
|
|||||||
pub mod v1_14_4;
|
pub mod v1_14_4;
|
||||||
|
pub mod v1_17_1;
|
||||||
|
|
||||||
|
/// Trait to obtain packet ID from packet data.
|
||||||
|
pub trait PacketId {
|
||||||
|
/// Get protcol packet ID.
|
||||||
|
fn packet_id(&self) -> u8;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! trait_packet_id (
|
||||||
|
($type: ident, $id: expr) => (
|
||||||
|
impl PacketId for $type {
|
||||||
|
fn packet_id(&self) -> u8 {
|
||||||
|
$id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
@ -3,6 +3,7 @@ use crate::decoder::Decoder;
|
|||||||
use crate::decoder::DecoderReadExt;
|
use crate::decoder::DecoderReadExt;
|
||||||
use crate::encoder::EncoderWriteExt;
|
use crate::encoder::EncoderWriteExt;
|
||||||
use crate::error::DecodeError;
|
use crate::error::DecodeError;
|
||||||
|
use crate::{trait_packet_id, version::PacketId};
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||||
use minecraft_protocol_derive::{Decoder, Encoder};
|
use minecraft_protocol_derive::{Decoder, Encoder};
|
||||||
use nbt::CompoundTag;
|
use nbt::CompoundTag;
|
||||||
@ -54,11 +55,11 @@ impl GameServerBoundPacket {
|
|||||||
impl GameClientBoundPacket {
|
impl GameClientBoundPacket {
|
||||||
pub fn get_type_id(&self) -> u8 {
|
pub fn get_type_id(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
GameClientBoundPacket::ClientBoundChatMessage(_) => 0x0E,
|
GameClientBoundPacket::ClientBoundChatMessage(_) => 0x0F,
|
||||||
GameClientBoundPacket::GameDisconnect(_) => 0x1A,
|
GameClientBoundPacket::GameDisconnect(_) => 0x1A,
|
||||||
GameClientBoundPacket::ClientBoundKeepAlive(_) => 0x20,
|
GameClientBoundPacket::ClientBoundKeepAlive(_) => 0x20,
|
||||||
GameClientBoundPacket::ChunkData(_) => 0x21,
|
GameClientBoundPacket::ChunkData(_) => 0x21,
|
||||||
GameClientBoundPacket::JoinGame(_) => 0x25,
|
GameClientBoundPacket::JoinGame(_) => 0x26,
|
||||||
GameClientBoundPacket::BossBar(_) => 0x0D,
|
GameClientBoundPacket::BossBar(_) => 0x0D,
|
||||||
GameClientBoundPacket::EntityAction(_) => 0x1B,
|
GameClientBoundPacket::EntityAction(_) => 0x1B,
|
||||||
}
|
}
|
||||||
@ -732,3 +733,15 @@ mod tests {
|
|||||||
assert!(abilities.creative_mode);
|
assert!(abilities.creative_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait_packet_id!(ServerBoundChatMessage, 0x03);
|
||||||
|
trait_packet_id!(ServerBoundKeepAlive, 0x0F);
|
||||||
|
trait_packet_id!(ServerBoundAbilities, 0x19);
|
||||||
|
|
||||||
|
trait_packet_id!(ClientBoundChatMessage, 0x0F);
|
||||||
|
trait_packet_id!(GameDisconnect, 0x1A);
|
||||||
|
trait_packet_id!(ClientBoundKeepAlive, 0x21);
|
||||||
|
trait_packet_id!(ChunkData, 0x21);
|
||||||
|
trait_packet_id!(JoinGame, 0x25);
|
||||||
|
trait_packet_id!(BossBar, 0x0D);
|
||||||
|
trait_packet_id!(EntityAction, 0x1B);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::decoder::Decoder;
|
use crate::decoder::Decoder;
|
||||||
use crate::error::DecodeError;
|
use crate::error::DecodeError;
|
||||||
|
use crate::{trait_packet_id, version::PacketId};
|
||||||
use minecraft_protocol_derive::{Decoder, Encoder};
|
use minecraft_protocol_derive::{Decoder, Encoder};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ impl HandshakeServerBoundPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Encoder, Decoder, Debug)]
|
#[derive(Clone, Encoder, Decoder, Debug)]
|
||||||
pub struct Handshake {
|
pub struct Handshake {
|
||||||
#[data_type(with = "var_int")]
|
#[data_type(with = "var_int")]
|
||||||
pub protocol_version: i32,
|
pub protocol_version: i32,
|
||||||
@ -53,3 +54,5 @@ impl Handshake {
|
|||||||
HandshakeServerBoundPacket::Handshake(handshake)
|
HandshakeServerBoundPacket::Handshake(handshake)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait_packet_id!(Handshake, 0x00);
|
||||||
|
@ -4,6 +4,7 @@ use uuid::Uuid;
|
|||||||
use crate::data::chat::Message;
|
use crate::data::chat::Message;
|
||||||
use crate::decoder::Decoder;
|
use crate::decoder::Decoder;
|
||||||
use crate::error::DecodeError;
|
use crate::error::DecodeError;
|
||||||
|
use crate::{trait_packet_id, version::PacketId};
|
||||||
use minecraft_protocol_derive::{Decoder, Encoder};
|
use minecraft_protocol_derive::{Decoder, Encoder};
|
||||||
|
|
||||||
pub enum LoginServerBoundPacket {
|
pub enum LoginServerBoundPacket {
|
||||||
@ -480,3 +481,13 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait_packet_id!(LoginStart, 0x00);
|
||||||
|
trait_packet_id!(EncryptionResponse, 0x01);
|
||||||
|
trait_packet_id!(LoginPluginResponse, 0x02);
|
||||||
|
|
||||||
|
trait_packet_id!(LoginDisconnect, 0x00);
|
||||||
|
trait_packet_id!(EncryptionRequest, 0x01);
|
||||||
|
trait_packet_id!(LoginSuccess, 0x02);
|
||||||
|
trait_packet_id!(SetCompression, 0x03);
|
||||||
|
trait_packet_id!(LoginPluginRequest, 0x04);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use crate::data::server_status::*;
|
use crate::data::server_status::*;
|
||||||
use crate::decoder::Decoder;
|
use crate::decoder::Decoder;
|
||||||
use crate::error::DecodeError;
|
use crate::error::DecodeError;
|
||||||
|
use crate::{trait_packet_id, version::PacketId};
|
||||||
use minecraft_protocol_derive::{Decoder, Encoder};
|
use minecraft_protocol_derive::{Decoder, Encoder};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
pub enum StatusServerBoundPacket {
|
pub enum StatusServerBoundPacket {
|
||||||
StatusRequest,
|
StatusRequest(StatusRequest),
|
||||||
PingRequest(PingRequest),
|
PingRequest(PingRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,14 +18,14 @@ pub enum StatusClientBoundPacket {
|
|||||||
impl StatusServerBoundPacket {
|
impl StatusServerBoundPacket {
|
||||||
pub fn get_type_id(&self) -> u8 {
|
pub fn get_type_id(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
StatusServerBoundPacket::StatusRequest => 0x00,
|
StatusServerBoundPacket::StatusRequest(_) => 0x00,
|
||||||
StatusServerBoundPacket::PingRequest(_) => 0x01,
|
StatusServerBoundPacket::PingRequest(_) => 0x01,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
||||||
match type_id {
|
match type_id {
|
||||||
0x00 => Ok(StatusServerBoundPacket::StatusRequest),
|
0x00 => Ok(StatusServerBoundPacket::StatusRequest(StatusRequest {})),
|
||||||
0x01 => {
|
0x01 => {
|
||||||
let ping_request = PingRequest::decode(reader)?;
|
let ping_request = PingRequest::decode(reader)?;
|
||||||
|
|
||||||
@ -70,6 +71,15 @@ impl PingResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct StatusRequest {}
|
||||||
|
|
||||||
|
impl StatusRequest {
|
||||||
|
pub fn new() -> StatusServerBoundPacket {
|
||||||
|
StatusServerBoundPacket::StatusRequest(StatusRequest {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Encoder, Decoder, Debug)]
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
pub struct StatusResponse {
|
pub struct StatusResponse {
|
||||||
pub server_status: ServerStatus,
|
pub server_status: ServerStatus,
|
||||||
@ -198,3 +208,9 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait_packet_id!(StatusRequest, 0x00);
|
||||||
|
trait_packet_id!(PingRequest, 0x01);
|
||||||
|
|
||||||
|
trait_packet_id!(StatusResponse, 0x00);
|
||||||
|
trait_packet_id!(PingResponse, 0x01);
|
||||||
|
313
protocol/src/version/v1_17_1/game.rs
Normal file
313
protocol/src/version/v1_17_1/game.rs
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
use crate::data::chat::Message;
|
||||||
|
use crate::decoder::Decoder;
|
||||||
|
use crate::error::DecodeError;
|
||||||
|
use crate::{trait_packet_id, version::PacketId};
|
||||||
|
use minecraft_protocol_derive::Decoder;
|
||||||
|
use minecraft_protocol_derive::Encoder;
|
||||||
|
use nbt::CompoundTag;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
// Re-export Minecraft 1.14.4 types
|
||||||
|
pub use super::super::v1_14_4::game::{
|
||||||
|
BossBar, ChunkData, ClientBoundChatMessage, ClientBoundKeepAlive, EntityAction, GameDisconnect,
|
||||||
|
ServerBoundAbilities, ServerBoundChatMessage, ServerBoundKeepAlive,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub enum GameServerBoundPacket {
|
||||||
|
ServerBoundChatMessage(ServerBoundChatMessage),
|
||||||
|
ServerBoundPluginMessage(ServerBoundPluginMessage),
|
||||||
|
ServerBoundKeepAlive(ServerBoundKeepAlive),
|
||||||
|
ServerBoundAbilities(ServerBoundAbilities),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum GameClientBoundPacket {
|
||||||
|
ClientBoundChatMessage(ClientBoundChatMessage),
|
||||||
|
JoinGame(JoinGame),
|
||||||
|
ClientBoundKeepAlive(ClientBoundKeepAlive),
|
||||||
|
ChunkData(ChunkData),
|
||||||
|
GameDisconnect(GameDisconnect),
|
||||||
|
BossBar(BossBar),
|
||||||
|
EntityAction(EntityAction),
|
||||||
|
|
||||||
|
ClientBoundPluginMessage(ClientBoundPluginMessage),
|
||||||
|
NamedSoundEffect(NamedSoundEffect),
|
||||||
|
Respawn(Respawn),
|
||||||
|
PlayerPositionAndLook(PlayerPositionAndLook),
|
||||||
|
SpawnPosition(SpawnPosition),
|
||||||
|
SetTitleSubtitle(SetTitleSubtitle),
|
||||||
|
SetTitleText(SetTitleText),
|
||||||
|
TimeUpdate(TimeUpdate),
|
||||||
|
SetTitleTimes(SetTitleTimes),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GameServerBoundPacket {
|
||||||
|
pub fn get_type_id(&self) -> u8 {
|
||||||
|
match self {
|
||||||
|
GameServerBoundPacket::ServerBoundChatMessage(_) => 0x03,
|
||||||
|
GameServerBoundPacket::ServerBoundPluginMessage(_) => 0x0A,
|
||||||
|
GameServerBoundPacket::ServerBoundKeepAlive(_) => 0x0F,
|
||||||
|
GameServerBoundPacket::ServerBoundAbilities(_) => 0x19,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
||||||
|
match type_id {
|
||||||
|
0x03 => {
|
||||||
|
let chat_message = ServerBoundChatMessage::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameServerBoundPacket::ServerBoundChatMessage(chat_message))
|
||||||
|
}
|
||||||
|
0x0A => {
|
||||||
|
let plugin_message = ServerBoundPluginMessage::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameServerBoundPacket::ServerBoundPluginMessage(
|
||||||
|
plugin_message,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
0x0F => {
|
||||||
|
let keep_alive = ServerBoundKeepAlive::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameServerBoundPacket::ServerBoundKeepAlive(keep_alive))
|
||||||
|
}
|
||||||
|
0x19 => {
|
||||||
|
let abilities = ServerBoundAbilities::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameServerBoundPacket::ServerBoundAbilities(abilities))
|
||||||
|
}
|
||||||
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GameClientBoundPacket {
|
||||||
|
pub fn get_type_id(&self) -> u8 {
|
||||||
|
match self {
|
||||||
|
GameClientBoundPacket::ClientBoundChatMessage(_) => 0x0E,
|
||||||
|
GameClientBoundPacket::ClientBoundPluginMessage(_) => 0x18,
|
||||||
|
GameClientBoundPacket::NamedSoundEffect(_) => 0x19,
|
||||||
|
GameClientBoundPacket::GameDisconnect(_) => 0x1A,
|
||||||
|
GameClientBoundPacket::ClientBoundKeepAlive(_) => 0x20,
|
||||||
|
GameClientBoundPacket::ChunkData(_) => 0x21,
|
||||||
|
GameClientBoundPacket::JoinGame(_) => 0x25,
|
||||||
|
GameClientBoundPacket::BossBar(_) => 0x0D,
|
||||||
|
GameClientBoundPacket::EntityAction(_) => 0x1B,
|
||||||
|
GameClientBoundPacket::PlayerPositionAndLook(_) => 0x38,
|
||||||
|
GameClientBoundPacket::Respawn(_) => 0x3D,
|
||||||
|
GameClientBoundPacket::SpawnPosition(_) => 0x4B,
|
||||||
|
GameClientBoundPacket::SetTitleSubtitle(_) => 0x57,
|
||||||
|
GameClientBoundPacket::TimeUpdate(_) => 0x58,
|
||||||
|
GameClientBoundPacket::SetTitleText(_) => 0x59,
|
||||||
|
GameClientBoundPacket::SetTitleTimes(_) => 0x5A,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
||||||
|
match type_id {
|
||||||
|
0x0E => {
|
||||||
|
let chat_message = ClientBoundChatMessage::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::ClientBoundChatMessage(chat_message))
|
||||||
|
}
|
||||||
|
0x18 => {
|
||||||
|
let plugin_message = ClientBoundPluginMessage::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::ClientBoundPluginMessage(
|
||||||
|
plugin_message,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
0x19 => {
|
||||||
|
let named_sound_effect = NamedSoundEffect::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::NamedSoundEffect(named_sound_effect))
|
||||||
|
}
|
||||||
|
0x1A => {
|
||||||
|
let game_disconnect = GameDisconnect::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::GameDisconnect(game_disconnect))
|
||||||
|
}
|
||||||
|
0x20 => {
|
||||||
|
let keep_alive = ClientBoundKeepAlive::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::ClientBoundKeepAlive(keep_alive))
|
||||||
|
}
|
||||||
|
0x21 => {
|
||||||
|
let chunk_data = ChunkData::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::ChunkData(chunk_data))
|
||||||
|
}
|
||||||
|
0x25 => {
|
||||||
|
let join_game = JoinGame::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::JoinGame(join_game))
|
||||||
|
}
|
||||||
|
0x3D => {
|
||||||
|
let respawn = Respawn::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::Respawn(respawn))
|
||||||
|
}
|
||||||
|
0x38 => {
|
||||||
|
let player_position = PlayerPositionAndLook::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::PlayerPositionAndLook(
|
||||||
|
player_position,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
0x4B => {
|
||||||
|
let spawn_position = SpawnPosition::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::SpawnPosition(spawn_position))
|
||||||
|
}
|
||||||
|
0x57 => {
|
||||||
|
let title_subtitle = SetTitleSubtitle::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::SetTitleSubtitle(title_subtitle))
|
||||||
|
}
|
||||||
|
0x58 => {
|
||||||
|
let time_update = TimeUpdate::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::TimeUpdate(time_update))
|
||||||
|
}
|
||||||
|
0x59 => {
|
||||||
|
let title_text = SetTitleText::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::SetTitleText(title_text))
|
||||||
|
}
|
||||||
|
0x5A => {
|
||||||
|
let title_times = SetTitleTimes::decode(reader)?;
|
||||||
|
|
||||||
|
Ok(GameClientBoundPacket::SetTitleTimes(title_times))
|
||||||
|
}
|
||||||
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct ServerBoundPluginMessage {
|
||||||
|
#[data_type(max_length = 32767)]
|
||||||
|
pub channel: String,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct ClientBoundPluginMessage {
|
||||||
|
#[data_type(max_length = 32767)]
|
||||||
|
pub channel: String,
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
// TODO(timvisee): remove clone?
|
||||||
|
#[derive(Clone, Encoder, Decoder, Debug)]
|
||||||
|
pub struct NamedSoundEffect {
|
||||||
|
#[data_type(max_length = 32767)]
|
||||||
|
pub sound_name: String,
|
||||||
|
#[data_type(with = "var_int")]
|
||||||
|
pub sound_category: i32,
|
||||||
|
// Mulitplied by 8
|
||||||
|
pub effect_pos_x: i32,
|
||||||
|
// Mulitplied by 8
|
||||||
|
pub effect_pos_y: i32,
|
||||||
|
// Mulitplied by 8
|
||||||
|
pub effect_pos_z: i32,
|
||||||
|
pub volume: f32,
|
||||||
|
pub pitch: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
// TODO(timvisee): remove clone?
|
||||||
|
#[derive(Clone, Encoder, Decoder, Debug)]
|
||||||
|
pub struct JoinGame {
|
||||||
|
pub entity_id: u32,
|
||||||
|
pub hardcore: bool,
|
||||||
|
pub game_mode: u8,
|
||||||
|
pub previous_game_mode: u8,
|
||||||
|
// TODO: max string length: 32767
|
||||||
|
pub world_names: Vec<String>,
|
||||||
|
pub dimension_codec: CompoundTag,
|
||||||
|
pub dimension: CompoundTag,
|
||||||
|
#[data_type(max_length = 32767)]
|
||||||
|
pub world_name: String,
|
||||||
|
pub hashed_seed: i64,
|
||||||
|
#[data_type(with = "var_int")]
|
||||||
|
pub max_players: i32,
|
||||||
|
#[data_type(with = "var_int")]
|
||||||
|
pub view_distance: i32,
|
||||||
|
pub reduced_debug_info: bool,
|
||||||
|
pub enable_respawn_screen: bool,
|
||||||
|
pub is_debug: bool,
|
||||||
|
pub is_flat: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct Respawn {
|
||||||
|
pub dimension: CompoundTag,
|
||||||
|
#[data_type(max_length = 32767)]
|
||||||
|
pub world_name: String,
|
||||||
|
pub hashed_seed: i64,
|
||||||
|
pub game_mode: u8,
|
||||||
|
pub previous_game_mode: u8,
|
||||||
|
pub is_debug: bool,
|
||||||
|
pub is_flat: bool,
|
||||||
|
pub copy_metadata: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct PlayerPositionAndLook {
|
||||||
|
pub x: f64,
|
||||||
|
pub y: f64,
|
||||||
|
pub z: f64,
|
||||||
|
pub yaw: f32,
|
||||||
|
pub pitch: f32,
|
||||||
|
pub flags: u8,
|
||||||
|
#[data_type(with = "var_int")]
|
||||||
|
pub teleport_id: i32,
|
||||||
|
pub dismount_vehicle: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(timvisee): implement new()
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct TimeUpdate {
|
||||||
|
pub world_age: i64,
|
||||||
|
pub time_of_day: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct SetTitleText {
|
||||||
|
pub text: Message,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct SetTitleSubtitle {
|
||||||
|
pub text: Message,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct SetTitleTimes {
|
||||||
|
pub fade_in: i32,
|
||||||
|
pub stay: i32,
|
||||||
|
pub fade_out: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encoder, Decoder, Debug)]
|
||||||
|
pub struct SpawnPosition {
|
||||||
|
pub position: u64,
|
||||||
|
pub angle: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
trait_packet_id!(ServerBoundPluginMessage, 0x0A);
|
||||||
|
|
||||||
|
trait_packet_id!(ClientBoundPluginMessage, 0x18);
|
||||||
|
trait_packet_id!(NamedSoundEffect, 0x19);
|
||||||
|
trait_packet_id!(JoinGame, 0x26);
|
||||||
|
trait_packet_id!(PlayerPositionAndLook, 0x38);
|
||||||
|
trait_packet_id!(Respawn, 0x3D);
|
||||||
|
trait_packet_id!(SpawnPosition, 0x4B);
|
||||||
|
trait_packet_id!(SetTitleSubtitle, 0x57);
|
||||||
|
trait_packet_id!(TimeUpdate, 0x58);
|
||||||
|
trait_packet_id!(SetTitleText, 0x59);
|
||||||
|
trait_packet_id!(SetTitleTimes, 0x5A);
|
1
protocol/src/version/v1_17_1/mod.rs
Normal file
1
protocol/src/version/v1_17_1/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod game;
|
Loading…
x
Reference in New Issue
Block a user