implement block placing and destroying

This commit is contained in:
LabyStudio
2022-02-01 00:57:25 +01:00
parent 02c36a79ba
commit 4d93f2aeeb
13 changed files with 434 additions and 83 deletions
@@ -58,8 +58,8 @@ window.WorldRenderer = class {
let player = this.minecraft.player;
// Rotation
this.camera.rotation.y = player.yaw * (Math.PI / 180);
this.camera.rotation.x = player.pitch * (Math.PI / 180);
this.camera.rotation.y = -player.yaw * (Math.PI / 180) + Math.PI;
this.camera.rotation.x = -player.pitch * (Math.PI / 180);
// Position
let x = player.prevX + (player.x - player.prevX) * partialTicks;
@@ -90,21 +90,14 @@ window.WorldRenderer = class {
renderChunks(renderer, partialTicks) {
let world = this.minecraft.world;
const xKeys = Object.keys(world.chunks)
for (let x = 0; x < xKeys.length; x++) {
for(let i in world.chunks) {
let chunk = world.chunks[i];
let zArray = world.chunks[xKeys[x]];
const zKeys = Object.keys(zArray)
for (let y = 0; y < chunk.sections.length; y++) {
let section = chunk.sections[y];
for (let z = 0; z < zKeys.length; z++) {
let chunk = zArray[zKeys[z]];
for (let y = 0; y < chunk.sections.length; y++) {
let section = chunk.sections[y];
if (section.dirty) {
section.rebuild(renderer);
}
if (section.dirty) {
section.rebuild(renderer);
}
}
}