remove #[async_trait] from many many places

Compile time got improved by 77% (including last commit)
This commit is contained in:
Alexander Medvedev committed 2025-12-04 13:57:03 +01:00
1 parent 71392b4a38
commit ae751f3a83
205 files changed
+11326 -9622

No files matched your search

+27 -26
View File
@@ -1,3 +1,4 @@
use std::pin::Pin;
use std::sync::Arc;
use crate::entity::Entity;
@@ -5,7 +6,6 @@ use crate::entity::decoration::end_crystal::EndCrystalEntity;
use crate::entity::player::Player;
use crate::item::{ItemBehaviour, ItemMetadata};
use crate::server::Server;
use async_trait::async_trait;
use pumpkin_data::entity::EntityType;
use pumpkin_data::item::Item;
use pumpkin_data::{Block, BlockDirection};
@@ -21,35 +21,36 @@ impl ItemMetadata for EndCrystalItem {
}
}
#[async_trait]
impl ItemBehaviour for EndCrystalItem {
async fn use_on_block(
&self,
item: &mut ItemStack,
player: &Player,
fn use_on_block<'a>(
&'a self,
item: &'a mut ItemStack,
player: &'a Player,
location: BlockPos,
_face: BlockDirection,
_block: &Block,
_server: &Server,
) {
let world = player.world();
let block = world.get_block(&location).await;
if block != &Block::OBSIDIAN && block != &Block::BEDROCK {
return;
}
_block: &'a Block,
_server: &'a Server,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
Box::pin(async move {
let world = player.world();
let block = world.get_block(&location).await;
if block != &Block::OBSIDIAN && block != &Block::BEDROCK {
return;
}
let location = location.up();
let entity = Entity::new(
Uuid::new_v4(),
world.clone(),
location.to_f64(),
&EntityType::END_CRYSTAL,
false,
);
let end_crystal = Arc::new(EndCrystalEntity::new(entity));
world.spawn_entity(end_crystal.clone()).await;
end_crystal.set_show_bottom(false).await;
item.decrement_unless_creative(player.gamemode.load(), 1);
let location = location.up();
let entity = Entity::new(
Uuid::new_v4(),
world.clone(),
location.to_f64(),
&EntityType::END_CRYSTAL,
false,
);
let end_crystal = Arc::new(EndCrystalEntity::new(entity));
world.spawn_entity(end_crystal.clone()).await;
end_crystal.set_show_bottom(false).await;
item.decrement_unless_creative(player.gamemode.load(), 1);
})
}
fn as_any(&self) -> &dyn std::any::Any {