diff --git a/Cargo.lock b/Cargo.lock index bc73aef..e502c79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,7 +869,7 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "minecraft-protocol" version = "0.1.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=5b80bc2#5b80bc2df31e07e2e6e203e652a301bd8a29a610" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=edfdf87#edfdf876c0c21be02afdd885e3400983f3137ec9" dependencies = [ "byteorder", "minecraft-protocol-derive", @@ -882,7 +882,7 @@ dependencies = [ [[package]] name = "minecraft-protocol-derive" version = "0.0.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=5b80bc2#5b80bc2df31e07e2e6e203e652a301bd8a29a610" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=edfdf87#edfdf876c0c21be02afdd885e3400983f3137ec9" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0f2fd37..f26f896 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ dotenv = "0.15" flate2 = { version = "1.0", default-features = false, features = ["default"] } futures = { version = "0.3", default-features = false, features = ["executor"] } log = "0.4" -minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "5b80bc2" } +minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "edfdf87" } named-binary-tag = "0.6" notify = "4.0" pretty_env_logger = "0.4" diff --git a/docs/join-method-lobby.md b/docs/join-method-lobby.md index d2a6b23..19dee51 100644 --- a/docs/join-method-lobby.md +++ b/docs/join-method-lobby.md @@ -23,7 +23,7 @@ Current limitations: - Only works with offline mode - Only works with vanilla Minecraft clients, does not work with modded (e.g. Forge, FTB) -- Probably only works with Minecraft 1.17-1.17.1 (tested with 1.17.1) +- Probably only works with Minecraft 1.16.3-1.17.1 (tested with 1.17.1) - This method will consume the client, following configured join methods won't be used. At this time it is unknown if some of the above limitations will ever be lifted, diff --git a/res/lazymc.toml b/res/lazymc.toml index 7d2068a..51c7a12 100644 --- a/res/lazymc.toml +++ b/res/lazymc.toml @@ -134,7 +134,7 @@ command = "java -Xmx1G -Xms1G -jar server.jar --nogui" # Don't enable this unless you know what you're doing. # # - Only works with offline mode -# - Only works with Minecraft 1.17-1.17.1 (tested with 1.17.1) +# - Only works with Minecraft 1.16.3-1.17.1 (tested with 1.17.1) # - Only works with vanilla Minecraft clients, does not work with modded # Maximum time in seconds in the lobby while the server starts. diff --git a/src/proto/packets/play/join_game.rs b/src/proto/packets/play/join_game.rs index c26fbb0..32131a4 100644 --- a/src/proto/packets/play/join_game.rs +++ b/src/proto/packets/play/join_game.rs @@ -1,6 +1,6 @@ use minecraft_protocol::decoder::Decoder; use minecraft_protocol::error::DecodeError; -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use nbt::CompoundTag; #[cfg(feature = "lobby")] use tokio::net::tcp::WriteHalf; @@ -33,16 +33,16 @@ impl JoinGameData { /// Extract join game data from given packet. pub fn from_packet(client_info: &ClientInfo, packet: RawPacket) -> Result { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { - Ok(v1_16_5::game::JoinGame::decode(&mut packet.data.as_slice())?.into()) + Some(p) if p <= v1_16_3::PROTOCOL => { + Ok(v1_16_3::game::JoinGame::decode(&mut packet.data.as_slice())?.into()) } _ => Ok(v1_17::game::JoinGame::decode(&mut packet.data.as_slice())?.into()), } } } -impl From for JoinGameData { - fn from(join_game: v1_16_5::game::JoinGame) -> Self { +impl From for JoinGameData { + fn from(join_game: v1_16_3::game::JoinGame) -> Self { Self { dimension: Some(join_game.dimension), dimension_codec: Some(join_game.dimension_codec), @@ -74,7 +74,7 @@ impl From for JoinGameData { /// Check whether the packet ID matches. pub fn is_packet(client_info: &ClientInfo, packet_id: u8) -> bool { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => packet_id == v1_16_5::game::JoinGame::PACKET_ID, + Some(p) if p <= v1_16_3::PROTOCOL => packet_id == v1_16_3::game::JoinGame::PACKET_ID, _ => packet_id == v1_17::game::JoinGame::PACKET_ID, } } @@ -102,9 +102,9 @@ pub async fn lobby_send( let status = server.status().await; match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::JoinGame { + v1_16_3::game::JoinGame { // Player ID must be unique, if it collides with another server entity ID the player gets // in a weird state and cannot move entity_id: 0, diff --git a/src/proto/packets/play/keep_alive.rs b/src/proto/packets/play/keep_alive.rs index 6bc3044..babd844 100644 --- a/src/proto/packets/play/keep_alive.rs +++ b/src/proto/packets/play/keep_alive.rs @@ -1,6 +1,6 @@ use std::sync::atomic::{AtomicU64, Ordering}; -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use crate::proto::client::{Client, ClientInfo}; @@ -21,8 +21,8 @@ pub async fn send( let id = KEEP_ALIVE_ID.fetch_add(1, Ordering::Relaxed); match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { - packet::write_packet(v1_16_5::game::ClientBoundKeepAlive { id }, client, writer).await + Some(p) if p <= v1_16_3::PROTOCOL => { + packet::write_packet(v1_16_3::game::ClientBoundKeepAlive { id }, client, writer).await } _ => packet::write_packet(v1_17::game::ClientBoundKeepAlive { id }, client, writer).await, } diff --git a/src/proto/packets/play/player_pos.rs b/src/proto/packets/play/player_pos.rs index 5dac1c9..4bedb3b 100644 --- a/src/proto/packets/play/player_pos.rs +++ b/src/proto/packets/play/player_pos.rs @@ -1,4 +1,4 @@ -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use crate::proto::client::{Client, ClientInfo}; @@ -11,9 +11,9 @@ pub async fn send( writer: &mut WriteHalf<'_>, ) -> Result<(), ()> { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::PlayerPositionAndLook { + v1_16_3::game::PlayerPositionAndLook { x: 0.0, y: 0.0, z: 0.0, diff --git a/src/proto/packets/play/respawn.rs b/src/proto/packets/play/respawn.rs index aaa11d0..25ed908 100644 --- a/src/proto/packets/play/respawn.rs +++ b/src/proto/packets/play/respawn.rs @@ -1,4 +1,4 @@ -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use super::join_game::JoinGameData; @@ -16,9 +16,9 @@ pub async fn lobby_send( data: JoinGameData, ) -> Result<(), ()> { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::Respawn { + v1_16_3::game::Respawn { dimension: data.dimension.unwrap_or_else(|| { dimension::lobby_dimension( &data diff --git a/src/proto/packets/play/server_brand.rs b/src/proto/packets/play/server_brand.rs index 033c4ab..1f0391e 100644 --- a/src/proto/packets/play/server_brand.rs +++ b/src/proto/packets/play/server_brand.rs @@ -1,4 +1,4 @@ -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use crate::proto::client::{Client, ClientInfo}; @@ -19,9 +19,9 @@ pub async fn send( writer: &mut WriteHalf<'_>, ) -> Result<(), ()> { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::ClientBoundPluginMessage { + v1_16_3::game::ClientBoundPluginMessage { channel: CHANNEL.into(), data: SERVER_BRAND.into(), }, diff --git a/src/proto/packets/play/sound.rs b/src/proto/packets/play/sound.rs index d2fea4d..9366563 100644 --- a/src/proto/packets/play/sound.rs +++ b/src/proto/packets/play/sound.rs @@ -1,4 +1,4 @@ -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use crate::proto::client::{Client, ClientInfo}; @@ -12,9 +12,9 @@ pub async fn send( sound_name: &str, ) -> Result<(), ()> { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::NamedSoundEffect { + v1_16_3::game::NamedSoundEffect { sound_name: sound_name.into(), sound_category: 0, effect_pos_x: 0, diff --git a/src/proto/packets/play/time_update.rs b/src/proto/packets/play/time_update.rs index 28fab10..e7cd5ec 100644 --- a/src/proto/packets/play/time_update.rs +++ b/src/proto/packets/play/time_update.rs @@ -1,4 +1,4 @@ -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; use crate::proto::client::{Client, ClientInfo}; @@ -15,9 +15,9 @@ pub async fn send( writer: &mut WriteHalf<'_>, ) -> Result<(), ()> { match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => { + Some(p) if p <= v1_16_3::PROTOCOL => { packet::write_packet( - v1_16_5::game::TimeUpdate { + v1_16_3::game::TimeUpdate { world_age: 0, time_of_day: 0, }, diff --git a/src/proto/packets/play/title.rs b/src/proto/packets/play/title.rs index 4a67ad3..eae4125 100644 --- a/src/proto/packets/play/title.rs +++ b/src/proto/packets/play/title.rs @@ -1,5 +1,5 @@ use minecraft_protocol::data::chat::{Message, Payload}; -use minecraft_protocol::version::{v1_16_5, v1_17}; +use minecraft_protocol::version::{v1_16_3, v1_17}; use tokio::net::tcp::WriteHalf; #[cfg(feature = "lobby")] @@ -29,18 +29,18 @@ pub async fn send( let subtitle = text.lines().skip(1).collect::>().join("\n"); match client_info.protocol() { - Some(p) if p <= v1_16_5::PROTOCOL => send_v1_16_5(client, writer, title, &subtitle).await, + Some(p) if p <= v1_16_3::PROTOCOL => send_v1_16_3(client, writer, title, &subtitle).await, _ => send_v1_17(client, writer, title, &subtitle).await, } } -async fn send_v1_16_5( +async fn send_v1_16_3( client: &Client, writer: &mut WriteHalf<'_>, title: &str, subtitle: &str, ) -> Result<(), ()> { - use v1_16_5::game::{Title, TitleAction}; + use v1_16_3::game::{Title, TitleAction}; // Set title packet::write_packet(