Can you move the "-180" into the PlayerYawToMetadata() calculation? So that the function stays true to its name - it converts raw player yaw into metadata.