implement player and movement input
This commit is contained in:
@@ -15,6 +15,38 @@ window.World = class {
|
||||
}
|
||||
}
|
||||
|
||||
getChunkAtBlock(x, y, z) {
|
||||
let chunk = this.getChunkAt(x >> 4, z >> 4);
|
||||
return y < 0 || y > World.TOTAL_HEIGHT ? null : chunk.getSection(y >> 4);
|
||||
}
|
||||
|
||||
getCollisionBoxes(aabb) {
|
||||
let boundingBoxList = [];
|
||||
|
||||
let minX = Math.floor(aabb.minX) - 1;
|
||||
let maxX = Math.ceil(aabb.maxX) + 1;
|
||||
let minY = Math.floor(aabb.minY) - 1;
|
||||
let maxY = Math.ceil(aabb.maxY) + 1;
|
||||
let minZ = Math.floor(aabb.minZ) - 1;
|
||||
let maxZ = Math.ceil(aabb.maxZ) + 1;
|
||||
|
||||
for (let x = minX; x < maxX; x++) {
|
||||
for (let y = minY; y < maxY; y++) {
|
||||
for (let z = minZ; z < maxZ; z++) {
|
||||
if (this.isSolidBlockAt(x, y, z)) {
|
||||
boundingBoxList.push(new BoundingBox(x, y, z, x + 1, y + 1, z + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return boundingBoxList;
|
||||
}
|
||||
|
||||
isSolidBlockAt(x, y, z) {
|
||||
let typeId = this.getBlockAt(x, y, z);
|
||||
return typeId !== 0; /* && Block.getById(typeId).isSolid();*/
|
||||
}
|
||||
|
||||
setBlockAt(x, y, z, type) {
|
||||
let chunkSection = this.getChunkAtBlock(x, y, z);
|
||||
if (chunkSection != null) {
|
||||
@@ -24,6 +56,12 @@ window.World = class {
|
||||
this.blockChanged(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
getBlockAt(x, y, z) {
|
||||
let chunkSection = this.getChunkAtBlock(x, y, z);
|
||||
return chunkSection == null ? 0 : chunkSection.getBlockAt(x & 15, y & 15, z & 15);
|
||||
}
|
||||
|
||||
getChunkAt(x, z) {
|
||||
let zArray = this.chunks[x];
|
||||
if (typeof zArray === 'undefined') {
|
||||
@@ -65,10 +103,4 @@ window.World = class {
|
||||
}
|
||||
}
|
||||
|
||||
getChunkAtBlock(x, y, z) {
|
||||
let chunk = this.getChunkAt(x >> 4, z >> 4);
|
||||
return y < 0 || y > World.TOTAL_HEIGHT ? null : chunk.getSection(y >> 4);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user