Neighbor Updates as a Queue
This commit is contained in:
@@ -46,7 +46,7 @@ function client_of(t: Game) {
|
||||
const at = (x: number, y: number, z: number) => copy.get(`${x} ${y} ${z}`);
|
||||
const info = (id: string) => EverythingRegistry.get<BlockRegistry>("blocks", id);
|
||||
|
||||
const rules = new BlockRules((_mod, _what, fn) => fn());
|
||||
const rules = new BlockRules((_mod, _what, fn) => fn(), (x, y, z) => at(x, y, z)?.[0]);
|
||||
const world: SharedWorld = {
|
||||
get_block: (x, y, z) => at(x, y, z)?.[0],
|
||||
get_state(x, y, z, name) {
|
||||
@@ -61,7 +61,7 @@ function client_of(t: Game) {
|
||||
const changed = set_state_value(state << 16, block, name, value)! >>> 16;
|
||||
if (changed !== state) {
|
||||
copy.set(`${x} ${y} ${z}`, [id, changed]);
|
||||
rules.notify_neighbors(world.get_block, x, y, z);
|
||||
rules.notify_neighbors(x, y, z);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -90,7 +90,7 @@ function client_of(t: Game) {
|
||||
place(id: string, x: number, y: number, z: number, yaw: number, face: Face, hit: [number, number, number]) {
|
||||
const value = rules.placement_value(info(id)!, yaw, 0, { x, y, z, face, hit, sneaking: false });
|
||||
copy.set(`${x} ${y} ${z}`, [id, value! >>> 16]);
|
||||
rules.notify_neighbors(world.get_block, x, y, z);
|
||||
rules.notify_neighbors(x, y, z);
|
||||
},
|
||||
// what game_mode does when this client right clicks face of x y z, at hit. whether the rules did something
|
||||
interact(x: number, y: number, z: number, yaw: number, face: Face, hit: [number, number, number]) {
|
||||
@@ -98,7 +98,7 @@ function client_of(t: Game) {
|
||||
},
|
||||
break(x: number, y: number, z: number) {
|
||||
copy.set(`${x} ${y} ${z}`, [AIR_ID, 0]);
|
||||
rules.notify_neighbors(world.get_block, x, y, z);
|
||||
rules.notify_neighbors(x, y, z);
|
||||
},
|
||||
blocks: () => blocks_in((x, y, z) => at(x, y, z)!),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user