Loot tables
This commit is contained in:
@@ -86,6 +86,13 @@ export function get_state_value(value: number, block_info: BlockRegistry, name:
|
||||
return (state_bits & s.mask) >>> s.shift;
|
||||
}
|
||||
|
||||
// every state of a block value by name, like { age: 7 }
|
||||
export function block_states(value: number, block_info: BlockRegistry): Record<string, number> {
|
||||
return Object.fromEntries(
|
||||
(block_info.states ?? []).map((s) => [s.name, get_state_value(value, block_info, s.name)!]),
|
||||
);
|
||||
}
|
||||
|
||||
export function set_state_value(value: number, block_info: BlockRegistry, name: string, new_value: number) {
|
||||
if (!block_info.states) {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user