From 7517a207db658c98d5b97b3b3f44df6725c025a2 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 2 Jun 2025 19:23:59 -0330 Subject: rename the Block trait to BlockTrait to disambiguate with azalea_registry::Block --- azalea-block/src/block_state.rs | 12 ++++++------ azalea-block/src/generated.rs | 2 +- azalea-block/src/lib.rs | 6 +++--- azalea-block/src/range.rs | 1 - 4 files changed, 10 insertions(+), 11 deletions(-) (limited to 'azalea-block/src') diff --git a/azalea-block/src/block_state.rs b/azalea-block/src/block_state.rs index dfa2a9b2..a954c333 100644 --- a/azalea-block/src/block_state.rs +++ b/azalea-block/src/block_state.rs @@ -5,7 +5,7 @@ use std::{ use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; -use crate::Block; +use crate::BlockTrait; /// The type that's used internally to represent a block state ID. /// @@ -121,14 +121,14 @@ impl Debug for BlockState { f, "BlockState(id: {}, {:?})", self.id, - Box::::from(*self) + Box::::from(*self) ) } } impl From for azalea_registry::Block { fn from(value: BlockState) -> Self { - Box::::from(value).as_registry_block() + Box::::from(value).as_registry_block() } } @@ -149,11 +149,11 @@ mod tests { #[test] fn test_from_blockstate() { - let block: Box = Box::::from(BlockState::AIR); + let block: Box = Box::::from(BlockState::AIR); assert_eq!(block.id(), "air"); - let block: Box = - Box::::from(BlockState::from(azalea_registry::Block::FloweringAzalea)); + let block: Box = + Box::::from(BlockState::from(azalea_registry::Block::FloweringAzalea)); assert_eq!(block.id(), "flowering_azalea"); } diff --git a/azalea-block/src/generated.rs b/azalea-block/src/generated.rs index 28dfe4f9..7c26291f 100644 --- a/azalea-block/src/generated.rs +++ b/azalea-block/src/generated.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use azalea_block_macros::make_block_states; -use crate::{Block, BlockBehavior, BlockState, BlockStates, Property}; +use crate::{BlockTrait, BlockBehavior, BlockState, BlockStates, Property}; make_block_states! { Properties => { diff --git a/azalea-block/src/lib.rs b/azalea-block/src/lib.rs index fdffe372..4f929cd3 100644 --- a/azalea-block/src/lib.rs +++ b/azalea-block/src/lib.rs @@ -15,7 +15,7 @@ pub use block_state::BlockState; pub use generated::{blocks, properties}; pub use range::BlockStates; -pub trait Block: Debug + Any { +pub trait BlockTrait: Debug + Any { fn behavior(&self) -> BlockBehavior; /// Get the Minecraft ID for this block. For example `stone` or /// `grass_block`. @@ -27,8 +27,8 @@ pub trait Block: Debug + Any { /// `azalea_registry::Block` doesn't contain any state data. fn as_registry_block(&self) -> azalea_registry::Block; } -impl dyn Block { - pub fn downcast_ref(&self) -> Option<&T> { +impl dyn BlockTrait { + pub fn downcast_ref(&self) -> Option<&T> { (self as &dyn Any).downcast_ref::() } } diff --git a/azalea-block/src/range.rs b/azalea-block/src/range.rs index 183c3cc0..cbe77284 100644 --- a/azalea-block/src/range.rs +++ b/azalea-block/src/range.rs @@ -1,7 +1,6 @@ use std::{ collections::{HashSet, hash_set}, ops::{Add, RangeInclusive}, - sync::LazyLock, }; use crate::{BlockState, block_state::BlockStateIntegerRepr}; -- cgit v1.2.3