@@ -847,7 +847,7 @@ void nodePlacementPrediction(Client &client,
847
847
<<" ) - Name not known" <<std::endl;
848
848
return ;
849
849
}
850
- // Predict param2
850
+ // Predict param2 for facedir and wallmounted nodes
851
851
u8 param2 = 0 ;
852
852
if (nodedef->get (id).param_type_2 == CPT2_WALLMOUNTED){
853
853
v3s16 dir = nodepos - neighbourpos;
@@ -859,8 +859,33 @@ void nodePlacementPrediction(Client &client,
859
859
param2 = dir.Z < 0 ? 5 : 4 ;
860
860
}
861
861
}
862
- // TODO: Facedir prediction
863
- // TODO: If predicted node is in attached_node group, check attachment
862
+ if (nodedef->get (id).param_type_2 == CPT2_FACEDIR){
863
+ v3s16 dir = nodepos - floatToInt (client.getEnv ().getLocalPlayer ()->getPosition (), BS);
864
+ if (abs (dir.X ) > abs (dir.Z )){
865
+ param2 = dir.X < 0 ? 3 : 1 ;
866
+ } else {
867
+ param2 = dir.Z < 0 ? 2 : 0 ;
868
+ }
869
+ }
870
+ assert (param2 >= 0 && param2 <= 5 );
871
+ // Check attachment if node is in group attached_node
872
+ if (((ItemGroupList) nodedef->get (id).groups )[" attached_node" ] != 0 ){
873
+ static v3s16 wallmounted_dirs[8 ] = {
874
+ v3s16 (0 ,1 ,0 ),
875
+ v3s16 (0 ,-1 ,0 ),
876
+ v3s16 (1 ,0 ,0 ),
877
+ v3s16 (-1 ,0 ,0 ),
878
+ v3s16 (0 ,0 ,1 ),
879
+ v3s16 (0 ,0 ,-1 ),
880
+ };
881
+ v3s16 pp;
882
+ if (nodedef->get (id).param_type_2 == CPT2_WALLMOUNTED)
883
+ pp = p + wallmounted_dirs[param2];
884
+ else
885
+ pp = p + v3s16 (0 ,-1 ,0 );
886
+ if (!nodedef->get (map.getNode (pp)).walkable )
887
+ return ;
888
+ }
864
889
// Add node to client map
865
890
MapNode n (id, 0 , param2);
866
891
try {
0 commit comments