🧱 方块(Block)#

#bs.block:help

管理方块,包括状态和NBT,同时提供无缝转换的高级工具。

“建筑是深思熟虑的空间创造。”

—路易斯·康(Louis Kahn)

虚拟方块格式

To manipulate blocks and their states, Bookshelf utilizes a virtual block format stored in the block output. It’s crucial not to update the virtual block format manually; instead, utilize the helper functions provided in the library.


🔧 函数#

你可以在下方找到此模块中的所有可用函数。


Emit Particle#

#bs.block:emit_block_particle

Emit block particle of a given block.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

命令存储 bs:in block.emit_block_particle

  • Particle data

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • properties: Block properties (e.g. {facing:"east"}).

      Only considered if type is present.

    • pos: X Y Z coordinates, the position at which to create particle (default: ~ ~ ~).

    • delta: X Y Z values, the random spread in blocks (default: 0 0 0).

    • speed: 粒子的速度(默认:1)。

    • count: Number of particles to spawn (default: 1).

    • mode: 显示模式:normalforce(默认:normal)。

    • viewers: 控制哪些玩家能看到这些粒子(默认:@a)。

输出:

状态:粒子被发射。

Example: Emit the particle of the block below your feet:

# Setup the input
data modify storage bs:in block.emit_block_particle set value { pos: "~ ~.5 ~", speed: 5, count: 30 }

# Emit the block particle (block below your feet)
execute positioned ~ ~-.5 ~ run function #bs.block:emit_block_particle

Example: Emit the particle of the block at position 0 0 0:

# Get block data
execute positioned 0 0 0 run function #bs.block:get_type

# Setup the input with the retrieved block data
data modify storage bs:in block.emit_block_particle set from storage bs:out block
data modify storage bs:in block.emit_block_particle merge value { speed: 5, count: 30 }

# Emit the block particle
function #bs.block:emit_block_particle

制作人员:Aksiome、theogiraudet


Fill Block#

#bs.block:fill_block

用指定方块填充部分或全部区域。

输入:

命令存储 bs:in block.fill_block

  • Fill data

    • block: 要填充的方块。

    • from: Starting position as a valid position string.

    • to: Ending position as a valid position string.

    • mode: Mode used to set blocks [outline|hollow|destroy|keep|replace|strict] (default: replace).

    • filter: Block used as a filter (default: none).

输出:

状态:方块被放置在世界中。

Example: Fill an area with stone:

# Setup the input
data modify storage bs:in block.fill_block set value {block:"minecraft:stone",from:"~-3 ~-3 ~-3",to:"~3 ~3 ~3"}

# Run the fill
function #bs.block:fill_block
#bs.block:fill_type

对部分或全部区域更改方块类型,同时保留方块状态和NBT。

输入:

命令存储 bs:in block.fill_type

  • Fill data

    • type: 要填充的方块的id。

    • from: Starting position as a valid position string.

    • to: Ending position as a valid position string.

    • mode: Mode used to set blocks [outline|hollow|destroy|keep|replace|strict] (default: replace).

    • filter: Block used as a filter (default: none).

输出:

状态:方块被放置在世界中。

示例:将橡木楼梯替换为云杉木楼梯并保留方块状态,完成时使用say命令:

# Setup the input
data modify storage bs:in block.fill_type set value {type:"minecraft:spruce_stairs",from:"~-3 ~-3 ~-3",to:"~3 ~3 ~3",filter:"minecraft:oak_stairs"}

# Run the process
function #bs.block:fill_type

制作人员:Aksiome


Get Block#

#bs.block:get_block

获取当前位置方块的所有相关数据,包括其状态和NBT。

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • group: 在同一个组的方块共享相同的可能的方块状态(比如:所有的楼梯)。

    • block: 方块的完整字符串表示方块id[方块状态]{nbt}

    • item: 方块对应的物品名字符串,可能不存在。

    • type: 方块id的字符串表示(比如:minecraft:stone)。

    • state: 方块状态的完整字符串表示(比如:[shape=straight]),可能不存在。

    • nbt: 方块数据的完整字符串表示,可能不存在。

    • properties: 方块状态的数据表示(用于下落的方块之类的实体),可能不存在。

