deathcap / node-minecraft-protocol-auto

Automatic protocol negotiation for node-minecraft-protocol (moved to node-minecraft-protocols)
https://github.com/deathcap/node-minecraft-protocols
MIT License
1 stars 0 forks source link

Use minecraft-data to translate protocol version -> minecraft version #1

Open deathcap opened 8 years ago

deathcap commented 8 years ago
// see http://wiki.vg/Protocol_version_numbers
// Get the minecraft-data version string for a protocol version
// TODO: switch to using https://github.com/PrismarineJS/minecraft-data/pull/92
function protocol2version(n) {
  if (n >= 48) return '1.9'; // 1.9 snapshots (15w+), 16w03a is 96
  if (n >= 6 && n <= 47) return '1.8.9'; // including 1.8 snapshots (14w)
  if (n >= 4 && n <= 5) return '1.7.10'; // including 1.7 prereleases
  // TODO: earlier versions "Beginning with the 1.7.1 pre-release (and release 1.7.2), versioning was reset."
  throw new Error(`unsupported/unknown protocol version: ${versionProtocol}, update protocol2version`);
}