@@ -8,14 +8,16 @@ use azalea_client::{
88} ;
99use azalea_core:: {
1010 game_type:: { GameMode , OptionalGameType } ,
11- position:: Vec3 ,
1211 resource_location:: ResourceLocation ,
1312 tick:: GameTick ,
1413} ;
15- use azalea_entity:: { metadata:: Health , LocalEntity , Position } ;
14+ use azalea_entity:: {
15+ metadata:: { Health , PlayerMetadataBundle } ,
16+ LocalEntity ,
17+ } ;
1618use azalea_protocol:: packets:: {
1719 common:: CommonPlayerSpawnInfo ,
18- config:: ClientboundFinishConfiguration ,
20+ config:: { ClientboundFinishConfiguration , ClientboundRegistryData } ,
1921 game:: { ClientboundLogin , ClientboundSetHealth } ,
2022 ConnectionProtocol , Packet , ProtocolPacket ,
2123} ;
@@ -26,6 +28,7 @@ use bevy_app::PluginGroup;
2628use bevy_ecs:: { prelude:: * , schedule:: ExecutorKind } ;
2729use bevy_log:: { tracing_subscriber, LogPlugin } ;
2830use parking_lot:: { Mutex , RwLock } ;
31+ use simdnbt:: owned:: { NbtCompound , NbtTag } ;
2932use tokio:: { sync:: mpsc, time:: sleep} ;
3033use uuid:: Uuid ;
3134
@@ -36,6 +39,19 @@ fn test_set_health_before_login() {
3639 let mut simulation = Simulation :: new ( ConnectionProtocol :: Configuration ) ;
3740 assert ! ( simulation. has_component:: <InConfigState >( ) ) ;
3841
42+ simulation. receive_packet ( ClientboundRegistryData {
43+ registry_id : ResourceLocation :: new ( "minecraft:dimension_type" ) ,
44+ entries : vec ! [ (
45+ ResourceLocation :: new( "minecraft:overworld" ) ,
46+ Some ( NbtCompound :: from_values( vec![
47+ ( "height" . into( ) , NbtTag :: Int ( 384 ) ) ,
48+ ( "min_y" . into( ) , NbtTag :: Int ( -64 ) ) ,
49+ ] ) ) ,
50+ ) ]
51+ . into_iter ( )
52+ . collect ( ) ,
53+ } ) ;
54+ simulation. tick ( ) ;
3955 simulation. receive_packet ( ClientboundFinishConfiguration ) ;
4056 simulation. tick ( ) ;
4157
@@ -62,7 +78,7 @@ fn test_set_health_before_login() {
6278 do_limited_crafting : false ,
6379 common : CommonPlayerSpawnInfo {
6480 dimension_type : DimensionType :: Overworld ,
65- dimension : ResourceLocation :: new ( "overworld" ) ,
81+ dimension : ResourceLocation :: new ( "minecraft: overworld" ) ,
6682 seed : 0 ,
6783 game_type : GameMode :: Survival ,
6884 previous_game_type : OptionalGameType ( None ) ,
@@ -124,7 +140,7 @@ pub fn create_local_player_bundle(
124140 connection_protocol,
125141 } ;
126142
127- let ( local_player_events_sender, local_player_events_receiver ) = mpsc:: unbounded_channel ( ) ;
143+ let ( local_player_events_sender, _local_player_events_receiver ) = mpsc:: unbounded_channel ( ) ;
128144
129145 let instance = Instance :: default ( ) ;
130146 let instance_holder = InstanceHolder :: new ( entity, Arc :: new ( RwLock :: new ( instance) ) ) ;
@@ -135,7 +151,9 @@ pub fn create_local_player_bundle(
135151 game_profile : GameProfileComponent ( GameProfile :: new ( Uuid :: nil ( ) , "azalea" . to_owned ( ) ) ) ,
136152 client_information : ClientInformation :: default ( ) ,
137153 instance_holder,
154+ metadata : PlayerMetadataBundle :: default ( ) ,
138155 } ;
156+
139157 (
140158 local_player_bundle,
141159 outgoing_packets_receiver,
@@ -144,10 +162,6 @@ pub fn create_local_player_bundle(
144162 )
145163}
146164
147- fn simulation_instance_name ( ) -> ResourceLocation {
148- ResourceLocation :: new ( "azalea:simulation" )
149- }
150-
151165fn create_simulation_app ( ) -> App {
152166 let mut app = App :: new ( ) ;
153167 app. add_plugins ( azalea_client:: DefaultPlugins . build ( ) . disable :: < LogPlugin > ( ) ) ;
@@ -201,7 +215,6 @@ impl Simulation {
201215 pub fn receive_packet < P : ProtocolPacket + Debug > ( & mut self , packet : impl Packet < P > ) {
202216 let buf = azalea_protocol:: write:: serialize_packet ( & packet. into_variant ( ) ) . unwrap ( ) ;
203217 self . incoming_packet_queue . lock ( ) . push ( buf. into ( ) ) ;
204- println ! ( "added to incoming_packet_queue" ) ;
205218 }
206219
207220 pub fn tick ( & mut self ) {
@@ -216,9 +229,6 @@ impl Simulation {
216229 pub fn has_component < T : Component > ( & self ) -> bool {
217230 self . app . world ( ) . get :: < T > ( self . entity ) . is_some ( )
218231 }
219- pub fn position ( & self ) -> Vec3 {
220- * self . component :: < Position > ( )
221- }
222232}
223233
224234fn tick_app ( app : & mut App ) {
0 commit comments