diff --git a/server/Converter.js b/server/Converter.js index b440130..b0f30f2 100644 --- a/server/Converter.js +++ b/server/Converter.js @@ -1,3 +1,7 @@ module.exports.toAbsoluteInt = function(float = 0.0) { return Math.round(float * 32.0); +} + +module.exports.to360Fraction = function(float = 0.0) { + return Math.floor((float / 360) * 256); } \ No newline at end of file diff --git a/server/Entities/EntityItem.js b/server/Entities/EntityItem.js index 71eef72..cfb974c 100644 --- a/server/Entities/EntityItem.js +++ b/server/Entities/EntityItem.js @@ -1,9 +1,11 @@ const Entity = require("./Entity.js"); class EntityItem extends Entity { - constructor(itemID = 0x00, x = 0, y = 0, z = 0) { + constructor(itemStack, x = 0, y = 0, z = 0) { super(global.fromIDPool(), x, y, z); + this.itemStack = itemStack; + this.motionX = (Math.random() * 0.2 - 0.1); this.motionY = 0.2; this.motionZ = (Math.random() * 0.2 - 0.1); diff --git a/server/Packets/Packet20NamedEntitySpawn.js b/server/Packets/Packet20NamedEntitySpawn.js index 963d9ee..22a4621 100644 --- a/server/Packets/Packet20NamedEntitySpawn.js +++ b/server/Packets/Packet20NamedEntitySpawn.js @@ -10,8 +10,8 @@ class Packet20NamedEntitySpawn extends Packet { this.absX = Converter.toAbsoluteInt(x); this.absY = Converter.toAbsoluteInt(y); this.absZ = Converter.toAbsoluteInt(z); - this.packedYaw = 0; // TODO: Add rotation. - this.packedPitch = 0; + this.packedYaw = Converter.to360Fraction(yaw); + this.packedPitch = Converter.to360Fraction(pitch); this.currentItem = currentItem; } diff --git a/server/Packets/Packet4TimeUpdate.js b/server/Packets/Packet4TimeUpdate.js index 0360f47..2db5d78 100644 --- a/server/Packets/Packet4TimeUpdate.js +++ b/server/Packets/Packet4TimeUpdate.js @@ -11,7 +11,7 @@ class Packet4TimeUpdate extends Packet { } - writePacket(EID = 0) { + writePacket() { super.writePacket(); this.writer.writeLong(this.time); diff --git a/server/chunkManager.js b/server/chunkManager.js index 598dba8..97a8356 100644 --- a/server/chunkManager.js +++ b/server/chunkManager.js @@ -22,9 +22,10 @@ module.exports = class { this.threadPool.push([false, worker]); const myID = i; worker.on("message", (data) => { + let user; switch (data[0]) { case "chunk": - const user = global.getUserByKey(data[2]); + user = global.getUserByKey(data[2]); user.chunksToSend.add(Buffer.from(data[1])); this.toRemove.push(data[1]); this.threadPool[myID][0] = false;