working blockstates
This commit is contained in:
23
world.js
Normal file
23
world.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// world.js
|
||||
export class World {
|
||||
constructor() {
|
||||
this.blocks = new Map(); // Keyed by "x,y,z"
|
||||
}
|
||||
|
||||
setBlock(id, x, y, z, props = {}) {
|
||||
const key = `${x},${y},${z}`;
|
||||
this.blocks.set(key, { id, x, y, z, props });
|
||||
}
|
||||
|
||||
updateBlock(x, y, z, newProps) {
|
||||
const key = `${x},${y},${z}`;
|
||||
const block = this.blocks.get(key);
|
||||
if (block) {
|
||||
block.props = { ...block.props, ...newProps };
|
||||
}
|
||||
}
|
||||
|
||||
getBlock(x, y, z) {
|
||||
return this.blocks.get(`${x},${y},${z}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user