mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-07 12:10:46 +00:00
add writeOthers function
This commit is contained in:
parent
71d6c1fa8c
commit
5f9a006132
1 changed files with 19 additions and 16 deletions
35
app.js
35
app.js
|
|
@ -35,7 +35,7 @@ for (var x = 0; x < 16;x++) {
|
||||||
var entityMaxId=0;
|
var entityMaxId=0;
|
||||||
|
|
||||||
var server = mc.createServer(options);
|
var server = mc.createServer(options);
|
||||||
|
|
||||||
if(settings.logging == true) {
|
if(settings.logging == true) {
|
||||||
createLog();
|
createLog();
|
||||||
}
|
}
|
||||||
|
|
@ -195,25 +195,28 @@ server.on('login', function(client) {
|
||||||
sendRelativePositionChange(client,toFixedPosition(position),onGround);
|
sendRelativePositionChange(client,toFixedPosition(position),onGround);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('position_look', function(packet) {
|
|
||||||
var position = new vec3(packet.x,packet.y,packet.z);
|
function writeOthers(packetName,packetFields)
|
||||||
var onGround=packet.onGround;
|
{
|
||||||
sendRelativePositionChange(client,toFixedPosition(position),onGround);
|
getOtherClients().forEach(function (otherClient) {
|
||||||
});
|
otherClient.write(packetName, packetFields);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sendRelativePositionChange(client,newPosition,onGround) {
|
function sendRelativePositionChange(client,newPosition,onGround) {
|
||||||
if (uuidToPlayer[client.uuid].position) {
|
if (uuidToPlayer[client.uuid].position) {
|
||||||
var diff = newPosition.minus(uuidToPlayer[client.uuid].position);
|
var diff = newPosition.minus(uuidToPlayer[client.uuid].position);
|
||||||
if(diff.distanceTo(new vec3(0,0,0))!=0)
|
if (diff.distanceTo(new vec3(0, 0, 0)) != 0) {
|
||||||
getOtherClients().forEach(function (otherClient) {
|
|
||||||
otherClient.write('rel_entity_move', {
|
writeOthers('rel_entity_move', {
|
||||||
entityId: uuidToPlayer[client.uuid].id,
|
entityId: client.id,
|
||||||
dX: diff.x,
|
dX: diff.x,
|
||||||
dY: diff.y,
|
dY: diff.y,
|
||||||
dZ: diff.z,
|
dZ: diff.z,
|
||||||
onGround: onGround
|
onGround: onGround
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
uuidToPlayer[client.uuid].position = newPosition;
|
uuidToPlayer[client.uuid].position = newPosition;
|
||||||
uuidToPlayer[client.uuid].onGround=onGround;
|
uuidToPlayer[client.uuid].onGround=onGround;
|
||||||
|
|
@ -268,7 +271,7 @@ server.on('listening', function() {
|
||||||
function createLog() {
|
function createLog() {
|
||||||
fs.writeFile("logs/" + timeStarted + ".log", "[INFO]: Started logging...\n", function(err, data) {
|
fs.writeFile("logs/" + timeStarted + ".log", "[INFO]: Started logging...\n", function(err, data) {
|
||||||
if (err) return console.log(err);
|
if (err) return console.log(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue