From c7a65b0dfaab4750b1a02805d083262efc312f2a Mon Sep 17 00:00:00 2001 From: holly Date: Thu, 12 Aug 2021 05:13:25 +0100 Subject: [PATCH] trhsry --- old/chunk.js | 67 ----------------------------------- old/nibbleArray.js | 46 ------------------------ server/Entities/Entity.js | 19 ++++++++++ server/Entities/EntityItem.js | 11 ++++++ server/user.js | 2 ++ 5 files changed, 32 insertions(+), 113 deletions(-) delete mode 100644 old/chunk.js delete mode 100644 old/nibbleArray.js create mode 100644 server/Entities/Entity.js create mode 100644 server/Entities/EntityItem.js diff --git a/old/chunk.js b/old/chunk.js deleted file mode 100644 index e2693f3..0000000 --- a/old/chunk.js +++ /dev/null @@ -1,67 +0,0 @@ -const nibbleArray = require("./nibbleArray.js"); - -module.exports = class { - constructor(xPos = 0, zPos = 0) { - this.xPos = xPos; - this.zPos = zPos; - - this.blocks = Buffer.alloc(256 * 128); - - this.data = new nibbleArray(this.blocks.length, 7); - - this.skylightMap = new nibbleArray(this.blocks.length, 7); - - this.blocklightMap = new nibbleArray(this.blocks.length, 7); - } - - getChunkData(xPos, yPos, zPos, l, i1, j1) { - let abyte0 = Buffer.alloc((l * i1 * j1 * 5) / 2); - let k1 = xPos >> 4; - let l1 = zPos >> 4; - let i2 = (xPos + l) - 1 >> 4; - let j2 = (zPos + j1) - 1 >> 4; - let k2 = 0; - let l2 = yPos; - let i3 = yPos + i1; - if(l2 < 0) - { - l2 = 0; - } - if(i3 > 128) - { - i3 = 128; - } - for(let j3 = k1; j3 <= i2; j3++) - { - let k3 = xPos - j3 * 16; - let l3 = (xPos + l) - j3 * 16; - if(k3 < 0) - { - k3 = 0; - } - if(l3 > 16) - { - l3 = 16; - } - for(let i4 = l1; i4 <= j2; i4++) - { - let j4 = zPos - i4 * 16; - let k4 = (zPos + j1) - i4 * 16; - if(j4 < 0) - { - j4 = 0; - } - if(k4 > 16) - { - k4 = 16; - } - k2 = 1;//getChunkFromChunkCoords(j3, i4).getChunkData(abyte0, k3, l2, j4, l3, i3, k4, k2); - } - - } - - return abyte0; - } - - -} \ No newline at end of file diff --git a/old/nibbleArray.js b/old/nibbleArray.js deleted file mode 100644 index 76ae3ca..0000000 --- a/old/nibbleArray.js +++ /dev/null @@ -1,46 +0,0 @@ -module.exports = class { - constructor(i, j) { - if (i instanceof Buffer) { - this.data = abyte0; - this.field_35661_b = i; - this.field_35662_c = i + 4; - } else { - this.data = new Buffer.alloc(i >> 1); - this.field_35661_b = j; - this.field_35662_c = j + 4; - } - } - - getNibble(i, j, k) - { - let l = i << field_35662_c | k << field_35661_b | j; - let i1 = l >> 1; - let j1 = l & 1; - if(j1 == 0) - { - return data[i1] & 0xf; - } else - { - return data[i1] >> 4 & 0xf; - } - } - - setNibble(i, j, k, l) - { - let i1 = i << this.field_35662_c | k << this.field_35661_b | j; - let j1 = i1 >> 1; - let k1 = i1 & 1; - if(k1 == 0) - { - data[j1] = (this.data[j1] & 0xf0 | l & 0xf); - } else - { - data[j1] = (this.data[j1] & 0xf | (l & 0xf) << 4); - } - } - - isValid() - { - return this.data != null; - } -} \ No newline at end of file diff --git a/server/Entities/Entity.js b/server/Entities/Entity.js new file mode 100644 index 0000000..4895783 --- /dev/null +++ b/server/Entities/Entity.js @@ -0,0 +1,19 @@ +class Entity { + constructor(x = 0, y = 0, z = 0, yaw = 0, pitch = 0) { + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + } + + onTick() { + + } +} + +module.exports = Entity; \ No newline at end of file diff --git a/server/Entities/EntityItem.js b/server/Entities/EntityItem.js new file mode 100644 index 0000000..e1f537c --- /dev/null +++ b/server/Entities/EntityItem.js @@ -0,0 +1,11 @@ +const Entity = require("./Entity.js"); + +class EntityItem extends Entity { + constructor(itemID = 0x00, x = 0, y = 0, z = 0) { + super(x, y, z); + + this.motionX = (Math.random() * 0.2 - 0.1); + this.motionY = 0.2; + this.motionZ = (Math.random() * 0.2 - 0.1); + } +} \ No newline at end of file diff --git a/server/user.js b/server/user.js index 02972ee..778cb59 100644 --- a/server/user.js +++ b/server/user.js @@ -11,6 +11,8 @@ module.exports = class { this.loginFinished = false; + this.entityRef = null; + this.chunksToSend = new funkyArray(); } } \ No newline at end of file