Compatibility
Minecraft: Java Edition
Platforms
Links
Details
[RB]方块替换 (ReplaceBlock)
The English description is below.
简介
此数据包提供了一个强大的 API,可以以完全原版的方式在世界生成后高性能地替换世界中的方块。
功能
此数据包以区块为单位遍历并替换方块,每次调用会从目标实体所在区块向远处遍历,直到成功清除一个区块,或者遍历完加载范围内所有区块。遍历范围可以进行配置,见下文。
调用
要调用 API,请先在您命令存储的 {}.replace_block 中存储 API 配置,可调用 replace_block:api/reset_settings 函数并传入 {storage:"您命令存储的命名空间 ID"} 生成示例配置,然后调用 replace_block:api/execute 函数并传入 {storage:"您命令存储的命名空间 ID"}。方块替换将立即开始,并在同一 tick 内结束。目前 ReplaceBlock 并没有对配置内容的验证机制,因此请务必确认您的配置包含所有要求的数据,否则可能导致 ReplaceBlock 出现严重错误。
配置
以下为完整的配置列表,另可查看 reset_settings.mcfunction 中的示例。
- 目标选择器:
- 路径:
{}.replace_block.selector - 内容:一个目标选择器,可包含参数。
- 示例:
"@e[type=player]"
- 路径:
- 替换范围:
- 路径:
{}.replace_block.search_range - 内容:遍历距离,为 1 即以玩家为中心的 9 个区块。
- 示例:
3
- 路径:
- 成功数量:
- 路径:
{}.replace_block.success_threshold - 内容:一次区块替换视为成功所需的方块替换数量,如果某区块所有方块对成功替换的方块数量总和未达到此数值,则继续遍历下一区块。
- 示例:
50
- 路径:
- 要替换的方块对列表:
- target_block
- 路径:
{}.replace_block.replace_pairs[].target_block - 内容:将被替换方块的命名空间 ID
- 示例:
"stone"
- 路径:
- replace_with
- 路径:
{}.replace_block.replace_pairs[].replace_with - 内容:新方块的命名空间 ID
- 示例:
"air"
- 路径:
- target_block
- 替换生效维度列表:
- dimension
- 路径:
{}.replace_block.dimensions[].dimension - 内容:替换生效维度的命名空间 ID
- 示例:
"minecraft:overworld"
- 路径:
- min_y
- 路径:
{}.replace_block.dimensions[].min_y - 内容:替换生效的最小高度
- 示例:
-64
- 路径:
- max_y
- 路径:
{}.replace_block.dimensions[].max_y - 内容:替换生效的最大高度
- 示例:
319
- 路径:
- dimension
Introduction
This datapack provides a powerful API that can replace blocks in the world with high performance in a completely vanilla way after world generation.
Features
This datapack traverses and replaces blocks chunk by chunk. Each call will traverse from the target entity's current chunk outward until successfully clearing one chunk or traversing all chunks within the loaded range. The traversal range can be configured as described below.
Usage
To use the API, first store the API configuration in your command storage at {}.replace_block. You can call the replace_block:api/reset_settings function with {storage:"your command storage namespace ID"} to generate example configuration, then call the replace_block:api/execute function with {storage:"your command storage namespace ID"}. Block replacement will start immediately and end within the same tick. Currently, ReplaceBlock does not have a validation mechanism for configuration content, so please ensure your configuration contains all required data, otherwise it may cause serious errors in ReplaceBlock.
Configuration
Below is the complete configuration list. You can also view the example in reset_settings.mcfunction.
- Target Selector:
- Path:
{}.replace_block.selector - Content: A target selector that can include parameters.
- Example:
"@e[type=player]"
- Path:
- Search Range:
- Path:
{}.replace_block.search_range - Content: Traversal distance, where 1 means 9 chunks centered on the player.
- Example:
3
- Path:
- Success Threshold:
- Path:
{}.replace_block.success_threshold - Content: Number of block replacements required for a chunk replacement to be considered successful. If the total number of successfully replaced blocks in a chunk does not reach this value, traversal continues to the next chunk.
- Example:
50
- Path:
- Replacement Block Pairs List:
- target_block
- Path:
{}.replace_block.replace_pairs[].target_block - Content: Namespace ID of the block to be replaced
- Example:
"stone"
- Path:
- replace_with
- Path:
{}.replace_block.replace_pairs[].replace_with - Content: Namespace ID of the new block
- Example:
"air"
- Path:
- target_block
- Effective Dimensions List:
- dimension
- Path:
{}.replace_block.dimensions[].dimension - Content: Namespace ID of the dimension where replacement takes effect
- Example:
"minecraft:overworld"
- Path:
- min_y
- Path:
{}.replace_block.dimensions[].min_y - Content: Minimum height where replacement takes effect
- Example:
-64
- Path:
- max_y
- Path:
{}.replace_block.dimensions[].max_y - Content: Maximum height where replacement takes effect
- Example:
319
- Path:
- dimension




