@@ -9,16 +9,17 @@ use anyhow::bail;
99use glam:: { ivec3, DVec3 , IVec2 } ;
1010use server:: block:: block_parameter:: Axis ;
1111use server:: block:: rotatable:: Rotate ;
12+ use server:: commands:: command_parse:: GreedyString ;
1213use server:: constants:: Gamemode ;
1314use server:: inventory:: menu:: OpenContainer ;
1415use server:: network:: binary:: var_int:: VarInt ;
15- use server:: network:: protocol:: play:: clientbound:: { Chat , EntityProperties , PlayerAbilities } ;
16+ use server:: network:: protocol:: play:: clientbound:: { Chat , EntityProperties , PlayerAbilities , PositionLook , Relative } ;
1617use server:: player:: attribute:: { Attribute , AttributeMap , AttributeModifier } ;
1718use server:: player:: sidebar:: Sidebar ;
1819use server:: types:: aabb:: AABB ;
1920use server:: types:: chat_component:: ChatComponent ;
2021use server:: utils:: hasher:: deterministic_hasher:: DeterministicHashMap ;
21- use server:: { ClientId , GameProfile , Player , World , WorldExtension } ;
22+ use server:: { command , ClientId , GameProfile , Player , World , WorldExtension } ;
2223use std:: cell:: { Cell , RefCell } ;
2324use std:: collections:: HashMap ;
2425use std:: rc:: Rc ;
@@ -202,6 +203,30 @@ impl WorldExtension for Dungeon {
202203 player. inventory . set_slot ( 43 , Some ( DungeonItem :: AspectOfTheVoid ) ) ;
203204 player. inventory . set_slot ( 44 , Some ( DungeonItem :: SkyblockMenu ) ) ;
204205 player. sync_inventory ( ) ;
206+
207+ let cmd = command ! ( "tproom" , |player: & mut Player <DungeonPlayer >, room_name: GreedyString | {
208+ let name = room_name. str ;
209+ for room_rc in player. world( ) . rooms. iter( ) {
210+ let room = room_rc. borrow( ) ;
211+ if room. data. name. to_lowercase( ) . contains( name) {
212+ for neighbour in room. neighbours( ) {
213+ let door = neighbour. door. borrow( ) ;
214+ player. write_packet( & PositionLook {
215+ x: door. x as f64 + 0.5 ,
216+ y: 69.0 ,
217+ z: door. z as f64 + 0.5 ,
218+ yaw: 0.0 ,
219+ pitch: 0.0 ,
220+ flags: Relative :: Yaw | Relative :: Pitch ,
221+ } ) ;
222+ }
223+ return Ok ( ( ) ) ;
224+ }
225+ }
226+ player. send_message( format!( "no room with name containing {name}" ) . as_str( ) )
227+ } ) ;
228+ player. command_dispatcher_mut ( ) . register_command ( cmd) ;
229+
205230 player. flush_packets ( )
206231 }
207232
0 commit comments