private bool FilterDirection(CoordInt block) { if (block.X == -1 && block.Y == 255 && block.Z == -1) { return(false); } //Player view is 1.5 above its position CoordDouble offset = block - this.Position + new CoordDouble(0.5, -1, 0.5); CoordDouble unit = new CoordDouble( -Math.Cos(Pitch * Math.PI / 180) * Math.Sin(Yaw * Math.PI / 180), -Math.Sin(Pitch * Math.PI / 180), Math.Cos(Pitch * Math.PI / 180) * Math.Cos(Yaw * Math.PI / 180)); double viewDist = offset.Scalar(unit); double perDist = (offset - unit * viewDist).Abs; #if DEBUG /*this.Tell ("Block: " + block + * //"Offset: " + offset.ToString ("0.0") + * //" Unit: " + unit.ToString ("0.0") + * " Dist: " + viewDist.ToString ("0.0") + * " Per: " + perDist.ToString ("0.0")); */ #endif //Ignore extreme values if (perDist > 20) { return(false); } if (viewDist > 20) { return(false); } //Logical max i 0.87 //Dont block anymore since client does not restore uncomfirmed blocks if (perDist > 1.5) { //Log.WritePlayer (this, "Aimed sideways: " + perDist.ToString ("0.00") + " > 0.87"); //return true; } if (viewDist > 6) { //Log.WritePlayer (this, "Aimed too far: " + viewDist.ToString ("0.0") + " > 6.0, " + block); //return true; } if (viewDist < -0.1) { //Log.WritePlayer (this, "Aimed behind: " + viewDist.ToString ("0.0") + " < 0"); //return true; } return(false); }