@@ -5,10 +5,10 @@ use crate::{
55 BlockBehaviour , BlockFuture , BlockIsReplacing , CanPlaceAtArgs , CanUpdateAtArgs ,
66 GetStateForNeighborUpdateArgs , OnPlaceArgs , UseWithItemArgs , registry:: BlockActionResult ,
77 } ,
8- entity:: player:: Player ,
8+ entity:: { EntityBase , player:: Player } ,
99} ;
1010use pumpkin_data:: {
11- Block , BlockDirection ,
11+ Block , BlockDirection , FacingExt ,
1212 block_properties:: { BlockProperties , VineLikeProperties } ,
1313 item:: Item ,
1414} ;
@@ -158,7 +158,17 @@ pub fn get_nearest_looking_directions(
158158 replace_clicked : bool ,
159159 clicked_face : BlockDirection ,
160160) -> [ BlockDirection ; 6 ] {
161- let mut directions = ordered_by_nearest ( player) ;
161+ let mut directions: [ BlockDirection ; 6 ] = {
162+ let fs = player. get_entity ( ) . get_entity_facing_order ( ) ;
163+ [
164+ fs[ 0 ] . to_block_direction ( ) ,
165+ fs[ 1 ] . to_block_direction ( ) ,
166+ fs[ 2 ] . to_block_direction ( ) ,
167+ fs[ 3 ] . to_block_direction ( ) ,
168+ fs[ 4 ] . to_block_direction ( ) ,
169+ fs[ 5 ] . to_block_direction ( ) ,
170+ ]
171+ } ;
162172
163173 if !replace_clicked {
164174 let target = clicked_face. opposite ( ) ;
@@ -176,72 +186,6 @@ pub fn get_nearest_looking_directions(
176186 }
177187 directions
178188}
179- pub fn ordered_by_nearest ( player : & Player ) -> [ BlockDirection ; 6 ] {
180- let ( yaw_degrees, pitch_degrees) = player. rotation ( ) ;
181- let yaw = -yaw_degrees. to_radians ( ) ;
182- let pitch = pitch_degrees. to_radians ( ) ;
183- let pitch_sin = pitch. sin ( ) ;
184- let pitch_cos = pitch. cos ( ) ;
185- let yaw_sin = yaw. sin ( ) ;
186- let yaw_cos = yaw. cos ( ) ;
187-
188- let x_pos = yaw_sin > 0.0 ;
189- let y_pos = pitch_sin < 0.0 ;
190- let z_pos = yaw_cos > 0.0 ;
191-
192- let x_yaw = if x_pos { yaw_sin } else { -yaw_sin } ;
193- let y_mag = if y_pos { -pitch_sin } else { pitch_sin } ;
194- let z_yaw = if z_pos { yaw_cos } else { -yaw_cos } ;
195-
196- let x_mag = x_yaw * pitch_cos;
197- let z_mag = z_yaw * pitch_cos;
198-
199- let axis_x = if x_pos {
200- BlockDirection :: East
201- } else {
202- BlockDirection :: West
203- } ;
204- let axis_y = if y_pos {
205- BlockDirection :: Up
206- } else {
207- BlockDirection :: Down
208- } ;
209- let axis_z = if z_pos {
210- BlockDirection :: South
211- } else {
212- BlockDirection :: North
213- } ;
214-
215- if x_yaw > z_yaw {
216- if y_mag > x_mag {
217- make_direction_array ( axis_y, axis_x, axis_z)
218- } else if z_mag > y_mag {
219- make_direction_array ( axis_x, axis_z, axis_y)
220- } else {
221- make_direction_array ( axis_x, axis_y, axis_z)
222- }
223- } else if y_mag > z_mag {
224- make_direction_array ( axis_y, axis_z, axis_x)
225- } else if x_mag > y_mag {
226- make_direction_array ( axis_z, axis_x, axis_y)
227- } else {
228- make_direction_array ( axis_z, axis_y, axis_x)
229- }
230- }
231- const fn make_direction_array (
232- axis1 : BlockDirection ,
233- axis2 : BlockDirection ,
234- axis3 : BlockDirection ,
235- ) -> [ BlockDirection ; 6 ] {
236- [
237- axis1,
238- axis2,
239- axis3,
240- axis3. opposite ( ) ,
241- axis2. opposite ( ) ,
242- axis1. opposite ( ) ,
243- ]
244- }
245189async fn can_place_vine_at (
246190 block_accessor : & dyn BlockAccessor ,
247191 block_pos : & BlockPos ,
@@ -278,7 +222,7 @@ const fn supports_vine(support_block: &Block) -> bool {
278222 false
279223}
280224//returns (accurate direction, boolean)
281- // true if this direction is for hanging leaf
225+ // true if this direction is for hanging vine
282226// false if it is not
283227async fn get_accurate_direction (
284228 block_accessor : & dyn BlockAccessor ,
0 commit comments