Skip to content

Function: get block count

theblackswitch edited this page May 15, 2026 · 3 revisions

#mtb-generated:<namespace>/<multiblock_id>/get_block_count {block:<block_id>}

This function gets the number of correctly placed blocks in the multiblock for a specifc block ID.

Context:

This function needs to run as the root of the multiblock instance you want inspect.

Note

You can use the selector @e[type=minecraft:block_display,tag=<namespace>-<multiblock_id>,tag=mtb.root] to find the root

Arguments:

block_id: string | The id of the block you want to track (For example: minecraft:stone)

Return:

block count: The amount of blocks of the type specified, that are actually placed down correctly.

Example:

# Generate a checklist for the multiblock (run as the multiblock root)
# This example does it for stone only

execute store result score #block_count temp run function #mtb-generated:tech_datapack/industrial_furnace/get_block_count {block:"minecraft:stone"}
execute store result score #remaining temp run function #mtb-generated:tech_datapack/industrial_furnace/get_remaining_block_count {block:"minecraft:stone"}

scoreboard players operation #total temp = #block_count temp
scoreboard players operation #total temp += #remaining temp

title @a[distance=..20] actionbar [{text:"Remaining: ",color:"gold"},{object:"atlas",sprite:"minecraft:block/stone"},{text:" minecraft:stone ",color:green"},{objective:"temp",name:"#remaining",color:"red"},{text:"/", color:"gray"},{objective:"temp",name:"#total",color:"gray"}]

Clone this wiki locally