From 26d619c9a329087a23d6577ee74bd764f50cd773 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:29:59 -0600 Subject: Enchantments (#286) * start implementing enchants * store parsed registries * more work on enchants * implement deserializer for some entity effects * mostly working definitions for enchants * fix tests * detect equipment changes * fix errors * update changelog * fix some imports * remove outdated todo * add basic test for enchants applying attributes * use git simdnbt --- azalea-client/src/test_utils/simulation.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'azalea-client/src/test_utils') diff --git a/azalea-client/src/test_utils/simulation.rs b/azalea-client/src/test_utils/simulation.rs index 13470600..2319a9c4 100644 --- a/azalea-client/src/test_utils/simulation.rs +++ b/azalea-client/src/test_utils/simulation.rs @@ -1,4 +1,4 @@ -use std::{collections::VecDeque, fmt::Debug, sync::Arc}; +use std::{any, collections::VecDeque, fmt::Debug, sync::Arc}; use azalea_auth::game_profile::GameProfile; use azalea_block::BlockState; @@ -28,7 +28,12 @@ use azalea_protocol::{ use azalea_registry::{Biome, DataRegistry, DimensionType, EntityKind}; use azalea_world::{Chunk, Instance, MinecraftEntityId, Section, palette::PalettedContainer}; use bevy_app::App; -use bevy_ecs::{component::Mutable, prelude::*, schedule::ExecutorKind}; +use bevy_ecs::{ + component::Mutable, + prelude::*, + query::{QueryData, QueryItem}, + schedule::ExecutorKind, +}; use parking_lot::{Mutex, RwLock}; use simdnbt::owned::{NbtCompound, NbtTag}; use uuid::Uuid; @@ -133,6 +138,18 @@ impl Simulation { pub fn with_component(&self, f: impl FnOnce(&T)) { f(self.app.world().entity(self.entity).get::().unwrap()); } + pub fn query_self(&mut self, f: impl FnOnce(QueryItem) -> R) -> R { + let mut ecs = self.app.world_mut(); + let mut qs = ecs.query::(); + let res = qs.get_mut(&mut ecs, self.entity).unwrap_or_else(|_| { + panic!( + "Our client is missing a required component {:?}", + any::type_name::() + ) + }); + f(res) + } + pub fn with_component_mut>( &mut self, f: impl FnOnce(&mut T), -- cgit v1.2.3