Example: Get block data of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_block

# See the result
data get storage bs:out block
#bs.block:get_type

获取当前位置的方块类型。虽然此函数输出的状态、NBT和属性为空,但这不影响管理方块状态的函数的运行。

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • group: 在同一个组的方块共享相同的可能的方块状态(比如:所有的楼梯)。

    • block: 方块的完整字符串表示(仅方块类型)。

    • item: 方块对应的物品名字符串,可能不存在。

    • type: 方块id的字符串表示(比如:minecraft:stone)。

Example: Get type data of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_type

# See the result
data get storage bs:out block

只读输出

bs:out block 输出是只读的。手动修改部分内容可能导致潜在漏洞。因此,模块提供了许多可以修改输出的函数来保证它的完整性。

制作人员:Aksiome、theogiraudet


Get Extras#

#bs.block:get_blast_resistance

Get the blast resistance value of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • blast_resistance: The blast resistance of the block at the position.

What is Blast Resistance?

Blast resistance is a numeric value used by Minecraft to determine how well a block resists explosions. Higher values mean the block is harder to destroy by TNT, creepers, or other explosions.

Example: Get the blast resistance of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_blast_resistance

# See the result
data get storage bs:out block
#bs.block:get_friction

Get the friction value of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • friction: The friction of the block at the position.

What is Friction?

Friction is a numeric value used by Minecraft to determine how slippery a block is. For example, normal blocks like stone have a friction of 0.6, while ice has a higher friction of 0.98.

Example: Get the friction of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_friction

# See the result
data get storage bs:out block
#bs.block:get_hardness

Get the hardness value of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • hardness: The hardness of the block at the position.

What is Hardness?

Hardness is a numeric value used by Minecraft to determine how long it takes to break a block with a tool. For example, stone has a higher hardness than dirt, and obsidian has one of the highest hardness values in the game.

Example: Get the hardness of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_hardness

# See the result
data get storage bs:out block
#bs.block:get_instrument

Get the note block instrument of the block at the current location (e.g., harp, bass, snare).

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • instrument: The instrument of the block at the position.

Example: Get the instrument of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_instrument

# See the result
data get storage bs:out block
#bs.block:get_jump_factor

Get the jump factor value of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • jump_factor: The jump factor of the block at the position.

Example: Get the jump factor of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_jump_factor

# See the result
data get storage bs:out block
#bs.block:get_luminance

Get the luminance value of the block at the current location. The luminance can depend on block properties. For example, a light block may have different luminance values depending on its level.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • luminance: The luminance of the block at the position.

Example: Get the luminance of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_luminance

# See the result
data get storage bs:out block
#bs.block:get_sounds

Get the sounds of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • sounds: The sounds of the block.

      • break: 玩家破坏方块时的声音。

      • fall: 玩家掉在方块上时的声音。

      • hit: 玩家敲击方块时的声音。

      • place: 玩家放置方块时的声音。

      • step: 玩家在方块上走路时的声音。

Example: Get the sounds of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_sounds

# See the result
data get storage bs:out block
#bs.block:get_speed_factor

Get the speed factor value of the block at the current location.

输入:

执行 at <实体>positioned <x> <y> <z>:获取方块数据的位置。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • speed_factor: The speed factor of the block at the position.

Example: Get the speed factor of the block below your feet:

# Run the get function on a block
execute positioned ~ ~-.5 ~ run function #bs.block:get_speed_factor

# See the result
data get storage bs:out block

小技巧

These functions merge their results into bs:out block rather than replacing it. This means previously retrieved block data (for example, from #bs.block:get_block) remains intact.

制作人员:Aksiome


Is Touching Power#

#bs.block:is_touching_power

Determine whether the current position is touching a powered block or is powered by a redstone component.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the block to check.

输出:

Return: Success or failure.

#bs.block:is_touching_strong_power

Determine whether the current position is touching a strongly powered block or is powered by a redstone component.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the block to check.

输出:

Return: Success or failure.

#bs.block:is_touching_weak_power

Determine whether the current position is touching a weakly powered block.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the block to check.

输出:

Return: Success or failure.

Example: Check whether the current location should activate a redstone mechanism:

execute if function #bs.block:is_touching_power run say ACTIVATE

Unsupported Redstone Components

The trapped_chest block is not supported by these functions. They rely on block states to determine power, and trapped_chest blocks do not update their block state when opened.

制作人员:Aksiome


Lookup Block#

#bs.block:lookup_type {type:<value>}

Get block data from the given type string id. The output is equivalent to #bs.block:get_type, but also includes all additional attributes that are not dependent on block state.

输入:

函数宏

  • 参数

    • type: 方块对应的方块类型的字符串id。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • group: 在同一个组的方块共享相同的可能的方块状态(比如:所有的楼梯)。

    • block: 方块的完整字符串表示(仅方块类型)。

    • item: 方块对应的物品名字符串,可能不存在。

    • type: 方块id的字符串表示(比如:minecraft:stone)。

    • can_occlude: Whether the block occludes neighboring faces.

    • ignited_by_lava: Whether the block can catch fire when exposed to lava.

    • blast_resistance: The blast resistance of the block at the position.

    • friction: The friction of the block at the position.

    • hardness: The hardness of the block at the position.

    • jump_factor: The jump factor of the block at the position.

    • speed_factor: The speed factor of the block at the position.

    • instrument: The instrument of the block at the position.

    • sounds: The sounds of the block.

      • break: 玩家破坏方块时的声音。

      • hit: 玩家敲击方块时的声音。

      • fall: 玩家掉在方块上时的声音。

      • place: 玩家放置方块时的声音。

      • step: 玩家在方块上走路时的声音。

示例:获取石头类型的方块数据:

# Get block type data
function #bs.block:lookup_type {type:"minecraft:stone"}

# See the result
data get storage bs:out block.block
#bs.block:lookup_item {item:<value>}

重要

Minecraft在方块和物品之间的映射并不完美。某些物品可能对应多个方块,此函数只会返回其中之一。

Get block data from the given item string id. The output is equivalent to #bs.block:get_type, but also includes all additional attributes that are not dependent on block state.

输入:

函数宏

  • 参数

    • item: 方块对应的物品的字符串id。

输出:

命令存储 bs:out block

  • [只读] 方块数据

    • group: 在同一个组的方块共享相同的可能的方块状态(比如:所有的楼梯)。

    • block: 方块的完整字符串表示(仅方块类型)。

    • item: 方块对应的物品名字符串,可能不存在。

    • type: 方块id的字符串表示(比如:minecraft:stone)。

    • can_occlude: Whether the block occludes neighboring faces.

    • ignited_by_lava: Whether the block can catch fire when exposed to lava.

    • blast_resistance: The blast resistance of the block at the position.

    • friction: The friction of the block at the position.

    • hardness: The hardness of the block at the position.

    • jump_factor: The jump factor of the block at the position.

    • speed_factor: The speed factor of the block at the position.

    • instrument: The instrument of the block at the position.

    • sounds: The sounds of the block.

      • break: 玩家破坏方块时的声音。

      • hit: 玩家敲击方块时的声音。

      • fall: 玩家掉在方块上时的声音。

      • place: 玩家放置方块时的声音。

      • step: 玩家在方块上走路时的声音。

示例:获取石头物品的方块数据:

# Get block type data
function #bs.block:lookup_item {item:"minecraft:stone"}

# See the result
data get storage bs:out block.block

只读输出

bs:out block 输出是只读的。手动修改部分内容可能导致潜在漏洞。因此,模块提供了许多可以修改输出的函数来保证它的完整性。

制作人员:Aksiome


管理方块状态#

#bs.block:keep_properties {properties:[]}

Filter properties to keep only the desired ones. This function acts on the virtual block format stored in the block output.

输入:

函数宏

  • 参数

    • properties: 要保留的方块状态列表。

      • 方块属性数据

        • name: 方块属性名称(比如:shape)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:仅保留朝向和形状的方块状态:

# Once (on stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Run the transformation
function #bs.block:keep_properties {properties:[{name:"facing"},{name:"shape"}]}

# See the result
data get storage bs:out block.block
#bs.block:merge_properties {properties:[]}

Merge state properties from the current location into the output. The merge occurs if the syntax is correct, regardless of logical coherence (e.g., using ‘age’ for different plants). This function acts on the virtual block format stored in the block output.

输入:

执行 at <实体>positioned <x> <y> <z>:作为输入的方块位置。

函数宏

  • 参数

    • properties: 要合并的方块状态列表。

      • 方块属性数据

        • name: 方块属性名称(比如:shape)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:将某个方块的朝向合并更新到楼梯上:

# Once (on stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Run the transformation (on a block with facing)
execute positioned ~ ~ ~ run function #bs.block:merge_properties {properties:[{name:"facing"}]}

# See the result
data get storage bs:out block.block
#bs.block:remove_properties {properties:[]}

Filter properties by removing the undesired ones. This function acts on the virtual block format stored in the block output.

输入:

函数宏

  • 参数

    • properties: 要移除的方块状态列表。

      • 方块属性数据

        • name: 方块属性名称(比如:shape)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:移除朝向和形状属性:

# Once (on stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Run the transformation
function #bs.block:remove_properties {properties:[{name:"facing"},{name:"shape"}]}

# See the result
data get storage bs:out block.block
#bs.block:replace_properties {properties:[]}

Replace property values. Invalid values will not be replaced. This function acts on the virtual block format stored in the block output.

输入:

函数宏

  • 参数

    • properties: 要替换的方块状态列表。

      • 方块属性数据

        • name: 方块属性名称(比如:shape)。

        • value: 方块属性值(比如:east)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:替换朝向方块状态:

# Once (on stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Run the transformation
function #bs.block:replace_properties {properties:[{name:"facing",value:"east"}]}

# See the result
data get storage bs:out block.block
#bs.block:shift_properties {properties:[]}

Shift properties by any amount, allowing cycling through their values. This function acts on the virtual block format stored in the block output.

输入:

函数宏

  • 参数

    • properties: 要偏移的方块状态列表。

      • 方块属性数据

        • name: 方块属性名称(比如:shape)。

        • by: 偏移数量(默认为1)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:将朝向属性值偏移2:

# Once (on stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Run the transformation
function #bs.block:shift_properties {properties:[{name:"facing",by:2}]}

# See the result
data get storage bs:out block.block

制作人员:Aksiome


管理方块类型#

#bs.block:replace_type {type:<value>}

Replace the block type while trying to conserve the state. State is preserved only if the group of the output matches the input. This function acts on the virtual block format stored in the block output.

输入:

函数宏

  • 参数

    • type: 方块id的字符串表示(比如:minecraft:stone)。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

返回值:是否找到了方块类型并进行了替换。

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:将橡木楼梯替换为云杉木楼梯,并保留当前状态:

# Once (on oak_stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Replace type data
function #bs.block:replace_type {type:"minecraft:spruce_stairs"}

# See the result
data get storage bs:out block.block
#bs.block:map_type {type:<value>,mapping_registry:<value>}

根据预定义的映射规则,将方块输出的属性(attr)替换为输入方块的属性(attr),生成新的方块类型。注册表定义如下:

data modify storage bs:const block.mapping_registry.bs.colors set value [ \
  { set: "wool", attrs: ["red"], type: "minecraft:red_wool" }, \
  { set: "wool", attrs: ["green"], type: "minecraft:green_wool" }, \
  { set: "carpet", attrs: ["red"], type: "minecraft:red_carpet" }, \
  { set: "carpet", attrs: ["green"], type: "minecraft:green_carpet" }, \
]

This function operates on the virtual block format stored in the block output. It replaces the type in the output with one that belongs to the same set and better matches the attributes of the inputted type.

例如,使用上述映射注册表:如果输入是 minecraft:red_wool(attrs:[“red”]),且虚拟方块类型是 minecraft:green_carpet(set:“carpet”),则结果方块将是 minecraft:red_carpet(set:“carpet”,attrs:[“red”])。

Bookshelf 包含两个预定义的映射注册表(bs.shapesbs.colors)。如果这些不够用,你可以创建自己的

输入:

函数宏

  • 参数

    • type: 方块id的字符串表示(比如:minecraft:stone)。

    • mapping_registry: 一个映射表的nbt路径(比如:bs.shapes),用于替换。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

返回值:是否找到了方块类型并进行了替换。

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:将所有橡木相关方块替换为云杉木(该函数将橡木楼梯方块替换为云杉木楼梯方块):

# Once (on oak_stairs)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Replace type data
function #bs.block:map_type { type: "minecraft:spruce_planks", mapping_registry: "bs.shapes" }

# See the result
data get storage bs:out block.block
#bs.block:mix_type {type:<value>,mapping_registry:<value>}

实验性

由于方块关系定义存在主观性,此函数的运行结果可能不尽人意。同时,其注册表虽涵盖大量常见方块,但基于人工整理收集,无法保证全面性。

根据预定义的映射规则,将方块输出的属性和输入方块的属性混合,生成新的方块类型。注册表定义如下:

data modify storage bs:const block.mapping_registry.bs.shapes set value [ \
  { set: "cube", attrs: ["stone"], type: "minecraft:stone" }, \
  { set: "cube", attrs: ["brick"], type: "minecraft:bricks" }, \
  { set: "cube", attrs: ["stone", "brick"], type: "minecraft:stone_bricks" }, \
  { set: "stairs", attrs: ["stone"], type: "minecraft:stone_stairs" }, \
  { set: "stairs", attrs: ["brick"], type: "minecraft:brick_stairs" }, \
  { set: "stairs", attrs: ["stone","brick"], type: "minecraft:stone_brick_stairs" }, \
]

This function operates on the virtual block format stored in the block output. It replaces the type in the output with one that belongs to the same set and better matches the attributes of both the output and input types while prioritizing the input type.

例如,使用上述映射注册表:如果输入是 minecraft:bricks(attrs:[“brick”]),且虚拟方块类型是 minecraft:stone_stairs(set:“stairs”,attrs:[“stone”]),则结果方块将是 minecraft:stone_brick_stairs(set:“stairs”,attrs:[“stone”,“brick”])。

Bookshelf 包含两个预定义的映射注册表(bs.shapesbs.colors)。如果这些不够用,你可以创建自己的

输入:

函数宏

  • 参数

    • type: 方块id的字符串表示(比如:minecraft:stone)。

    • mapping_registry: 一个映射表的nbt路径(比如:bs.shapes),用于替换。

Storage bs:out block: There’s no need for manual specification; rather, employ the relevant functions, such as get_block.

输出:

返回值:是否找到了方块类型并进行了替换。

命令存储 bs:out block blockstateproperties 会在运行后同步更新。

示例:将苔石方块与砖块混合,得到苔石砖:

# Once (on mossy_cobblestone)
execute positioned ~ ~ ~ run function #bs.block:get_block

# Replace type data
function #bs.block:mix_type { type: "minecraft:bricks", mapping_registry: "bs.shapes" }

# See the result
data get storage bs:out block.block

制作人员:Aksiome


匹配#

#bs.block:match

检查当前位置是否和给定方块匹配。

输入:

执行 at <实体>positioned <x> <y> <z>:要检查的方块位置。

命令存储 bs:in block.match.block 要检查的方块的完整字符串表示。

输出:

返回值:检查是否成功或失败(1或0)。

示例:检查0 0 0处的方块是否匹配0 1 0处的方块:

# Get block data at 0 0 0
execute positioned 0 0 0 run function #bs.block:get_block

# Setup the input
data modify storage bs:in block.match.block set from storage bs:out block.block

# Run a command if it's a match
execute positioned 0 1 0 if function #bs.block:match run say It's a match

制作人员:Aksiome、theogiraudet


Play Sound#

#bs.block:play_break_sound

Play the block’s break sound.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

Storage bs:in block.play_break_sound:

  • 方块声音数据

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • source: 声音来源:mastermusicrecordweatherblockhostileneutralplayerambientvoice(默认:master)。

    • targets: The entities who will hear the sound (default: @s).

    • pos: X Y Z coordinates of the sound’s position (default: ~ ~ ~).

    • pitch: Pitch of the sound (default: 1.0).

    • volume: Volume of the sound (default: 1.0).

    • min_volume: Minimum volume of the sound (default: 0.0).

输出:

状态:音效被播放。

#bs.block:play_fall_sound

Play the block’s fall sound.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

Storage bs:in block.play_fall_sound:

  • 方块声音数据

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • source: 声音来源:mastermusicrecordweatherblockhostileneutralplayerambientvoice(默认:master)。

    • targets: The entities who will hear the sound (default: @s).

    • pos: X Y Z coordinates of the sound’s position (default: ~ ~ ~).

    • pitch: Pitch of the sound (default: 1.0).

    • volume: Volume of the sound (default: 1.0).

    • min_volume: Minimum volume of the sound (default: 0.0).

输出:

状态:音效被播放。

#bs.block:play_hit_sound

Play the block’s hit sound.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

Storage bs:in block.play_hit_sound:

  • 方块声音数据

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • source: 声音来源:mastermusicrecordweatherblockhostileneutralplayerambientvoice(默认:master)。

    • targets: The entities who will hear the sound (default: @s).

    • pos: X Y Z coordinates of the sound’s position (default: ~ ~ ~).

    • pitch: Pitch of the sound (default: 1.0).

    • volume: Volume of the sound (default: 1.0).

    • min_volume: Minimum volume of the sound (default: 0.0).

输出:

状态:音效被播放。

#bs.block:play_place_sound

Play the block’s place sound.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

Storage bs:in block.play_place_sound:

  • 方块声音数据

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • source: 声音来源:mastermusicrecordweatherblockhostileneutralplayerambientvoice(默认:master)。

    • targets: The entities who will hear the sound (default: @s).

    • pos: X Y Z coordinates of the sound’s position (default: ~ ~ ~).

    • pitch: Pitch of the sound (default: 1.0).

    • volume: Volume of the sound (default: 1.0).

    • min_volume: Minimum volume of the sound (default: 0.0).

输出:

状态:音效被播放。

#bs.block:play_step_sound

Play the block’s step sound.

输入:

Execution at <entity> or positioned <x> <y> <z>: Position of the default type and reference for pos.

Storage bs:in block.play_step_sound:

  • 方块声音数据

    • type: Block type (e.g. minecraft:stone).

      If omitted, the block type at the current execution position will be used.

    • source: 声音来源:mastermusicrecordweatherblockhostileneutralplayerambientvoice(默认:master)。

    • targets: The entities who will hear the sound (default: @s).

    • pos: X Y Z coordinates of the sound’s position (default: ~ ~ ~).

    • pitch: Pitch of the sound (default: 1.0).

    • volume: Volume of the sound (default: 1.0).

    • min_volume: Minimum volume of the sound (default: 0.0).

输出:

状态:音效被播放。

Example: Play the step sound of the block below your feet:

# Setup the input
data modify storage bs:in block.play_step_sound set value { source: "block", pos: "~ ~.5 ~" }

# Play the block sound (block below your feet)
execute positioned ~ ~-.5 ~ run function #bs.block:play_step_sound

Example: Play the break sound of the block at position 0 0 0:

# Get block data
execute positioned 0 0 0 run function #bs.block:get_type

# Setup the input with the retrieved block data
data modify storage bs:in block.play_break_sound set value { source: "block" }
data modify storage bs:in block.play_break_sound.type set from storage bs:out block.type

# Play the block sound
function #bs.block:play_break_sound

制作人员:Aksiome、theogiraudet


Set Block#

#bs.block:set_block

在当前位置放置方块。

输入:

执行 at <实体>positioned <x> <y> <z>:要放置方块的位置。

命令存储 bs:in block.set_block

  • 放置方块数据

    • block: 要放置的方块的完整字符串表示。

    • mode: 放置方块的模式 [destroy|keep|replace|strict] (默认: replace)。

输出:

状态:方块被放置在世界中。

示例:在0 0 0处放置石头方块并破坏已有方块:

# Setup the input
data modify storage bs:in block.set_block set value {block:"minecraft:stone",mode:"destroy"}

# Run the function
execute positioned 0 0 0 run function #bs.block:set_block
#bs.block:set_type

在尝试保留方块状态和NBT的同时替换当前位置的方块类型。

输入:

执行 at <实体>positioned <x> <y> <z>:要放置方块的位置。

命令存储 bs:in block.set_type

  • 放置方块数据

    • block: 要放置的方块id的字符串表示。

    • mode: 放置方块的模式 [destroy|keep|replace|strict] (默认: replace)。

输出:

状态:方块被放置在世界中。

示例:将所有楼梯替换为橡木楼梯,并保留方块状态:

# Setup the input
data modify storage bs:in block.set_type.type set value "minecraft:oak_stairs"

# Run the function
execute positioned 0 0 0 run function #bs.block:set_type

制作人员:Aksiome、theogiraudet


Spawn Entity#

#bs.block:spawn_block_display

生成给定方块对应的方块展示实体。

输入:

执行 at <实体>positioned <x> <y> <z>:实体生成的位置。

命令存储 bs:in block.spawn_block_display

  • 方块展示实体数据

    • type: 方块类型(和方块输出(bs:out block)类似)。

    • properties: 方块属性(和方块输出(bs:out block)类似)。

    • extra_nbt: 生成实体附加的NBT数据。

输出:

状态:生成的实体。

示例:使用0 0 0处的方块生成方块展示实体:

# Get block data
execute positioned 0 0 0 run function #bs.block:get_block

# Setup the input
data modify storage bs:in block.spawn_block_display set from storage bs:out block

# Summon the block display
function #bs.block:spawn_block_display
#bs.block:spawn_falling_block

生成给定方块对应的下落的方块。

输入:

执行 at <实体>positioned <x> <y> <z>:实体生成的位置。

命令存储 bs:in block.spawn_falling_block

  • 下落的方块数据

    • type: 方块类型(和方块输出(bs:out block)类似)。

    • properties: 方块属性(和方块输出(bs:out block)类似)。

    • extra_nbt: 生成实体附加的NBT数据。

输出:

状态:生成的实体。

示例:使用0 0 0处的方块生成下落的方块:

# Get block data
execute positioned 0 0 0 run function #bs.block:get_block

# Setup the input
data modify storage bs:in block.spawn_falling_block set from storage bs:out block

# Summon the block display
function #bs.block:spawn_falling_block
#bs.block:spawn_solid_block_display

生成给定方块对应的方块展示实体,并且有和方块一样的碰撞逻辑。

输入:

执行 at <实体>positioned <x> <y> <z>:实体生成的位置。

命令存储 bs:in block.spawn_solid_block_display

  • 方块展示实体数据

    • type: 方块类型(和方块输出(bs:out block)类似)。

    • properties: 方块属性(和方块输出(bs:out block)类似)。

    • extra_nbt: 生成实体附加的NBT数据。

输出:

状态:生成的实体。

示例:使用0 0 0处的方块生成带碰撞箱的方块展示实体:

# Get block data
execute positioned 0 0 0 run function #bs.block:get_block

# Setup the input
data modify storage bs:in block.spawn_solid_block_display set from storage bs:out block

# Summon the block display
function #bs.block:spawn_solid_block_display

制作人员:Aksiome、theogiraudet


👁️ Predicates#

You can find below all predicates available in this module.


Is Conductive#

bs.block:is_conductive

Check if the block at the current location can conduct redstone. The conductivity can depend on block properties. For example, a slab block may only be conductive if it is a double slab.

制作人员:Aksiome


Is Powered#

bs.block:is_powered

Check if the block is conductive and powered by redstone.

制作人员:Aksiome


Is Spawnable#

bs.block:is_spawnable

Check if the block at the current location can serve as a valid spawn surface. This does not consider light level and may depend on block properties. For example, a slab may be spawnable only if it is not a bottom slab.

制作人员:Aksiome


Is Strongly Powered#

bs.block:is_strongly_powered

Check if the block is conductive and strongly powered by redstone.

What is Strongly Powered?

A block is strongly powered when it can power adjacent redstone dust (including redstone dust on and beneath the block), in addition to activating adjacent mechanism component, and powering redstone repeaters and redstone comparators facing away from the block.

A block becomes strongly powered by being powered by a redstone power component, a powered redstone repeater, or a powered redstone comparator.

制作人员:Aksiome


Is Weakly Powered#

bs.block:is_weakly_powered

Check if the block is conductive and weakly powered by redstone.

What is Weakly Powered?

A block that is weakly powered cannot power adjacent redstone dust, but can still activate adjacent redstone mechanisms, and power redstone repeaters and redstone comparators facing away from the block.

A block becomes weakly powered when it is powered only by redstone dust.

制作人员:Aksiome


🏷️ Tags#

You can find below below all tags available in this module.


Can Occlude#

#bs.block:can_occlude

Determine if the block occludes neighboring faces (i.e., whether it’s solid enough to hide adjacent block faces).

制作人员:Aksiome


Has State#

#bs.hitbox:has_state

Determine if the block can have state properties (e.g., facing, waterlogged).

制作人员:Aksiome


Ignited by Lava#

#bs.hitbox:ignited_by_lava

Determine if the block can catch fire when exposed to lava.

制作人员:Aksiome


🎓 自定义映射注册表#

此模块允许你创建根据特定需求定制的个性化映射注册表。


要创建新的注册表,你需要在 bs:const block.mapping_registry 命令存储中定义一个数组。每个新注册表都应该有命名空间,且每个元素必须包含 setattrstype。以下是定义新映射注册表的方法:

data modify storage bs:const block.mapping_registry.<namespace>.<name> [
  { set: "cube", attrs: ["oak"], type: "minecraft:oak_planks" }, \
  { set: "cube", attrs: ["spruce"], type: "minecraft:spruce_planks" }, \
  \
  { set: "stairs", attrs: ["oak"], type: "minecraft:oak_stairs" }, \
  { set: "stairs", attrs: ["spruce"], type: "minecraft:spruce_stairs" }, \
  \
  { set: "slab", attrs: ["oak"], type: "minecraft:oak_slab" }, \
  { set: "slab", attrs: ["spruce"], type: "minecraft:spruce_slab" }, \
]

💬 这对你有帮助吗?

欢迎在下方留下你的问题和反馈!