code cleanup
This commit is contained in:
parent
3d24527e50
commit
ad550a8e7b
5 changed files with 12 additions and 5 deletions
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class Packet4TimeUpdate extends Packet {
|
|||
|
||||
}
|
||||
|
||||
writePacket(EID = 0) {
|
||||
writePacket() {
|
||||
super.writePacket();
|
||||
|
||||
this.writer.writeLong(this.time);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue