implement player spawning, movement, animation, metadata and destroying, implement NBT serialization, version 1.1.7

This commit is contained in:
LabyStudio
2022-06-20 03:16:20 +02:00
parent 4ac61adbb5
commit 19a131bd94
44 changed files with 1481 additions and 138 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ export default class Chunk {
while (y > 0) {
let typeId = this.getBlockAt(x, y - 1, z);
let block = Block.getById(typeId);
let opacity = typeId === 0 ? 0 : block.getOpacity();
let opacity = typeId === 0 || block === null ? 0 : block.getOpacity();
if (opacity !== 0) {
break;
+15 -2
View File
@@ -43,6 +43,11 @@ export default class World {
}
onTick() {
// Tick entities
for (let i = 0; i < this.entities.length; i++) {
this.entities[i].onUpdate();
}
// Update skylight subtracted (To make the night dark)
let lightLevel = this.calculateSkylightSubtracted(1.0);
if (lightLevel !== this.skylightSubtracted) {
@@ -566,8 +571,10 @@ export default class World {
removeEntityById(id) {
let entity = this.getEntityById(id);
this.entities.remove(entity);
this.group.remove(entity.renderer.group);
if (entity !== null) {
this.entities.splice(this.entities.indexOf(entity), 1);
this.group.remove(entity.renderer.group);
}
}
getEntityById(id) {
@@ -602,4 +609,10 @@ export default class World {
return this.chunkProvider;
}
clearEntities() {
for (let entity of this.entities) {
this.removeEntityById(entity.id);
}
}
}