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]]
|
||||
name = "azalea"
|
||||
version = "0.2.4"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
@ -115,7 +115,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-auth"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-buf",
|
||||
"azalea-crypto",
|
||||
|
@ -133,7 +133,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-block"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-block-macros",
|
||||
"azalea-buf",
|
||||
|
@ -141,7 +141,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-block-macros"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -150,11 +150,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-brigadier"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
|
||||
[[package]]
|
||||
name = "azalea-buf"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-buf-macros",
|
||||
"byteorder",
|
||||
|
@ -166,7 +166,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-buf-macros"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -175,7 +175,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-chat"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-buf",
|
||||
"azalea-language",
|
||||
|
@ -186,7 +186,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-client"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"azalea-auth",
|
||||
|
@ -206,7 +206,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-core"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-buf",
|
||||
"azalea-chat",
|
||||
|
@ -216,7 +216,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-crypto"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"azalea-buf",
|
||||
|
@ -231,7 +231,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-language"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"serde",
|
||||
|
@ -240,7 +240,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-nbt"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"azalea-buf",
|
||||
|
@ -269,7 +269,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-physics"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-block",
|
||||
"azalea-core",
|
||||
|
@ -280,7 +280,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-protocol"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"async-recursion",
|
||||
|
@ -312,7 +312,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-protocol-macros"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -321,7 +321,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-registry"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-buf",
|
||||
"azalea-registry-macros",
|
||||
|
@ -329,7 +329,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-registry-macros"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -338,7 +338,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "azalea-world"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"azalea-block",
|
||||
"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
|
||||
|
||||
[](https://docs.rs/azalea)
|
||||
|
||||
A collection of Rust crates for making Minecraft bots, clients, and tools.
|
||||
|
||||
<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. -->
|
||||
*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.
|
||||
|
|
|
@ -3,23 +3,24 @@ description = "A port of Mojang's Authlib and launcher authentication."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-buf = { path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-crypto = { path = "../azalea-crypto", version = "^0.2.0" }
|
||||
chrono = { version = "0.4.22", default-features = false }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||
azalea-crypto = {path = "../azalea-crypto", version = "^0.3.0" }
|
||||
chrono = {version = "0.4.22", default-features = false}
|
||||
log = "0.4.17"
|
||||
num-bigint = "0.4.3"
|
||||
reqwest = { version = "0.11.12", features = ["json"] }
|
||||
serde = { version = "1.0.145", features = ["derive"] }
|
||||
reqwest = {version = "0.11.12", features = ["json"]}
|
||||
serde = {version = "1.0.145", features = ["derive"]}
|
||||
serde_json = "1.0.86"
|
||||
thiserror = "1.0.37"
|
||||
tokio = { version = "1.21.2", features = ["fs"] }
|
||||
tokio = {version = "1.21.2", features = ["fs"]}
|
||||
uuid = "^1.1.2"
|
||||
|
||||
[dev-dependencies]
|
||||
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> {
|
||||
let res = client
|
||||
.get("https://api.minecraftservices.com/entitlements/mcstore")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.header("Authorization", format!("Bearer {minecraft_access_token}"))
|
||||
.send()
|
||||
.await?
|
||||
.json::<GameOwnershipResponse>()
|
||||
|
@ -472,10 +469,7 @@ async fn get_profile(
|
|||
) -> Result<ProfileResponse, GetProfileError> {
|
||||
let res = client
|
||||
.get("https://api.minecraftservices.com/minecraft/profile")
|
||||
.header(
|
||||
"Authorization",
|
||||
format!("Bearer {minecraft_access_token}"),
|
||||
)
|
||||
.header("Authorization", format!("Bearer {minecraft_access_token}"))
|
||||
.send()
|
||||
.await?
|
||||
.json::<ProfileResponse>()
|
||||
|
|
|
@ -3,12 +3,13 @@ description = "Representation of Minecraft block states."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
name = "azalea-block"
|
||||
version = "0.2.0"
|
||||
repository = "https://github.com/mat-1/azalea/tree/main/azalea-block"
|
||||
version = "0.3.0"
|
||||
|
||||
[lib]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
azalea-block-macros = {path = "./azalea-block-macros", version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-block-macros = {path = "./azalea-block-macros", version = "^0.3.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||
|
|
|
@ -3,7 +3,8 @@ description = "Proc macros used by azalea-block."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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]
|
||||
proc-macro = true
|
||||
|
|
|
@ -3,7 +3,8 @@ description = "A port of Mojang's Brigadier command parsing and dispatching libr
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@ description = "Serialize and deserialize buffers from Minecraft."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[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"
|
||||
serde_json = {version = "^1.0", optional = true}
|
||||
thiserror = "^1.0.34"
|
||||
|
|
|
@ -3,7 +3,8 @@ description = "#[derive(McBuf)]"
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
name = "azalea-buf-macros"
|
||||
version = "0.2.0"
|
||||
repository = "https://github.com/mat-1/azalea/tree/main/azalea-buf"
|
||||
version = "0.3.0"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
|
|
@ -3,13 +3,14 @@ description = "Parse Minecraft chat messages."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-buf = {path = "../azalea-buf", features = ["serde_json"], version = "^0.2.0" }
|
||||
azalea-language = {path = "../azalea-language", version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", features = ["serde_json"], version = "^0.3.0" }
|
||||
azalea-language = {path = "../azalea-language", version = "^0.3.0" }
|
||||
lazy_static = "^1.4.0"
|
||||
serde = "^1.0.130"
|
||||
serde_json = "^1.0.72"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{component::Component, style::Style};
|
||||
use crate::{style::Style, Component};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BaseComponent {
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::{
|
|||
translatable_component::{StringOrComponent, TranslatableComponent},
|
||||
};
|
||||
|
||||
/// A chat component, basically anything you can see in chat.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Component {
|
||||
Text(TextComponent),
|
||||
|
@ -57,7 +58,22 @@ impl Component {
|
|||
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 {
|
||||
// default the default_style to white if it's not set
|
||||
let default_style: &Style = default_style.unwrap_or(&DEFAULT_STYLE);
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
extern crate lazy_static;
|
||||
|
||||
pub mod base_component;
|
||||
pub mod component;
|
||||
mod component;
|
||||
pub mod style;
|
||||
pub mod text_component;
|
||||
pub mod translatable_component;
|
||||
|
||||
pub use component::Component;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
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)]
|
||||
pub struct TextComponent {
|
||||
pub base: BaseComponent,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use crate::{
|
||||
base_component::BaseComponent, component::Component, style::Style,
|
||||
text_component::TextComponent,
|
||||
base_component::BaseComponent, style::Style, text_component::TextComponent, Component,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -11,6 +10,7 @@ pub enum StringOrComponent {
|
|||
Component(Component),
|
||||
}
|
||||
|
||||
/// A message whose content depends on the client's language.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TranslatableComponent {
|
||||
pub base: BaseComponent,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use azalea_chat::{
|
||||
component::Component,
|
||||
style::{Ansi, ChatFormatting, TextColor},
|
||||
Component,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
|
|
@ -3,20 +3,21 @@ description = "A headless Minecraft client."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.59"
|
||||
azalea-auth = { path = "../azalea-auth", version = "0.2.1" }
|
||||
azalea-block = { path = "../azalea-block", version = "0.2.0" }
|
||||
azalea-chat = { path = "../azalea-chat", version = "0.2.0" }
|
||||
azalea-core = { path = "../azalea-core", version = "0.2.0" }
|
||||
azalea-crypto = { path = "../azalea-crypto", version = "0.2.0" }
|
||||
azalea-physics = { path = "../azalea-physics", version = "0.2.0" }
|
||||
azalea-protocol = { path = "../azalea-protocol", version = "0.2.0" }
|
||||
azalea-world = { path = "../azalea-world", version = "0.2.0" }
|
||||
azalea-auth = { path = "../azalea-auth", version = "0.3.0" }
|
||||
azalea-block = { path = "../azalea-block", version = "0.3.0" }
|
||||
azalea-chat = { path = "../azalea-chat", version = "0.3.0" }
|
||||
azalea-core = { path = "../azalea-core", version = "0.3.0" }
|
||||
azalea-crypto = { path = "../azalea-crypto", version = "0.3.0" }
|
||||
azalea-physics = { path = "../azalea-physics", version = "0.3.0" }
|
||||
azalea-protocol = { path = "../azalea-protocol", version = "0.3.0" }
|
||||
azalea-world = { path = "../azalea-world", version = "0.3.0" }
|
||||
log = "0.4.17"
|
||||
parking_lot = "0.12.1"
|
||||
thiserror = "^1.0.34"
|
||||
|
|
|
@ -6,6 +6,18 @@ use uuid::Uuid;
|
|||
/// Something that can join Minecraft servers.
|
||||
///
|
||||
/// 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)]
|
||||
pub struct 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
|
||||
/// avoid confusion.
|
||||
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(
|
||||
email,
|
||||
azalea_auth::AuthOpts {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{movement::WalkDirection, Account, Player};
|
||||
use azalea_auth::game_profile::GameProfile;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_core::{ChunkPos, ResourceLocation, Vec3};
|
||||
use azalea_protocol::{
|
||||
connect::{Connection, ConnectionError, ReadConnection, WriteConnection},
|
||||
|
@ -17,6 +17,7 @@ use azalea_protocol::{
|
|||
},
|
||||
handshake::client_intention_packet::ClientIntentionPacket,
|
||||
login::{
|
||||
serverbound_custom_query_packet::ServerboundCustomQueryPacket,
|
||||
serverbound_hello_packet::ServerboundHelloPacket,
|
||||
serverbound_key_packet::{NonceOrSaltSignature, ServerboundKeyPacket},
|
||||
ClientboundLoginPacket,
|
||||
|
@ -62,6 +63,7 @@ pub enum Event {
|
|||
Packet(Box<ClientboundGamePacket>),
|
||||
}
|
||||
|
||||
/// A chat packet, either a system message or a chat message.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ChatPacket {
|
||||
System(ClientboundSystemChatPacket),
|
||||
|
@ -69,6 +71,7 @@ pub enum ChatPacket {
|
|||
}
|
||||
|
||||
impl ChatPacket {
|
||||
/// Get the message shown in chat for this packet.
|
||||
pub fn message(&self) -> Component {
|
||||
match self {
|
||||
ChatPacket::System(p) => p.content.clone(),
|
||||
|
@ -182,9 +185,8 @@ impl Client {
|
|||
.await?;
|
||||
|
||||
let (conn, game_profile) = loop {
|
||||
let packet_result = conn.read().await;
|
||||
match packet_result {
|
||||
Ok(packet) => match packet {
|
||||
let packet = conn.read().await?;
|
||||
match packet {
|
||||
ClientboundLoginPacket::Hello(p) => {
|
||||
debug!("Got encryption request");
|
||||
let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||
|
@ -203,9 +205,7 @@ impl Client {
|
|||
|
||||
conn.write(
|
||||
ServerboundKeyPacket {
|
||||
nonce_or_salt_signature: NonceOrSaltSignature::Nonce(
|
||||
e.encrypted_nonce,
|
||||
),
|
||||
nonce_or_salt_signature: NonceOrSaltSignature::Nonce(e.encrypted_nonce),
|
||||
key_bytes: e.encrypted_public_key,
|
||||
}
|
||||
.get(),
|
||||
|
@ -227,10 +227,14 @@ impl Client {
|
|||
}
|
||||
ClientboundLoginPacket::CustomQuery(p) => {
|
||||
debug!("Got custom query {:?}", p);
|
||||
conn.write(
|
||||
ServerboundCustomQueryPacket {
|
||||
transaction_id: p.transaction_id,
|
||||
data: None,
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
panic!("Error: {e:?}");
|
||||
.get(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -758,6 +762,7 @@ impl Client {
|
|||
ClientboundGamePacket::TabList(_) => {}
|
||||
ClientboundGamePacket::TagQuery(_) => {}
|
||||
ClientboundGamePacket::TakeItemEntity(_) => {}
|
||||
ClientboundGamePacket::ContainerClose(_) => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -10,25 +10,52 @@ use std::path::PathBuf;
|
|||
/// Mac: `$HOME/Library/Application Support/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> {
|
||||
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")]
|
||||
{
|
||||
let appdata = std::env::var("APPDATA").ok()?;
|
||||
Some(PathBuf::from(appdata).join(".minecraft"))
|
||||
"USERPROFILE"
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let home = std::env::var("HOME").ok()?;
|
||||
Some(PathBuf::from(home).join("Library/Application Support/minecraft"))
|
||||
"HOME"
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let home = std::env::var("HOME").ok()?;
|
||||
Some(PathBuf::from(home).join(".minecraft"))
|
||||
"HOME"
|
||||
}
|
||||
#[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;
|
||||
|
||||
pub use account::Account;
|
||||
pub use client::{Client, ClientInformation, Event};
|
||||
pub use client::{ChatPacket, Client, ClientInformation, Event, JoinError};
|
||||
pub use movement::WalkDirection;
|
||||
pub use player::Player;
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@ description = "Miscellaneous things in Azalea."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||
uuid = "^1.1.2"
|
||||
|
|
|
@ -3,13 +3,14 @@ description = "Cryptography features used in Minecraft."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
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"
|
||||
num-bigint = "^0.4.3"
|
||||
rand = {version = "^0.8.4", features = ["getrandom"]}
|
||||
|
|
|
@ -3,7 +3,8 @@ description = "Translate Minecraft strings from their id."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ description = "A fast NBT serializer and deserializer."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
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"
|
||||
flate2 = "^1.0.23"
|
||||
num-derive = "^0.3.3"
|
||||
|
|
|
@ -8,11 +8,11 @@ version = "0.1.0"
|
|||
[dependencies]
|
||||
anyhow = "1.0.65"
|
||||
async-trait = "0.1.57"
|
||||
azalea = {version = "0.2.4", path = "../azalea"}
|
||||
azalea-block = {version = "0.2.0", path = "../azalea-block"}
|
||||
azalea-client = {version = "0.2.2", path = "../azalea-client"}
|
||||
azalea-core = {version = "0.2.0", path = "../azalea-core"}
|
||||
azalea-physics = {version = "0.2.0", path = "../azalea-physics"}
|
||||
azalea-world = {version = "0.2.0", path = "../azalea-world"}
|
||||
azalea = { version = "0.3.0", path = "../azalea" }
|
||||
azalea-block = { version = "0.3.0", path = "../azalea-block" }
|
||||
azalea-client = { version = "0.3.0", path = "../azalea-client" }
|
||||
azalea-core = { version = "0.3.0", path = "../azalea-core" }
|
||||
azalea-physics = { version = "0.3.0", path = "../azalea-physics" }
|
||||
azalea-world = { version = "0.3.0", path = "../azalea-world" }
|
||||
num-traits = "0.2.15"
|
||||
priority-queue = "1.2.3"
|
||||
|
|
|
@ -3,14 +3,15 @@ description = "Physics for Minecraft entities."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-block = { path = "../azalea-block", version = "^0.2.0" }
|
||||
azalea-core = { path = "../azalea-core", version = "^0.2.0" }
|
||||
azalea-world = { path = "../azalea-world", version = "^0.2.0" }
|
||||
azalea-block = { path = "../azalea-block", version = "^0.3.0" }
|
||||
azalea-core = { path = "../azalea-core", version = "^0.3.0" }
|
||||
azalea-world = { path = "../azalea-world", version = "^0.3.0" }
|
||||
lazy_static = "1.4.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -3,24 +3,25 @@ description = "Send and receive Minecraft packets."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
async-compression = {version = "^0.3.8", features = ["tokio", "zlib"], optional = true}
|
||||
async-recursion = "1.0.0"
|
||||
azalea-auth = {path = "../azalea-auth", version = "^0.2.1" }
|
||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.2.0" }
|
||||
azalea-brigadier = {path = "../azalea-brigadier", version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
||||
azalea-core = {path = "../azalea-core", optional = true, version = "^0.2.0" }
|
||||
azalea-crypto = {path = "../azalea-crypto", version = "^0.2.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
||||
azalea-protocol-macros = {path = "./azalea-protocol-macros", version = "^0.2.0" }
|
||||
azalea-registry = {path = "../azalea-registry", version = "^0.2.0" }
|
||||
azalea-world = {path = "../azalea-world", version = "^0.2.0" }
|
||||
azalea-auth = {path = "../azalea-auth", version = "^0.3.0" }
|
||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0" }
|
||||
azalea-brigadier = {path = "../azalea-brigadier", version = "^0.3.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||
azalea-core = {path = "../azalea-core", optional = true, version = "^0.3.0" }
|
||||
azalea-crypto = {path = "../azalea-crypto", version = "^0.3.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||
azalea-protocol-macros = {path = "./azalea-protocol-macros", version = "^0.3.0" }
|
||||
azalea-registry = {path = "../azalea-registry", version = "^0.3.0" }
|
||||
azalea-world = {path = "../azalea-world", version = "^0.3.0" }
|
||||
byteorder = "^1.4.3"
|
||||
bytes = "^1.1.0"
|
||||
flate2 = "1.0.23"
|
||||
|
|
|
@ -3,7 +3,8 @@ description = "Macros internally used in azalea-protocol."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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]
|
||||
proc-macro = true
|
||||
|
|
|
@ -55,9 +55,8 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// hostname: address.host.to_string(),
|
||||
/// port: address.port,
|
||||
/// intention: ConnectionProtocol::Login,
|
||||
/// }
|
||||
/// .get(),
|
||||
/// )
|
||||
/// }.get());
|
||||
///
|
||||
/// .await?;
|
||||
/// let mut conn = conn.login();
|
||||
///
|
||||
|
@ -73,8 +72,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// .await?;
|
||||
///
|
||||
/// let (conn, game_profile) = loop {
|
||||
/// let packet_result = conn.read().await;
|
||||
/// match packet_result {
|
||||
/// let packet_result = conn.read().await?;
|
||||
/// Ok(packet) => match packet {
|
||||
/// ClientboundLoginPacket::Hello(p) => {
|
||||
/// let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
|
||||
|
@ -87,7 +85,8 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// .get(),
|
||||
/// )
|
||||
/// .await?;
|
||||
/// conn.set_encryption_key(e.secret_key); }
|
||||
/// conn.set_encryption_key(e.secret_key);
|
||||
/// }
|
||||
/// ClientboundLoginPacket::LoginCompression(p) => {
|
||||
/// conn.set_compression_threshold(p.compression_threshold);
|
||||
/// }
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
//! You should probably use [`azalea`] or [`azalea_client`] instead, as
|
||||
//! azalea_protocol delegates much of the work, such as auth, to the user of
|
||||
//! the crate.
|
||||
//!
|
||||
//! [`azalea`]: https://crates.io/crates/azalea
|
||||
//! [`azalea_client`]: https://crates.io/crates/azalea-client
|
||||
|
||||
// these two are necessary for thiserror backtraces
|
||||
#![feature(error_generic_member_access)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use azalea_buf::{
|
||||
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
||||
};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::io::Cursor;
|
||||
use std::io::Write;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::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_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use azalea_buf::{BufReadError, McBuf};
|
||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::io::{Cursor, Write};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::{
|
||||
component::Component,
|
||||
translatable_component::{StringOrComponent, TranslatableComponent},
|
||||
Component,
|
||||
};
|
||||
use azalea_core::BitSet;
|
||||
use azalea_crypto::{MessageSignature, SignedMessageHeader};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
/// Unused in vanilla.
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundPlayerCombatEndPacket {
|
||||
#[var]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
/// Unused in vanilla.
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundPlayerCombatEnterPacket {}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
/// Used to send a respawn screen.
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundPlayerCombatKillPacket {
|
||||
#[var]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::packets::login::serverbound_hello_packet::ProfilePublicKeyData;
|
||||
use azalea_buf::{BufReadError, McBuf};
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::io::{Cursor, Write};
|
||||
use uuid::Uuid;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::io::{Cursor, Write};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 std::io::{Cursor, Write};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_core::{ResourceLocation, Slot};
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
use std::collections::HashMap;
|
||||
|
|
|
@ -13,6 +13,7 @@ pub mod clientbound_change_difficulty_packet;
|
|||
pub mod clientbound_chat_preview_packet;
|
||||
pub mod clientbound_command_suggestions_packet;
|
||||
pub mod clientbound_commands_packet;
|
||||
pub mod clientbound_container_close_packet;
|
||||
pub mod clientbound_container_set_content_packet;
|
||||
pub mod clientbound_container_set_data_packet;
|
||||
pub mod clientbound_container_set_slot_packet;
|
||||
|
@ -229,6 +230,7 @@ declare_state_packets!(
|
|||
0x0c: clientbound_chat_preview_packet::ClientboundChatPreviewPacket,
|
||||
0x0e: clientbound_command_suggestions_packet::ClientboundCommandSuggestionsPacket,
|
||||
0x0f: clientbound_commands_packet::ClientboundCommandsPacket,
|
||||
0x10: clientbound_container_close_packet::ClientboundContainerClosePacket,
|
||||
0x11: clientbound_container_set_content_packet::ClientboundContainerSetContentPacket,
|
||||
0x12: clientbound_container_set_data_packet::ClientboundContainerSetDataPacket,
|
||||
0x13: clientbound_container_set_slot_packet::ClientboundContainerSetSlotPacket,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundLoginPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_protocol_macros::ClientboundStatusPacket;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
|
|
@ -3,10 +3,11 @@ description = "Use Minecraft's registries."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-registry-macros = {path = "./azalea-registry-macros", version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.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"
|
||||
license = "MIT"
|
||||
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]
|
||||
proc-macro = true
|
||||
|
|
|
@ -3,17 +3,18 @@ description = "The Minecraft world representation used in Azalea."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.2.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.2.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.2.0" }
|
||||
azalea-core = {path = "../azalea-core", version = "^0.2.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.2.0" }
|
||||
azalea-registry = {path = "../azalea-registry", version = "^0.2.0" }
|
||||
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.3.0" }
|
||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.3.0" }
|
||||
azalea-core = {path = "../azalea-core", version = "^0.3.0" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.3.0" }
|
||||
azalea-registry = {path = "../azalea-registry", version = "^0.3.0" }
|
||||
log = "0.4.17"
|
||||
nohash-hasher = "0.2.0"
|
||||
thiserror = "1.0.34"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use azalea_buf::{BufReadError, McBufVarReadable};
|
||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||
use azalea_chat::component::Component;
|
||||
use azalea_chat::Component;
|
||||
use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot};
|
||||
use std::io::{Cursor, Write};
|
||||
use uuid::Uuid;
|
||||
|
|
|
@ -3,16 +3,17 @@ description = "A framework for creating Minecraft bots."
|
|||
edition = "2021"
|
||||
license = "MIT"
|
||||
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
|
||||
|
||||
[dependencies]
|
||||
anyhow = "^1.0.65"
|
||||
async-trait = "^0.1.57"
|
||||
azalea-client = { version = "0.2.2", path = "../azalea-client" }
|
||||
azalea-protocol = { version = "0.2.0", path = "../azalea-protocol" }
|
||||
azalea-core = { version = "0.2.0", path = "../azalea-core" }
|
||||
azalea-client = { version = "0.3.0", path = "../azalea-client" }
|
||||
azalea-protocol = { version = "0.3.0", path = "../azalea-protocol" }
|
||||
azalea-core = { version = "0.3.0", path = "../azalea-core" }
|
||||
parking_lot = "^0.12.1"
|
||||
thiserror = "^1.0.37"
|
||||
tokio = "^1.21.1"
|
||||
|
|
|
@ -5,6 +5,17 @@
|
|||
//! refer to `azalea_client`. You can just replace these with `azalea` in your
|
||||
//! 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
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
|
@ -94,8 +105,10 @@ where
|
|||
/// The address of the server that we're connecting to. This can be a
|
||||
/// `&str`, [`ServerAddress`], or anything that implements
|
||||
/// `TryInto<ServerAddress>`.
|
||||
///
|
||||
/// [`ServerAddress`]: azalea_protocol::ServerAddress
|
||||
pub address: A,
|
||||
/// The account that's going to join the server,
|
||||
/// The account that's going to join the server.
|
||||
pub account: Account,
|
||||
/// A list of plugins that are going to be used. Plugins are external
|
||||
/// crates that add extra functionality to Azalea.
|
||||
|
@ -116,6 +129,16 @@ where
|
|||
/// ```
|
||||
pub state: S,
|
||||
/// 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>,
|
||||
}
|
||||
|
||||
|
@ -123,6 +146,8 @@ where
|
|||
pub enum Error {
|
||||
#[error("Invalid address")]
|
||||
InvalidAddress,
|
||||
#[error("Join error: {0}")]
|
||||
Join(#[from] azalea_client::JoinError),
|
||||
}
|
||||
|
||||
/// 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),
|
||||
};
|
||||
|
||||
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 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':
|
||||
field_type_rs = 'Component'
|
||||
uses.add('azalea_chat::component::Component')
|
||||
uses.add('azalea_chat::Component')
|
||||
elif burger_type == 'identifier':
|
||||
field_type_rs = 'ResourceLocation'
|
||||
uses.add('azalea_core::ResourceLocation')
|
||||
|
|
Loading…
Add table
Reference in a new issue