@@ -95,4 +95,60 @@ impl EntityAppearance<Dungeon> for BlockAppearance {
9595 packet. entities . push ( VarInt ( entity. id ) ) ;
9696 packet. entities . push ( VarInt ( entity. id + 1 ) ) ;
9797 }
98+ }
99+
100+ // doesn't prevent clientside gravity whatsoever, used for falling blocks and in ice fill
101+ #[ derive( Component ) ]
102+ pub struct FallingBlockAppearance {
103+ pub block : Block
104+ }
105+
106+ impl EntityAppearance < Dungeon > for FallingBlockAppearance {
107+
108+ fn enter_player_view ( & self , entity : & MinecraftEntity < Dungeon > , player : & mut Player < DungeonPlayer > ) {
109+ let DVec3 { x, y, z } = entity. position ;
110+
111+ let object_data = {
112+ let block_state_id = self . block . get_blockstate_id ( ) as i32 ;
113+ let block_id = block_state_id >> 4 ;
114+ let metadata = block_state_id & 0b1111 ;
115+ block_id | ( metadata << 12 )
116+ } ;
117+
118+ player. write_packet ( & SpawnObject {
119+ entity_id : entity. id ,
120+ variant : ObjectVariant :: FallingBlock ,
121+ x,
122+ y,
123+ z,
124+ pitch : 0.0 ,
125+ yaw : 0.0 ,
126+ data : object_data,
127+ velocity_x : 0.0 ,
128+ velocity_y : 0.0 ,
129+ velocity_z : 0.0 ,
130+ } ) ;
131+ }
132+
133+ fn leave_player_view ( & self , entity : & MinecraftEntity < Dungeon > , player : & mut Player < DungeonPlayer > ) {
134+ player. write_packet ( & DestroyEntites {
135+ entities : vec ! [ VarInt ( entity. id) ] ,
136+ } )
137+ }
138+
139+ fn update_position ( & self , entity : & MinecraftEntity < Dungeon > , packet_buffer : & mut PacketBuffer ) {
140+ packet_buffer. write_packet ( & EntityTeleport {
141+ entity_id : entity. id ,
142+ pos_x : entity. position . x ,
143+ pos_y : entity. position . y ,
144+ pos_z : entity. position . z ,
145+ yaw : 0.0 ,
146+ pitch : 0.0 ,
147+ on_ground : false ,
148+ } ) ;
149+ }
150+
151+ fn destroy ( & self , entity : & MinecraftEntity < Dungeon > , packet : & mut DestroyEntites ) {
152+ packet. entities . push ( VarInt ( entity. id ) ) ;
153+ }
98154}
0 commit comments