def create_block(*block_id): """(Block) Creates a block (this function can be thought of as a block factory) Parameters: block_id (*tuple): N-length tuple to uniquely identify the block, often comprised of strings, but not necessarily (arguments are grouped into a single tuple) Examples: >>> create_block("leaf") LeafBlock() >>> create_block("stone") ResourceBlock('stone') >>> create_block("mayhem", 1) TrickCandleFlameBlock(1) """ if len(block_id) == 1: block_id = block_id[0] if block_id == "leaf": return LeafBlock() elif block_id == 'crafting_table': return CraftingTableBlock(block_id, BREAK_TABLES["wood"]) elif block_id == 'furnace': return FurnaceBlock(block_id, BREAK_TABLES["stone"]) elif block_id in BREAK_TABLES: return ResourceBlock(block_id, BREAK_TABLES[block_id]) elif block_id in EXTRA_BREAK_TABLES: return ResourceBlock(block_id, EXTRA_BREAK_TABLES[block_id]) elif block_id[0] == 'mayhem': return TrickCandleFlameBlock(block_id[1]) raise KeyError(f"No block defined for {block_id}")
def create_block(*block_ids): if len(block_ids) == 1: block_id = block_ids[0] if block_id == "leaf": return LeafBlock() elif block_id in BREAK_TABLES: return ResourceBlock(block_id, BREAK_TABLES[block_id]) # ~< remove from template elif block_id == "crafting_table": return CraftingTableBlock() # ~> elif block_ids[0] == 'mayhem': return TrickCandleFlameBlock(block_ids[1]) raise KeyError(f"No block defined for {block_ids}")