streaming assets
This commit is contained in:
27
world.js
27
world.js
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user