From 5e3deed67232cfa67471536814fc0fd61e93011f Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 26 Jun 2011 19:23:44 +0300 Subject: [PATCH] Added CPT_FACEDIR_SIMPLE calculation, finally, as figured out by spongie --- src/server.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 */ -- 2.30.2