This commit is contained in:
2026-09-26 18:06:05 -03:00
parent 01a81b926e
commit e22f12c0b6
12 changed files with 215 additions and 35 deletions
+11 -4
View File
@@ -41,10 +41,17 @@ export function distance_point_point(ax: number, ay: number, az: number, bx: num
export function register_block_item(block: BlockRegistry) {
// cubes are drawn from the block's textures, anything else as a sprite
const texture_id = block_item_texture(block) ?? cube_face_texture(block, "side");
EverythingRegistry.register<ItemRegistry>("items", block.id, {
texture_id,
block_id: block.id,
});
const item: ItemRegistry = { texture_id, block_id: block.id };
if (block.name !== undefined) item.name = block.name;
EverythingRegistry.register<ItemRegistry>("items", block.id, item);
}
// what players see an item called: its name, or one made from its id, so bworld:iron_ingot is "Iron Ingot"
export function display_name(item_id: string): string {
const name = EverythingRegistry.get<ItemRegistry>("items", item_id)?.name;
if (name) return name;
const words = (item_id.split(":")[1] ?? item_id).split("_").filter((word) => word.length > 0);
return words.map((word) => word[0].toUpperCase() + word.slice(1)).join(" ");
}
export function get_state_value(value: number, block_info: BlockRegistry, name: string) {