streaming assets

This commit is contained in:
David Allemang
2026-07-06 14:02:29 -04:00
parent 7f946723ce
commit 0a32b46e93
6 changed files with 160 additions and 56 deletions

View File

@@ -123,6 +123,33 @@ export class World {
if (!capturedInitialState) captureInitial();
}
getUniqueBlockStates() {
const unique = new Map();
const add = (block) => {
if (!block || !block.id || block.id === 'air' || block.id === 'minecraft:air') return;
// Create a stable hash for the state object so we don't duplicate requests
const stateHash = Object.entries(block.state)
.sort((a, b) => a[0].localeCompare(b[0]))
.map(e => `${e[0]}=${e[1]}`)
.join(',');
const hash = `${block.id}[${stateHash}]`;
if (!unique.has(hash)) {
unique.set(hash, {id: block.id, state: {...block.state}});
}
};
for (const block of this.initialState.values()) add(block);
for (const ev of this.events) {
for (const action of ev.actions) {
add(action.prev);
add(action.next);
}
}
return Array.from(unique.values());
}
}
export class WorldFrame {