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

This commit is contained in:
Romain Beaumont 2015-10-09 12:30:43 +02:00
parent 2424dac368
commit 0873206011
3 changed files with 27 additions and 24 deletions

View file

@ -21,6 +21,10 @@ function inject(serv,player)
player.loadedChunks={}; player.loadedChunks={};
} }
function toFixedPosition(p)
{
return p.scaled(32).floored();
}
function sendLogin() function sendLogin()
{ {
// send init data so client will start rendering world // send init data so client will start rendering world
@ -33,7 +37,7 @@ function inject(serv,player)
reducedDebugInfo: false, reducedDebugInfo: false,
maxPlayers: serv._server.maxPlayers maxPlayers: serv._server.maxPlayers
}); });
player.entity.position=player.spawnPoint.scaled(32); player.entity.position=toFixedPosition(player.spawnPoint);
} }
function spiral(arr) function spiral(arr)
@ -115,13 +119,13 @@ function inject(serv,player)
function sendInitialPosition() function sendInitialPosition()
{ {
player.entity.position=player.spawnPoint; player.entity.position=toFixedPosition(player.spawnPoint);
player.entity.yaw=0; player.entity.yaw=0;
player.entity.pitch=0; player.entity.pitch=0;
player._client.write('position', { player._client.write('position', {
x: player.entity.position.x, x: player.entity.position.x/32,
y: player.entity.position.y, y: player.entity.position.y/32,
z: player.entity.position.z, z: player.entity.position.z/32,
yaw: player.entity.yaw, yaw: player.entity.yaw,
pitch: player.entity.pitch, pitch: player.entity.pitch,
flags: 0x00 flags: 0x00
@ -160,20 +164,19 @@ function inject(serv,player)
}] }]
}); });
player._client.write('player_info', { serv.players.map((otherPlayer) => {
action: 0, player._client.write('player_info', {
data: serv.players action: 0,
.map(function (otherPlayer) { data: [{
return { UUID: otherPlayer._client.uuid,
UUID: otherPlayer._client.uuid, name: otherPlayer.username,
name: otherPlayer.username, properties: [],
properties: [], gamemode: otherPlayer.gameMode,
gamemode: otherPlayer.gameMode, ping: 1,
ping: 1, hasDisplayName: true,
hasDisplayName: true, displayName: otherPlayer.username
displayName: otherPlayer.username }]
}; });
})
}); });
} }
@ -201,9 +204,9 @@ function inject(serv,player)
player._writeOthers('named_entity_spawn',{ player._writeOthers('named_entity_spawn',{
entityId: player.entity.id, entityId: player.entity.id,
playerUUID: player._client.uuid, playerUUID: player._client.uuid,
x: player.entity.position.x, x: player.entity.position.x/32,
y: player.entity.position.y, y: player.entity.position.y/32,
z: player.entity.position.z, z: player.entity.position.z/32,
yaw: player.entity.yaw, yaw: player.entity.yaw,
pitch: player.entity.pitch, pitch: player.entity.pitch,
currentItem: 0, currentItem: 0,

View file

@ -4,7 +4,7 @@ module.exports=inject;
function toFixedPosition(p) function toFixedPosition(p)
{ {
return p.scaled(32); return p.scaled(32).floored();
} }
function inject(serv,player) function inject(serv,player)

View file

@ -1,3 +1,3 @@
var mc = require("minecraft-protocol"); var mc = require("minecraft-protocol");
module.exports=mc.minecraftVersion; module.exports="1.8";