From 0873206011e9174aa2359e31645254594aba2f8e Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Fri, 9 Oct 2015 12:30:43 +0200 Subject: [PATCH] fix missing fixedPosition conversion, bypass nmp 0.15 uuid+array bug by sending multiple player_info, fix the mc version since next nmp version will support cross version --- src/lib/playerPlugins/login.js | 47 +++++++++++++----------- src/lib/playerPlugins/updatePositions.js | 2 +- src/lib/version.js | 2 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/lib/playerPlugins/login.js b/src/lib/playerPlugins/login.js index 36c08d2..c91cc35 100644 --- a/src/lib/playerPlugins/login.js +++ b/src/lib/playerPlugins/login.js @@ -21,6 +21,10 @@ function inject(serv,player) player.loadedChunks={}; } + function toFixedPosition(p) + { + return p.scaled(32).floored(); + } function sendLogin() { // send init data so client will start rendering world @@ -33,7 +37,7 @@ function inject(serv,player) reducedDebugInfo: false, maxPlayers: serv._server.maxPlayers }); - player.entity.position=player.spawnPoint.scaled(32); + player.entity.position=toFixedPosition(player.spawnPoint); } function spiral(arr) @@ -115,13 +119,13 @@ function inject(serv,player) function sendInitialPosition() { - player.entity.position=player.spawnPoint; + player.entity.position=toFixedPosition(player.spawnPoint); player.entity.yaw=0; player.entity.pitch=0; player._client.write('position', { - x: player.entity.position.x, - y: player.entity.position.y, - z: player.entity.position.z, + x: player.entity.position.x/32, + y: player.entity.position.y/32, + z: player.entity.position.z/32, yaw: player.entity.yaw, pitch: player.entity.pitch, flags: 0x00 @@ -160,20 +164,19 @@ function inject(serv,player) }] }); - player._client.write('player_info', { - action: 0, - data: serv.players - .map(function (otherPlayer) { - return { - UUID: otherPlayer._client.uuid, - name: otherPlayer.username, - properties: [], - gamemode: otherPlayer.gameMode, - ping: 1, - hasDisplayName: true, - displayName: otherPlayer.username - }; - }) + serv.players.map((otherPlayer) => { + player._client.write('player_info', { + action: 0, + data: [{ + UUID: otherPlayer._client.uuid, + name: otherPlayer.username, + properties: [], + gamemode: otherPlayer.gameMode, + ping: 1, + hasDisplayName: true, + displayName: otherPlayer.username + }] + }); }); } @@ -201,9 +204,9 @@ function inject(serv,player) player._writeOthers('named_entity_spawn',{ entityId: player.entity.id, playerUUID: player._client.uuid, - x: player.entity.position.x, - y: player.entity.position.y, - z: player.entity.position.z, + x: player.entity.position.x/32, + y: player.entity.position.y/32, + z: player.entity.position.z/32, yaw: player.entity.yaw, pitch: player.entity.pitch, currentItem: 0, diff --git a/src/lib/playerPlugins/updatePositions.js b/src/lib/playerPlugins/updatePositions.js index 0dd2941..9190e68 100644 --- a/src/lib/playerPlugins/updatePositions.js +++ b/src/lib/playerPlugins/updatePositions.js @@ -4,7 +4,7 @@ module.exports=inject; function toFixedPosition(p) { - return p.scaled(32); + return p.scaled(32).floored(); } function inject(serv,player) diff --git a/src/lib/version.js b/src/lib/version.js index 7de8e70..c25e3a6 100644 --- a/src/lib/version.js +++ b/src/lib/version.js @@ -1,3 +1,3 @@ var mc = require("minecraft-protocol"); -module.exports=mc.minecraftVersion; \ No newline at end of file +module.exports="1.8"; \ No newline at end of file