From: Perttu Ahola Date: Sun, 26 Jun 2011 16:23:44 +0000 (+0300) Subject: Added CPT_FACEDIR_SIMPLE calculation, finally, as figured out by spongie X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=5e3deed67232cfa67471536814fc0fd61e93011f;p=zefram%2Fminetest%2Fminetest_engine.git Added CPT_FACEDIR_SIMPLE calculation, finally, as figured out by spongie --- diff --git a/src/server.cpp b/src/server.cpp index 18357e19..2ee94f34 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2734,9 +2734,31 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) MaterialItem *mitem = (MaterialItem*)item; MapNode n; n.d = mitem->getMaterial(); + + // Calculate direction for wall mounted stuff if(content_features(n.d).wall_mounted) n.dir = packDir(p_under - p_over); - + + // Calculate the direction for furnaces and chests and stuff + if(content_features(n.d).param_type == CPT_FACEDIR_SIMPLE) + { + v3f playerpos = player->getPosition(); + v3f blockpos = intToFloat(p_over, BS) - playerpos; + blockpos = blockpos.normalize(); + n.param1 = 0; + if (fabs(blockpos.X) > fabs(blockpos.Z)) { + if (blockpos.X < 0) + n.param1 = 3; + else + n.param1 = 1; + } else { + if (blockpos.Z < 0) + n.param1 = 2; + else + n.param1 = 0; + } + } + /* Send to all close-by players */