Example #1
0
def pack_palette(palette: BlockManager) -> amulet_nbt.TAG_List:
    block_palette_nbt = amulet_nbt.TAG_List()
    extra_blocks = set()

    for block in palette.blocks():
        if len(block.extra_blocks) > 0:
            extra_blocks.update(block.extra_blocks)

    extra_blocks = list(extra_blocks)

    palette_len = len(palette)
    for block_entry in palette.blocks():
        block_palette_nbt.append(
            generate_block_entry(block_entry, palette_len, extra_blocks))

    for extra_block in extra_blocks:
        block_palette_nbt.append(
            generate_block_entry(extra_block, palette_len, extra_blocks))
    return block_palette_nbt
Example #2
0
def gen_paste_blocks(
    block_palette: BlockManager, skip_blocks: Tuple[Block, ...]
) -> numpy.ndarray:
    """Create a numpy array of all the blocks which should be pasted.

    :param block_palette: The block palette of the chunk.
    :param skip_blocks: Blocks to not copy if they match exactly.
    :return:
    """
    return numpy.vectorize(lambda b: b not in skip_blocks)(block_palette.blocks())