aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-block/azalea-block-macros/src/lib.rs8
-rw-r--r--azalea-block/azalea-block-macros/src/property/generate.rs4
-rw-r--r--azalea-block/src/generated.rs2
-rw-r--r--azalea-block/src/lib.rs5
-rw-r--r--azalea-client/src/account/microsoft.rs12
-rw-r--r--azalea-client/src/plugins/interact/mod.rs1
-rw-r--r--azalea/examples/testbot/commands/debug.rs8
7 files changed, 19 insertions, 21 deletions
diff --git a/azalea-block/azalea-block-macros/src/lib.rs b/azalea-block/azalea-block-macros/src/lib.rs
index 23546a2b..47d12345 100644
--- a/azalea-block/azalea-block-macros/src/lib.rs
+++ b/azalea-block/azalea-block-macros/src/lib.rs
@@ -458,19 +458,19 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
set_property_match_inner.extend(match kind {
PropertyKind::Enum => quote! { #name => self.#name_ident = new_value.parse()?, },
PropertyKind::Bool => {
- quote! { #name => self.#name_ident = new_value.parse::<bool>().map_err(|_| ())?, }
+ quote! { #name => self.#name_ident = new_value.parse::<bool>().map_err(|_| InvalidPropertyError)?, }
}
});
}
let set_property = if set_property_match_inner.is_empty() {
quote! {
- Err(())
+ Err(InvalidPropertyError)
}
} else {
quote! {
match name {
#set_property_match_inner
- _ => return Err(()),
+ _ => return Err(InvalidPropertyError),
}
Ok(())
}
@@ -527,7 +527,7 @@ pub fn make_block_states(input: TokenStream) -> TokenStream {
_ => None,
}
}
- fn set_property(&mut self, name: &str, new_value: &str) -> Result<(), ()> {
+ fn set_property(&mut self, name: &str, new_value: &str) -> Result<(), InvalidPropertyError> {
#set_property
}
}
diff --git a/azalea-block/azalea-block-macros/src/property/generate.rs b/azalea-block/azalea-block-macros/src/property/generate.rs
index fc48e609..1a219059 100644
--- a/azalea-block/azalea-block-macros/src/property/generate.rs
+++ b/azalea-block/azalea-block-macros/src/property/generate.rs
@@ -131,12 +131,12 @@ fn generate_property_code(
}
}
impl FromStr for #property_struct_name {
- type Err = ();
+ type Err = InvalidPropertyError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
#from_str_match_inner
- _ => return Err(())
+ _ => return Err(InvalidPropertyError)
})
}
}
diff --git a/azalea-block/src/generated.rs b/azalea-block/src/generated.rs
index d042da22..092b00bd 100644
--- a/azalea-block/src/generated.rs
+++ b/azalea-block/src/generated.rs
@@ -5,7 +5,7 @@ use std::{fmt::Debug, str::FromStr};
use azalea_block_macros::make_block_states;
use crate::{
- BlockBehavior, BlockState, BlockStates, BlockTrait, Property,
+ BlockBehavior, BlockState, BlockStates, BlockTrait, InvalidPropertyError, Property,
block_state::BlockStateIntegerRepr,
};
diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs
index 3c64af25..86e2bc4f 100644
--- a/azalea-block/src/lib.rs
+++ b/azalea-block/src/lib.rs
@@ -52,9 +52,12 @@ pub trait BlockTrait: Debug + Any {
/// returns `Err(())`.
///
/// To get a property, use [`Self::get_property`].
- fn set_property(&mut self, name: &str, new_value: &str) -> Result<(), ()>;
+ fn set_property(&mut self, name: &str, new_value: &str) -> Result<(), InvalidPropertyError>;
}
+#[derive(Debug)]
+pub struct InvalidPropertyError;
+
impl dyn BlockTrait {
pub fn downcast_ref<T: BlockTrait>(&self) -> Option<&T> {
(self as &dyn Any).downcast_ref::<T>()
diff --git a/azalea-client/src/account/microsoft.rs b/azalea-client/src/account/microsoft.rs
index 22228eb9..ab31ee82 100644
--- a/azalea-client/src/account/microsoft.rs
+++ b/azalea-client/src/account/microsoft.rs
@@ -91,10 +91,10 @@ impl AccountTrait for MicrosoftAccount {
let access_token = self.access_token.lock().clone();
sessionserver::join(SessionServerJoinOpts {
access_token: &access_token,
- public_key: public_key,
- private_key: private_key,
+ public_key,
+ private_key,
uuid: &self.uuid(),
- server_id: &server_id,
+ server_id,
proxy,
})
.await
@@ -196,10 +196,10 @@ impl AccountTrait for MicrosoftWithAccessTokenAccount {
let access_token = self.access_token.lock().clone();
sessionserver::join(SessionServerJoinOpts {
access_token: &access_token,
- public_key: public_key,
- private_key: private_key,
+ public_key,
+ private_key,
uuid: &self.uuid(),
- server_id: &server_id,
+ server_id,
proxy,
})
.await
diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs
index 4f07c280..d8f8b8b4 100644
--- a/azalea-client/src/plugins/interact/mod.rs
+++ b/azalea-client/src/plugins/interact/mod.rs
@@ -30,7 +30,6 @@ use azalea_protocol::packets::game::{
s_swing::ServerboundSwing,
s_use_item_on::ServerboundUseItemOn,
};
-use azalea_registry::builtin::ItemKind;
use azalea_world::Instance;
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index c1837f97..36c699a4 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -10,15 +10,11 @@ use azalea::{
pathfinder::{ExecutingPath, Pathfinder},
};
use azalea_core::hit_result::HitResult;
-use azalea_entity::{EntityKindComponent, LocalEntity, metadata};
+use azalea_entity::{EntityKindComponent, metadata};
use azalea_inventory::components::MaxStackSize;
use azalea_world::InstanceContainer;
use bevy_app::AppExit;
-use bevy_ecs::{
- message::Messages,
- query::{With, Without},
- world::EntityRef,
-};
+use bevy_ecs::{message::Messages, query::With, world::EntityRef};
use parking_lot::Mutex;
use super::{CommandSource, Ctx};