This commit is contained in:
Holly Stubbs 2021-08-12 05:13:25 +01:00
parent 1c775cfd60
commit c7a65b0dfa
5 changed files with 32 additions and 113 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

19
server/Entities/Entity.js Normal file
View file

@ -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;

View file

@ -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);
}
}

View file

@ -11,6 +11,8 @@ module.exports = class {
this.loginFinished = false; this.loginFinished = false;
this.entityRef = null;
this.chunksToSend = new funkyArray(); this.chunksToSend = new funkyArray();
} }
} }