implement player spawning, movement, animation, metadata and destroying, implement NBT serialization, version 1.1.7
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user