Skip to content

Commit

Permalink
add entities to chunk column
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqtoday committed Jul 15, 2024
1 parent 2dc9a9d commit 4f2b3b3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/pc/common/CommonChunkColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CommonChunkColumn {
this.registry = registry
// Just a collection of deserialized NBTs
this.blockEntities = {}
this.entities = {}
this.minY = 0
}

Expand Down Expand Up @@ -66,6 +67,26 @@ class CommonChunkColumn {
this.setBlockEntity({ x: entity.x.value >> 4, y: entity.y.value, z: entity.z.value >> 4 }, entity)
}
}

// Entities

getEntity (id) {
return this.entities[id]
}

setEntity (id, entity) {
this.entities[id] = entity
}

removeEntity (id) {
delete this.entities[id]
}

loadEntities (entities) {
for (const id in entities) {
this.addEntity(id, entities[id])
}
}
}

module.exports = CommonChunkColumn

0 comments on commit 4f2b3b3

Please sign in to comment.