mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
fix merge issues
This commit is contained in:
commit
8a507244d3
63 changed files with 352 additions and 209 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
@ -100,7 +100,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea"
|
name = "azalea"
|
||||||
version = "0.2.4"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -115,7 +115,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-auth"
|
name = "azalea-auth"
|
||||||
version = "0.2.2"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
"azalea-crypto",
|
"azalea-crypto",
|
||||||
|
@ -133,7 +133,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-block"
|
name = "azalea-block"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-block-macros",
|
"azalea-block-macros",
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
|
@ -141,7 +141,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-block-macros"
|
name = "azalea-block-macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -150,11 +150,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-brigadier"
|
name = "azalea-brigadier"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-buf"
|
name = "azalea-buf"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-buf-macros",
|
"azalea-buf-macros",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -166,7 +166,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-buf-macros"
|
name = "azalea-buf-macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -175,7 +175,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-chat"
|
name = "azalea-chat"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
"azalea-language",
|
"azalea-language",
|
||||||
|
@ -186,7 +186,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-client"
|
name = "azalea-client"
|
||||||
version = "0.2.2"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"azalea-auth",
|
"azalea-auth",
|
||||||
|
@ -206,7 +206,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-core"
|
name = "azalea-core"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
"azalea-chat",
|
"azalea-chat",
|
||||||
|
@ -216,7 +216,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-crypto"
|
name = "azalea-crypto"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
|
@ -231,7 +231,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-language"
|
name = "azalea-language"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -240,7 +240,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-nbt"
|
name = "azalea-nbt"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
|
@ -269,7 +269,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-physics"
|
name = "azalea-physics"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-block",
|
"azalea-block",
|
||||||
"azalea-core",
|
"azalea-core",
|
||||||
|
@ -280,7 +280,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-protocol"
|
name = "azalea-protocol"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-compression",
|
"async-compression",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
|
@ -312,7 +312,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-protocol-macros"
|
name = "azalea-protocol-macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -321,7 +321,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-registry"
|
name = "azalea-registry"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
"azalea-registry-macros",
|
"azalea-registry-macros",
|
||||||
|
@ -329,7 +329,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-registry-macros"
|
name = "azalea-registry-macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -338,7 +338,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "azalea-world"
|
name = "azalea-world"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azalea-block",
|
"azalea-block",
|
||||||
"azalea-buf",
|
"azalea-buf",
|
||||||
|
|
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 mat
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -1,5 +1,7 @@
|
||||||
# Azalea
|
# Azalea
|
||||||
|
|
||||||
|
[](https://docs.rs/azalea)
|
||||||
|
|
||||||
A collection of Rust crates for making Minecraft bots, clients, and tools.
|
A collection of Rust crates for making Minecraft bots, clients, and tools.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
@ -9,7 +11,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools.
|
||||||
<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
|
<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
|
||||||
*Currently supported Minecraft version: `1.19.2`.*
|
*Currently supported Minecraft version: `1.19.2`.*
|
||||||
|
|
||||||
## ⚠️ Azalea is still very unfinished, though some crates are in a somewhat useable state
|
## ⚠️ Azalea is still very unfinished, though most crates are in a somewhat useable state
|
||||||
|
|
||||||
|
|
||||||
I named this Azalea because it sounds like a cool word and this is a cool library.
|
I named this Azalea because it sounds like a cool word and this is a cool library.
|
||||||
|
|
|
@ -3,23 +3,24 @@ description = "A port of Mojang's Authlib and launcher authentication."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-auth"
|
name = "azalea-auth"
|
||||||
version = "0.2.2"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-auth"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf = { path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
azalea-crypto = { path = "../azalea-crypto", version = "^0.2.0" }
|
azalea-crypto = {path = "../azalea-crypto", version = "^0.3.0" }
|
||||||
chrono = { version = "0.4.22", default-features = false }
|
chrono = {version = "0.4.22", default-features = false}
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
num-bigint = "0.4.3"
|
num-bigint = "0.4.3"
|
||||||
reqwest = { version = "0.11.12", features = ["json"] }
|
reqwest = {version = "0.11.12", features = ["json"]}
|
||||||
serde = { version = "1.0.145", features = ["derive"] }
|
serde = {version = "1.0.145", features = ["derive"]}
|
||||||
serde_json = "1.0.86"
|
serde_json = "1.0.86"
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
tokio = { version = "1.21.2", features = ["fs"] }
|
tokio = {version = "1.21.2", features = ["fs"]}
|
||||||
uuid = "^1.1.2"
|
uuid = "^1.1.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.9.1"
|
env_logger = "0.9.1"
|
||||||
tokio = { version = "1.21.2", features = ["full"] }
|
tokio = {version = "1.21.2", features = ["full"]}
|
||||||
|
|
|
@ -444,10 +444,7 @@ async fn check_ownership(
|
||||||
) -> Result<bool, CheckOwnershipError> {
|
) -> Result<bool, CheckOwnershipError> {
|
||||||
let res = client
|
let res = client
|
||||||
.get("https://api.minecraftservices.com/entitlements/mcstore")
|
.get("https://api.minecraftservices.com/entitlements/mcstore")
|
||||||
.header(
|
.header("Authorization", format!("Bearer {minecraft_access_token}"))
|
||||||
"Authorization",
|
|
||||||
format!("Bearer {minecraft_access_token}"),
|
|
||||||
)
|
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.json::<GameOwnershipResponse>()
|
.json::<GameOwnershipResponse>()
|
||||||
|
@ -472,10 +469,7 @@ async fn get_profile(
|
||||||
) -> Result<ProfileResponse, GetProfileError> {
|
) -> Result<ProfileResponse, GetProfileError> {
|
||||||
let res = client
|
let res = client
|
||||||
.get("https://api.minecraftservices.com/minecraft/profile")
|
.get("https://api.minecraftservices.com/minecraft/profile")
|
||||||
.header(
|
.header("Authorization", format!("Bearer {minecraft_access_token}"))
|
||||||
"Authorization",
|
|
||||||
format!("Bearer {minecraft_access_token}"),
|
|
||||||
)
|
|
||||||
.send()
|
.send()
|
||||||
.await?
|
.await?
|
||||||
.json::<ProfileResponse>()
|
.json::<ProfileResponse>()
|
||||||
|
|
|
@ -3,12 +3,13 @@ description = "Representation of Minecraft block states."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-block"
|
name = "azalea-block"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-block"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-block-macros = {path = "./azalea-block-macros", version = "^0.2.0" }
|
azalea-block-macros = {path = "./azalea-block-macros", version = "^0.3.0" }
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "Proc macros used by azalea-block."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-block-macros"
|
name = "azalea-block-macros"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-block/azalea-block-macros"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "A port of Mojang's Brigadier command parsing and dispatching libr
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-brigadier"
|
name = "azalea-brigadier"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-brigadier"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,13 @@ description = "Serialize and deserialize buffers from Minecraft."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-buf"
|
name = "azalea-buf"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-buf"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf-macros = {path = "./azalea-buf-macros", version = "^0.2.0" }
|
azalea-buf-macros = {path = "./azalea-buf-macros", version = "^0.3.0" }
|
||||||
byteorder = "^1.4.3"
|
byteorder = "^1.4.3"
|
||||||
serde_json = {version = "^1.0", optional = true}
|
serde_json = {version = "^1.0", optional = true}
|
||||||
thiserror = "^1.0.34"
|
thiserror = "^1.0.34"
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "#[derive(McBuf)]"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-buf-macros"
|
name = "azalea-buf-macros"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-buf"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
|
@ -3,13 +3,14 @@ description = "Parse Minecraft chat messages."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-chat"
|
name = "azalea-chat"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-chat"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf = {path = "../azalea-buf", features = ["serde_json"], version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", features = ["serde_json"], version = "^0.3.0" }
|
||||||
azalea-language = {path = "../azalea-language", version = "^0.2.0" }
|
azalea-language = {path = "../azalea-language", version = "^0.3.0" }
|
||||||
lazy_static = "^1.4.0"
|
lazy_static = "^1.4.0"
|
||||||
serde = "^1.0.130"
|
serde = "^1.0.130"
|
||||||
serde_json = "^1.0.72"
|
serde_json = "^1.0.72"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{component::Component, style::Style};
|
use crate::{style::Style, Component};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BaseComponent {
|
pub struct BaseComponent {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::{
|
||||||
translatable_component::{StringOrComponent, TranslatableComponent},
|
translatable_component::{StringOrComponent, TranslatableComponent},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// A chat component, basically anything you can see in chat.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Component {
|
pub enum Component {
|
||||||
Text(TextComponent),
|
Text(TextComponent),
|
||||||
|
@ -57,7 +58,22 @@ impl Component {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this component into an ansi string
|
/// Convert this component into an
|
||||||
|
/// [ANSI string](https://en.wikipedia.org/wiki/ANSI_escape_code), so you
|
||||||
|
/// can print it to your terminal and get styling.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use azalea_chat::Component;
|
||||||
|
///
|
||||||
|
/// let component = Component::deserialize(&serde_json::json!({
|
||||||
|
/// "text": "Hello, world!",
|
||||||
|
/// "color": "red",
|
||||||
|
/// })).unwrap();
|
||||||
|
///
|
||||||
|
/// println!("{}", component.to_ansi());
|
||||||
|
/// ```
|
||||||
pub fn to_ansi(&self, default_style: Option<&Style>) -> String {
|
pub fn to_ansi(&self, default_style: Option<&Style>) -> String {
|
||||||
// default the default_style to white if it's not set
|
// default the default_style to white if it's not set
|
||||||
let default_style: &Style = default_style.unwrap_or(&DEFAULT_STYLE);
|
let default_style: &Style = default_style.unwrap_or(&DEFAULT_STYLE);
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
pub mod base_component;
|
pub mod base_component;
|
||||||
pub mod component;
|
mod component;
|
||||||
pub mod style;
|
pub mod style;
|
||||||
pub mod text_component;
|
pub mod text_component;
|
||||||
pub mod translatable_component;
|
pub mod translatable_component;
|
||||||
|
|
||||||
|
pub use component::Component;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use crate::{base_component::BaseComponent, component::Component, style::ChatFormatting};
|
use crate::{base_component::BaseComponent, style::ChatFormatting, Component};
|
||||||
|
|
||||||
|
/// A component that contains text that's the same in all locales.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct TextComponent {
|
pub struct TextComponent {
|
||||||
pub base: BaseComponent,
|
pub base: BaseComponent,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
base_component::BaseComponent, component::Component, style::Style,
|
base_component::BaseComponent, style::Style, text_component::TextComponent, Component,
|
||||||
text_component::TextComponent,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -11,6 +10,7 @@ pub enum StringOrComponent {
|
||||||
Component(Component),
|
Component(Component),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A message whose content depends on the client's language.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct TranslatableComponent {
|
pub struct TranslatableComponent {
|
||||||
pub base: BaseComponent,
|
pub base: BaseComponent,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use azalea_chat::{
|
use azalea_chat::{
|
||||||
component::Component,
|
|
||||||
style::{Ansi, ChatFormatting, TextColor},
|
style::{Ansi, ChatFormatting, TextColor},
|
||||||
|
Component,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
|
@ -3,20 +3,21 @@ description = "A headless Minecraft client."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-client"
|
name = "azalea-client"
|
||||||
version = "0.2.2"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-client"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.59"
|
anyhow = "1.0.59"
|
||||||
azalea-auth = { path = "../azalea-auth", version = "0.2.1" }
|
azalea-auth = { path = "../azalea-auth", version = "0.3.0" }
|
||||||
azalea-block = { path = "../azalea-block", version = "0.2.0" }
|
azalea-block = { path = "../azalea-block", version = "0.3.0" }
|
||||||
azalea-chat = { path = "../azalea-chat", version = "0.2.0" }
|
azalea-chat = { path = "../azalea-chat", version = "0.3.0" }
|
||||||
azalea-core = { path = "../azalea-core", version = "0.2.0" }
|
azalea-core = { path = "../azalea-core", version = "0.3.0" }
|
||||||
azalea-crypto = { path = "../azalea-crypto", version = "0.2.0" }
|
azalea-crypto = { path = "../azalea-crypto", version = "0.3.0" }
|
||||||
azalea-physics = { path = "../azalea-physics", version = "0.2.0" }
|
azalea-physics = { path = "../azalea-physics", version = "0.3.0" }
|
||||||
azalea-protocol = { path = "../azalea-protocol", version = "0.2.0" }
|
azalea-protocol = { path = "../azalea-protocol", version = "0.3.0" }
|
||||||
azalea-world = { path = "../azalea-world", version = "0.2.0" }
|
azalea-world = { path = "../azalea-world", version = "0.3.0" }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
thiserror = "^1.0.34"
|
thiserror = "^1.0.34"
|
||||||
|
|
|
@ -6,6 +6,18 @@ use uuid::Uuid;
|
||||||
/// Something that can join Minecraft servers.
|
/// Something that can join Minecraft servers.
|
||||||
///
|
///
|
||||||
/// To join a server using this account, use [`crate::Client::join`].
|
/// To join a server using this account, use [`crate::Client::join`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```rust,no_run
|
||||||
|
/// use azalea_client::Account;
|
||||||
|
///
|
||||||
|
/// # #[tokio::main]
|
||||||
|
/// # async fn main() {
|
||||||
|
/// let account = Account::microsoft("example@example.com").await;
|
||||||
|
/// // or Account::offline("example");
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Account {
|
pub struct Account {
|
||||||
/// The Minecraft username of the account.
|
/// The Minecraft username of the account.
|
||||||
|
@ -34,7 +46,12 @@ impl Account {
|
||||||
/// a key for the cache, but it's recommended to use the real email to
|
/// a key for the cache, but it's recommended to use the real email to
|
||||||
/// avoid confusion.
|
/// avoid confusion.
|
||||||
pub async fn microsoft(email: &str) -> Result<Self, azalea_auth::AuthError> {
|
pub async fn microsoft(email: &str) -> Result<Self, azalea_auth::AuthError> {
|
||||||
let minecraft_dir = get_mc_dir::minecraft_dir().unwrap();
|
let minecraft_dir = get_mc_dir::minecraft_dir().unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"No {} environment variable found",
|
||||||
|
get_mc_dir::home_env_var()
|
||||||
|
)
|
||||||
|
});
|
||||||
let auth_result = azalea_auth::auth(
|
let auth_result = azalea_auth::auth(
|
||||||
email,
|
email,
|
||||||
azalea_auth::AuthOpts {
|
azalea_auth::AuthOpts {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{movement::WalkDirection, Account, Player};
|
use crate::{movement::WalkDirection, Account, Player};
|
||||||
use azalea_auth::game_profile::GameProfile;
|
use azalea_auth::game_profile::GameProfile;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_core::{ChunkPos, ResourceLocation, Vec3};
|
use azalea_core::{ChunkPos, ResourceLocation, Vec3};
|
||||||
use azalea_protocol::{
|
use azalea_protocol::{
|
||||||
connect::{Connection, ConnectionError, ReadConnection, WriteConnection},
|
connect::{Connection, ConnectionError, ReadConnection, WriteConnection},
|
||||||
|
@ -17,6 +17,7 @@ use azalea_protocol::{
|
||||||
},
|
},
|
||||||
handshake::client_intention_packet::ClientIntentionPacket,
|
handshake::client_intention_packet::ClientIntentionPacket,
|
||||||
login::{
|
login::{
|
||||||
|
serverbound_custom_query_packet::ServerboundCustomQueryPacket,
|
||||||
serverbound_hello_packet::ServerboundHelloPacket,
|
serverbound_hello_packet::ServerboundHelloPacket,
|
||||||
serverbound_key_packet::{NonceOrSaltSignature, ServerboundKeyPacket},
|
serverbound_key_packet::{NonceOrSaltSignature, ServerboundKeyPacket},
|
||||||
ClientboundLoginPacket,
|
ClientboundLoginPacket,
|
||||||
|
@ -62,6 +63,7 @@ pub enum Event {
|
||||||
Packet(Box<ClientboundGamePacket>),
|
Packet(Box<ClientboundGamePacket>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A chat packet, either a system message or a chat message.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ChatPacket {
|
pub enum ChatPacket {
|
||||||
System(ClientboundSystemChatPacket),
|
System(ClientboundSystemChatPacket),
|
||||||
|
@ -69,6 +71,7 @@ pub enum ChatPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChatPacket {
|
impl ChatPacket {
|
||||||
|
/// Get the message shown in chat for this packet.
|
||||||
pub fn message(&self) -> Component {
|
pub fn message(&self) -> Component {
|
||||||
match self {
|
match self {
|
||||||
ChatPacket::System(p) => p.content.clone(),
|
ChatPacket::System(p) => p.content.clone(),
|
||||||
|
@ -182,55 +185,56 @@ impl Client {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let (conn, game_profile) = loop {
|
let (conn, game_profile) = loop {
|
||||||
let packet_result = conn.read().await;
|
let packet = conn.read().await?;
|
||||||
match packet_result {
|
match packet {
|
||||||
Ok(packet) => match packet {
|
ClientboundLoginPacket::Hello(p) => {
|
||||||
ClientboundLoginPacket::Hello(p) => {
|
debug!("Got encryption request");
|
||||||
debug!("Got encryption request");
|
let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||||
let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
|
||||||
|
|
||||||
if let Some(access_token) = &account.access_token {
|
if let Some(access_token) = &account.access_token {
|
||||||
conn.authenticate(
|
conn.authenticate(
|
||||||
access_token,
|
access_token,
|
||||||
&account
|
&account
|
||||||
.uuid
|
.uuid
|
||||||
.expect("Uuid must be present if access token is present."),
|
.expect("Uuid must be present if access token is present."),
|
||||||
e.secret_key,
|
e.secret_key,
|
||||||
p,
|
p,
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.write(
|
|
||||||
ServerboundKeyPacket {
|
|
||||||
nonce_or_salt_signature: NonceOrSaltSignature::Nonce(
|
|
||||||
e.encrypted_nonce,
|
|
||||||
),
|
|
||||||
key_bytes: e.encrypted_public_key,
|
|
||||||
}
|
|
||||||
.get(),
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
conn.set_encryption_key(e.secret_key);
|
conn.write(
|
||||||
}
|
ServerboundKeyPacket {
|
||||||
ClientboundLoginPacket::LoginCompression(p) => {
|
nonce_or_salt_signature: NonceOrSaltSignature::Nonce(e.encrypted_nonce),
|
||||||
debug!("Got compression request {:?}", p.compression_threshold);
|
key_bytes: e.encrypted_public_key,
|
||||||
conn.set_compression_threshold(p.compression_threshold);
|
}
|
||||||
}
|
.get(),
|
||||||
ClientboundLoginPacket::GameProfile(p) => {
|
)
|
||||||
debug!("Got profile {:?}", p.game_profile);
|
.await?;
|
||||||
break (conn.game(), p.game_profile);
|
|
||||||
}
|
conn.set_encryption_key(e.secret_key);
|
||||||
ClientboundLoginPacket::LoginDisconnect(p) => {
|
}
|
||||||
debug!("Got disconnect {:?}", p);
|
ClientboundLoginPacket::LoginCompression(p) => {
|
||||||
}
|
debug!("Got compression request {:?}", p.compression_threshold);
|
||||||
ClientboundLoginPacket::CustomQuery(p) => {
|
conn.set_compression_threshold(p.compression_threshold);
|
||||||
debug!("Got custom query {:?}", p);
|
}
|
||||||
}
|
ClientboundLoginPacket::GameProfile(p) => {
|
||||||
},
|
debug!("Got profile {:?}", p.game_profile);
|
||||||
Err(e) => {
|
break (conn.game(), p.game_profile);
|
||||||
panic!("Error: {e:?}");
|
}
|
||||||
|
ClientboundLoginPacket::LoginDisconnect(p) => {
|
||||||
|
debug!("Got disconnect {:?}", p);
|
||||||
|
}
|
||||||
|
ClientboundLoginPacket::CustomQuery(p) => {
|
||||||
|
debug!("Got custom query {:?}", p);
|
||||||
|
conn.write(
|
||||||
|
ServerboundCustomQueryPacket {
|
||||||
|
transaction_id: p.transaction_id,
|
||||||
|
data: None,
|
||||||
|
}
|
||||||
|
.get(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -758,6 +762,7 @@ impl Client {
|
||||||
ClientboundGamePacket::TabList(_) => {}
|
ClientboundGamePacket::TabList(_) => {}
|
||||||
ClientboundGamePacket::TagQuery(_) => {}
|
ClientboundGamePacket::TagQuery(_) => {}
|
||||||
ClientboundGamePacket::TakeItemEntity(_) => {}
|
ClientboundGamePacket::TakeItemEntity(_) => {}
|
||||||
|
ClientboundGamePacket::ContainerClose(_) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -10,25 +10,52 @@ use std::path::PathBuf;
|
||||||
/// Mac: `$HOME/Library/Application Support/minecraft`\
|
/// Mac: `$HOME/Library/Application Support/minecraft`\
|
||||||
/// Linux: `$HOME/.minecraft`
|
/// Linux: `$HOME/.minecraft`
|
||||||
///
|
///
|
||||||
/// Anywhere else it'll return None.
|
/// If the environment variable is not set, this will return `None`.
|
||||||
pub fn minecraft_dir() -> Option<PathBuf> {
|
pub fn minecraft_dir() -> Option<PathBuf> {
|
||||||
|
let env_var = home_env_var();
|
||||||
|
let home = std::env::var(env_var).ok()?;
|
||||||
|
let path = PathBuf::from(home).join(minecraft_dir_relative());
|
||||||
|
Some(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the name of the environment variable that's used for the home folder
|
||||||
|
/// on the user's operating system.
|
||||||
|
pub fn home_env_var() -> &'static str {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
let appdata = std::env::var("APPDATA").ok()?;
|
"USERPROFILE"
|
||||||
Some(PathBuf::from(appdata).join(".minecraft"))
|
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
let home = std::env::var("HOME").ok()?;
|
"HOME"
|
||||||
Some(PathBuf::from(home).join("Library/Application Support/minecraft"))
|
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
let home = std::env::var("HOME").ok()?;
|
"HOME"
|
||||||
Some(PathBuf::from(home).join(".minecraft"))
|
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
|
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
|
||||||
{
|
{
|
||||||
None
|
"HOME"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the path relative to the home folder where we expect to find the
|
||||||
|
/// .minecraft directory.
|
||||||
|
pub fn minecraft_dir_relative() -> &'static str {
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
".minecraft"
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
"Library/Application Support/minecraft"
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
".minecraft"
|
||||||
|
}
|
||||||
|
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
|
||||||
|
{
|
||||||
|
".minecraft"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub mod ping;
|
||||||
mod player;
|
mod player;
|
||||||
|
|
||||||
pub use account::Account;
|
pub use account::Account;
|
||||||
pub use client::{Client, ClientInformation, Event};
|
pub use client::{ChatPacket, Client, ClientInformation, Event, JoinError};
|
||||||
pub use movement::WalkDirection;
|
pub use movement::WalkDirection;
|
||||||
pub use player::Player;
|
pub use player::Player;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,13 @@ description = "Miscellaneous things in Azalea."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-core"
|
name = "azalea-core"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-core"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||||
uuid = "^1.1.2"
|
uuid = "^1.1.2"
|
||||||
|
|
|
@ -3,13 +3,14 @@ description = "Cryptography features used in Minecraft."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-crypto"
|
name = "azalea-crypto"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-crypto"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aes = "0.8.1"
|
aes = "0.8.1"
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
cfb8 = "0.8.1"
|
cfb8 = "0.8.1"
|
||||||
num-bigint = "^0.4.3"
|
num-bigint = "^0.4.3"
|
||||||
rand = {version = "^0.8.4", features = ["getrandom"]}
|
rand = {version = "^0.8.4", features = ["getrandom"]}
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "Translate Minecraft strings from their id."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-language"
|
name = "azalea-language"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-language"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,14 @@ description = "A fast NBT serializer and deserializer."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-nbt"
|
name = "azalea-nbt"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-nbt"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ahash = "^0.8.0"
|
ahash = "^0.8.0"
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
byteorder = "^1.4.3"
|
byteorder = "^1.4.3"
|
||||||
flate2 = "^1.0.23"
|
flate2 = "^1.0.23"
|
||||||
num-derive = "^0.3.3"
|
num-derive = "^0.3.3"
|
||||||
|
|
|
@ -8,11 +8,11 @@ version = "0.1.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.65"
|
anyhow = "1.0.65"
|
||||||
async-trait = "0.1.57"
|
async-trait = "0.1.57"
|
||||||
azalea = {version = "0.2.4", path = "../azalea"}
|
azalea = { version = "0.3.0", path = "../azalea" }
|
||||||
azalea-block = {version = "0.2.0", path = "../azalea-block"}
|
azalea-block = { version = "0.3.0", path = "../azalea-block" }
|
||||||
azalea-client = {version = "0.2.2", path = "../azalea-client"}
|
azalea-client = { version = "0.3.0", path = "../azalea-client" }
|
||||||
azalea-core = {version = "0.2.0", path = "../azalea-core"}
|
azalea-core = { version = "0.3.0", path = "../azalea-core" }
|
||||||
azalea-physics = {version = "0.2.0", path = "../azalea-physics"}
|
azalea-physics = { version = "0.3.0", path = "../azalea-physics" }
|
||||||
azalea-world = {version = "0.2.0", path = "../azalea-world"}
|
azalea-world = { version = "0.3.0", path = "../azalea-world" }
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
priority-queue = "1.2.3"
|
priority-queue = "1.2.3"
|
||||||
|
|
|
@ -3,14 +3,15 @@ description = "Physics for Minecraft entities."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-physics"
|
name = "azalea-physics"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-physics"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-block = { path = "../azalea-block", version = "^0.2.0" }
|
azalea-block = { path = "../azalea-block", version = "^0.3.0" }
|
||||||
azalea-core = { path = "../azalea-core", version = "^0.2.0" }
|
azalea-core = { path = "../azalea-core", version = "^0.3.0" }
|
||||||
azalea-world = { path = "../azalea-world", version = "^0.2.0" }
|
azalea-world = { path = "../azalea-world", version = "^0.3.0" }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -3,24 +3,25 @@ description = "Send and receive Minecraft packets."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-protocol"
|
name = "azalea-protocol"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-protocol"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-compression = {version = "^0.3.8", features = ["tokio", "zlib"], optional = true}
|
async-compression = {version = "^0.3.8", features = ["tokio", "zlib"], optional = true}
|
||||||
async-recursion = "1.0.0"
|
async-recursion = "1.0.0"
|
||||||
azalea-auth = {path = "../azalea-auth", version = "^0.2.1" }
|
azalea-auth = {path = "../azalea-auth", version = "^0.3.0" }
|
||||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.2.0" }
|
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0" }
|
||||||
azalea-brigadier = {path = "../azalea-brigadier", version = "^0.2.0" }
|
azalea-brigadier = {path = "../azalea-brigadier", version = "^0.3.0" }
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||||
azalea-core = {path = "../azalea-core", optional = true, version = "^0.2.0" }
|
azalea-core = {path = "../azalea-core", optional = true, version = "^0.3.0" }
|
||||||
azalea-crypto = {path = "../azalea-crypto", version = "^0.2.0" }
|
azalea-crypto = {path = "../azalea-crypto", version = "^0.3.0" }
|
||||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||||
azalea-protocol-macros = {path = "./azalea-protocol-macros", version = "^0.2.0" }
|
azalea-protocol-macros = {path = "./azalea-protocol-macros", version = "^0.3.0" }
|
||||||
azalea-registry = {path = "../azalea-registry", version = "^0.2.0" }
|
azalea-registry = {path = "../azalea-registry", version = "^0.3.0" }
|
||||||
azalea-world = {path = "../azalea-world", version = "^0.2.0" }
|
azalea-world = {path = "../azalea-world", version = "^0.3.0" }
|
||||||
byteorder = "^1.4.3"
|
byteorder = "^1.4.3"
|
||||||
bytes = "^1.1.0"
|
bytes = "^1.1.0"
|
||||||
flate2 = "1.0.23"
|
flate2 = "1.0.23"
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "Macros internally used in azalea-protocol."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-protocol-macros"
|
name = "azalea-protocol-macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-protocol/azalea-protocol-macros"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
|
@ -55,26 +55,24 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
||||||
/// hostname: address.host.to_string(),
|
/// hostname: address.host.to_string(),
|
||||||
/// port: address.port,
|
/// port: address.port,
|
||||||
/// intention: ConnectionProtocol::Login,
|
/// intention: ConnectionProtocol::Login,
|
||||||
/// }
|
/// }.get());
|
||||||
/// .get(),
|
|
||||||
/// )
|
|
||||||
/// .await?;
|
|
||||||
/// let mut conn = conn.login();
|
|
||||||
///
|
///
|
||||||
/// // login
|
/// .await?;
|
||||||
/// conn.write(
|
/// let mut conn = conn.login();
|
||||||
/// ServerboundHelloPacket {
|
|
||||||
/// username,
|
|
||||||
/// public_key: None,
|
|
||||||
/// profile_id: None,
|
|
||||||
/// }
|
|
||||||
/// .get(),
|
|
||||||
/// )
|
|
||||||
/// .await?;
|
|
||||||
///
|
///
|
||||||
/// let (conn, game_profile) = loop {
|
/// // login
|
||||||
/// let packet_result = conn.read().await;
|
/// conn.write(
|
||||||
/// match packet_result {
|
/// ServerboundHelloPacket {
|
||||||
|
/// username,
|
||||||
|
/// public_key: None,
|
||||||
|
/// profile_id: None,
|
||||||
|
/// }
|
||||||
|
/// .get(),
|
||||||
|
/// )
|
||||||
|
/// .await?;
|
||||||
|
///
|
||||||
|
/// let (conn, game_profile) = loop {
|
||||||
|
/// let packet_result = conn.read().await?;
|
||||||
/// Ok(packet) => match packet {
|
/// Ok(packet) => match packet {
|
||||||
/// ClientboundLoginPacket::Hello(p) => {
|
/// ClientboundLoginPacket::Hello(p) => {
|
||||||
/// let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
/// let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||||
|
@ -87,7 +85,8 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
||||||
/// .get(),
|
/// .get(),
|
||||||
/// )
|
/// )
|
||||||
/// .await?;
|
/// .await?;
|
||||||
/// conn.set_encryption_key(e.secret_key); }
|
/// conn.set_encryption_key(e.secret_key);
|
||||||
|
/// }
|
||||||
/// ClientboundLoginPacket::LoginCompression(p) => {
|
/// ClientboundLoginPacket::LoginCompression(p) => {
|
||||||
/// conn.set_compression_threshold(p.compression_threshold);
|
/// conn.set_compression_threshold(p.compression_threshold);
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
//! You should probably use [`azalea`] or [`azalea_client`] instead, as
|
//! You should probably use [`azalea`] or [`azalea_client`] instead, as
|
||||||
//! azalea_protocol delegates much of the work, such as auth, to the user of
|
//! azalea_protocol delegates much of the work, such as auth, to the user of
|
||||||
//! the crate.
|
//! the crate.
|
||||||
|
//!
|
||||||
|
//! [`azalea`]: https://crates.io/crates/azalea
|
||||||
|
//! [`azalea_client`]: https://crates.io/crates/azalea-client
|
||||||
|
|
||||||
// these two are necessary for thiserror backtraces
|
// these two are necessary for thiserror backtraces
|
||||||
#![feature(error_generic_member_access)]
|
#![feature(error_generic_member_access)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::{
|
use azalea_buf::{
|
||||||
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
||||||
};
|
};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
use azalea_buf::McBuf;
|
||||||
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
pub struct ClientboundContainerClosePacket {
|
||||||
|
pub container_id: u8,
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use azalea_buf::{BufReadError, McBuf};
|
use azalea_buf::{BufReadError, McBuf};
|
||||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::{
|
use azalea_chat::{
|
||||||
component::Component,
|
|
||||||
translatable_component::{StringOrComponent, TranslatableComponent},
|
translatable_component::{StringOrComponent, TranslatableComponent},
|
||||||
|
Component,
|
||||||
};
|
};
|
||||||
use azalea_core::BitSet;
|
use azalea_core::BitSet;
|
||||||
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
|
/// Unused in vanilla.
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerCombatEndPacket {
|
pub struct ClientboundPlayerCombatEndPacket {
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
|
/// Unused in vanilla.
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerCombatEnterPacket {}
|
pub struct ClientboundPlayerCombatEnterPacket {}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
|
/// Used to send a respawn screen.
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
pub struct ClientboundPlayerCombatKillPacket {
|
pub struct ClientboundPlayerCombatKillPacket {
|
||||||
#[var]
|
#[var]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::packets::login::serverbound_hello_packet::ProfilePublicKeyData;
|
use crate::packets::login::serverbound_hello_packet::ProfilePublicKeyData;
|
||||||
use azalea_buf::{BufReadError, McBuf};
|
use azalea_buf::{BufReadError, McBuf};
|
||||||
use azalea_buf::{McBufReadable, McBufWritable};
|
use azalea_buf::{McBufReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
||||||
use azalea_chat::{component::Component, style::ChatFormatting};
|
use azalea_chat::{style::ChatFormatting, Component};
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_core::{ResourceLocation, Slot};
|
use azalea_core::{ResourceLocation, Slot};
|
||||||
use azalea_protocol_macros::ClientboundGamePacket;
|
use azalea_protocol_macros::ClientboundGamePacket;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub mod clientbound_change_difficulty_packet;
|
||||||
pub mod clientbound_chat_preview_packet;
|
pub mod clientbound_chat_preview_packet;
|
||||||
pub mod clientbound_command_suggestions_packet;
|
pub mod clientbound_command_suggestions_packet;
|
||||||
pub mod clientbound_commands_packet;
|
pub mod clientbound_commands_packet;
|
||||||
|
pub mod clientbound_container_close_packet;
|
||||||
pub mod clientbound_container_set_content_packet;
|
pub mod clientbound_container_set_content_packet;
|
||||||
pub mod clientbound_container_set_data_packet;
|
pub mod clientbound_container_set_data_packet;
|
||||||
pub mod clientbound_container_set_slot_packet;
|
pub mod clientbound_container_set_slot_packet;
|
||||||
|
@ -229,6 +230,7 @@ declare_state_packets!(
|
||||||
0x0c: clientbound_chat_preview_packet::ClientboundChatPreviewPacket,
|
0x0c: clientbound_chat_preview_packet::ClientboundChatPreviewPacket,
|
||||||
0x0e: clientbound_command_suggestions_packet::ClientboundCommandSuggestionsPacket,
|
0x0e: clientbound_command_suggestions_packet::ClientboundCommandSuggestionsPacket,
|
||||||
0x0f: clientbound_commands_packet::ClientboundCommandsPacket,
|
0x0f: clientbound_commands_packet::ClientboundCommandsPacket,
|
||||||
|
0x10: clientbound_container_close_packet::ClientboundContainerClosePacket,
|
||||||
0x11: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket,
|
0x11: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket,
|
||||||
0x12: clientbound_container_set_data_packet::ClientboundContainerSetDataPacket,
|
0x12: clientbound_container_set_data_packet::ClientboundContainerSetDataPacket,
|
||||||
0x13: clientbound_container_set_slot_packet::ClientboundContainerSetSlotPacket,
|
0x13: clientbound_container_set_slot_packet::ClientboundContainerSetSlotPacket,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::McBuf;
|
use azalea_buf::McBuf;
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundLoginPacket;
|
use azalea_protocol_macros::ClientboundLoginPacket;
|
||||||
|
|
||||||
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
|
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
|
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_protocol_macros::ClientboundStatusPacket;
|
use azalea_protocol_macros::ClientboundStatusPacket;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
|
@ -3,10 +3,11 @@ description = "Use Minecraft's registries."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-registry"
|
name = "azalea-registry"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-registry"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
azalea-registry-macros = {path = "./azalea-registry-macros", version = "^0.2.0" }
|
azalea-registry-macros = {path = "./azalea-registry-macros", version = "^0.3.0" }
|
||||||
|
|
|
@ -3,7 +3,8 @@ description = "Macros internally used in azalea-registry."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-registry-macros"
|
name = "azalea-registry-macros"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-registry/azalea-registry-macros"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
|
@ -3,17 +3,18 @@ description = "The Minecraft world representation used in Azalea."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea-world"
|
name = "azalea-world"
|
||||||
version = "0.2.0"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea-world"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.2.0" }
|
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0" }
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||||
azalea-core = {path = "../azalea-core", version = "^0.2.0" }
|
azalea-core = {path = "../azalea-core", version = "^0.3.0" }
|
||||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||||
azalea-registry = {path = "../azalea-registry", version = "^0.2.0" }
|
azalea-registry = {path = "../azalea-registry", version = "^0.3.0" }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
nohash-hasher = "0.2.0"
|
nohash-hasher = "0.2.0"
|
||||||
thiserror = "1.0.34"
|
thiserror = "1.0.34"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use azalea_buf::{BufReadError, McBufVarReadable};
|
use azalea_buf::{BufReadError, McBufVarReadable};
|
||||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||||
use azalea_chat::component::Component;
|
use azalea_chat::Component;
|
||||||
use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot};
|
use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot};
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
|
@ -3,16 +3,17 @@ description = "A framework for creating Minecraft bots."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "azalea"
|
name = "azalea"
|
||||||
version = "0.2.4"
|
repository = "https://github.com/mat-1/azalea/tree/main/azalea"
|
||||||
|
version = "0.3.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "^1.0.65"
|
anyhow = "^1.0.65"
|
||||||
async-trait = "^0.1.57"
|
async-trait = "^0.1.57"
|
||||||
azalea-client = { version = "0.2.2", path = "../azalea-client" }
|
azalea-client = { version = "0.3.0", path = "../azalea-client" }
|
||||||
azalea-protocol = { version = "0.2.0", path = "../azalea-protocol" }
|
azalea-protocol = { version = "0.3.0", path = "../azalea-protocol" }
|
||||||
azalea-core = { version = "0.2.0", path = "../azalea-core" }
|
azalea-core = { version = "0.3.0", path = "../azalea-core" }
|
||||||
parking_lot = "^0.12.1"
|
parking_lot = "^0.12.1"
|
||||||
thiserror = "^1.0.37"
|
thiserror = "^1.0.37"
|
||||||
tokio = "^1.21.1"
|
tokio = "^1.21.1"
|
||||||
|
|
|
@ -5,6 +5,17 @@
|
||||||
//! refer to `azalea_client`. You can just replace these with `azalea` in your
|
//! refer to `azalea_client`. You can just replace these with `azalea` in your
|
||||||
//! code, since everything from azalea_client is re-exported in azalea.
|
//! code, since everything from azalea_client is re-exported in azalea.
|
||||||
//!
|
//!
|
||||||
|
//! # Installation
|
||||||
|
//!
|
||||||
|
//! First, install Rust nightly with `rustup install nightly` and `rustup
|
||||||
|
//! default nightly`.
|
||||||
|
//!
|
||||||
|
//! Then, add one of the following lines to your Cargo.toml.\
|
||||||
|
//! Latest bleeding-edge version:
|
||||||
|
//! `azalea = { git="https://github.com/mat-1/Cargo.toml" }`
|
||||||
|
//! Latest "stable" release:
|
||||||
|
//! `azalea = "0.3"`
|
||||||
|
//!
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
|
@ -94,8 +105,10 @@ where
|
||||||
/// The address of the server that we're connecting to. This can be a
|
/// The address of the server that we're connecting to. This can be a
|
||||||
/// `&str`, [`ServerAddress`], or anything that implements
|
/// `&str`, [`ServerAddress`], or anything that implements
|
||||||
/// `TryInto<ServerAddress>`.
|
/// `TryInto<ServerAddress>`.
|
||||||
|
///
|
||||||
|
/// [`ServerAddress`]: azalea_protocol::ServerAddress
|
||||||
pub address: A,
|
pub address: A,
|
||||||
/// The account that's going to join the server,
|
/// The account that's going to join the server.
|
||||||
pub account: Account,
|
pub account: Account,
|
||||||
/// A list of plugins that are going to be used. Plugins are external
|
/// A list of plugins that are going to be used. Plugins are external
|
||||||
/// crates that add extra functionality to Azalea.
|
/// crates that add extra functionality to Azalea.
|
||||||
|
@ -116,6 +129,16 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
pub state: S,
|
pub state: S,
|
||||||
/// The function that's called whenever we get an event.
|
/// The function that's called whenever we get an event.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use azalea::prelude::*;
|
||||||
|
///
|
||||||
|
/// async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
|
||||||
|
/// Ok(())
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub handle: HandleFn<Fut, S>,
|
pub handle: HandleFn<Fut, S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +146,8 @@ where
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Invalid address")]
|
#[error("Invalid address")]
|
||||||
InvalidAddress,
|
InvalidAddress,
|
||||||
|
#[error("Join error: {0}")]
|
||||||
|
Join(#[from] azalea_client::JoinError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Join a server and start handling events. This function will run forever until
|
/// Join a server and start handling events. This function will run forever until
|
||||||
|
@ -151,7 +176,7 @@ pub async fn start<
|
||||||
Err(_) => return Err(Error::InvalidAddress),
|
Err(_) => return Err(Error::InvalidAddress),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (bot, mut rx) = Client::join(&options.account, address).await.unwrap();
|
let (bot, mut rx) = Client::join(&options.account, address).await?;
|
||||||
|
|
||||||
let state = options.state;
|
let state = options.state;
|
||||||
let bot_plugin = bot::Plugin::default();
|
let bot_plugin = bot::Plugin::default();
|
||||||
|
|
|
@ -45,7 +45,7 @@ def burger_type_to_rust_type(burger_type, field_name: Optional[str] = None, inst
|
||||||
|
|
||||||
elif burger_type == 'chatcomponent':
|
elif burger_type == 'chatcomponent':
|
||||||
field_type_rs = 'Component'
|
field_type_rs = 'Component'
|
||||||
uses.add('azalea_chat::component::Component')
|
uses.add('azalea_chat::Component')
|
||||||
elif burger_type == 'identifier':
|
elif burger_type == 'identifier':
|
||||||
field_type_rs = 'ResourceLocation'
|
field_type_rs = 'ResourceLocation'
|
||||||
uses.add('azalea_core::ResourceLocation')
|
uses.add('azalea_core::ResourceLocation')
|
||||||
|
|
Loading…
Add table
Reference in a new issue