Radial Patterns
Radial Patterns 是一个小型的 Minecraft Java 版数据包库,用于在围绕原点的随机方块图案上运行自定义函数。
它本身不会修改方块、伤害实体或每刻执行操作。其他数据包会调用它并提供应在每个选定位置运行的函数。
适用于飞溅、爆炸、风化、腐蚀、霜冻、魔法效果、挖掘工具以及其他希望呈现不规则感但无需进行实时射线检测的效果。
兼容性
- Minecraft:Java Edition 26.2
- 数据包格式:107
- 许可证:MIT
安装
下载发布版 zip 文件并将其放入世界的 datapacks 文件夹中:
<world>/datapacks/radial-patterns-<version>.zip
然后运行:
/reload
用法
在你的效果中心调用 radial_patterns:apply,并为每一层传递一个回调函数:
execute positioned <x> <y> <z> run function radial_patterns:apply {outer_func:"example:outer",middle_func:"example:middle",inner_func:"example:inner"}
每个回调函数将在为该层选定的方块位置上运行。各层的执行顺序如下:
outer
middle
inner
坐标可以重叠,因此同一位置可能会收到多次回调执行。这对于希望向中心增强的效果非常有用。
示例
创建一个回调函数:
# data/example/function/puff.mcfunction
particle minecraft:dust{color:[1.0,0.2,0.1],scale:0.8} ~ ~ ~ 0.18 0.18 0.18 0 4 force
调用该库:
execute at @s run function radial_patterns:apply {outer_func:"example:puff",middle_func:"example:puff",inner_func:"example:puff"}
对于会改变方块的效果,请保持回调函数轻量,并首先拒绝无关的方块:
execute if block ~ ~ ~ #example:affected_blocks run function example:process_block
形状
生成的图案使用 81 个可能的相对坐标:
- 中心的
3x3x3 立方体;
- 从该立方体每侧延伸出的一个居中的
3x3 面。
这形成了一个紧凑的半径为二的形状,而无需扫描完整 5x5x5 立方体的每个角落。
每次调用都会从每一层随机选择一个生成的图案。默认发布版包含每层 8 个图案,共计 8 x 8 x 8 = 512 种可能的层组合。
开发者说明
仓库结构
radial-patterns/
├── data/
│ ├── minecraft/tags/function/load.json
│ ├── radial_patterns/function/apply.mcfunction
│ ├── radial_patterns/function/load.mcfunction
│ ├── radial_patterns/function/dispatch/
│ ├── radial_patterns/function/patterns/
│ └── radial_patterns_test/function/puff.mcfunction
├── tools/generate-patterns.py
├── pack.mcmeta
├── pack.png
├── README.md
└── LICENSE
重新生成图案
图案和分发器文件是预先生成的:
python3 tools/generate-patterns.py --clean --patterns 8 --seed 365 --manifest build/pattern-manifest.json
生成器会验证每个坐标是否位于规范的 81 坐标形状内,并确保每层中没有重复的图案。
导出发布版 zip
在仓库根目录下执行:
mkdir -p dist
zip -r dist/radial-patterns-1.0.0.zip pack.mcmeta pack.png data -x '*/.DS_Store'
将该 zip 上传至 Modrinth 作为数据包文件。
本地测试
- 将仓库复制或符号链接到世界的
datapacks 文件夹中。
- 运行
/reload。
- 运行内置的粒子测试:
execute positioned ~ ~ ~ run function radial_patterns:apply {outer_func:"radial_patterns_test:puff",middle_func:"radial_patterns_test:puff",inner_func:"radial_patterns_test:puff"}
预期行为:在半径为二的形状内部出现随机聚集的粒子爆发,且重复调用会产生变化,因为每一层都会选择随机生成的图案。
Radial Patterns
Radial Patterns is a small Minecraft Java Edition datapack library for running your own functions across randomized block patterns around an origin.
It does not change blocks, damage entities, or run on tick by itself. Other datapacks call it and provide the functions that should run at each selected position.
Good fits include splashes, bursts, weathering, corrosion, frost, magic effects, mining tools, and other effects that should feel irregular without doing live raycasts.
Compatibility
- Minecraft: Java Edition 26.2
- Data pack format: 107
- License: MIT
Install
Download the release zip and put it in your world's datapacks folder:
<world>/datapacks/radial-patterns-<version>.zip
Then run:
/reload
Use
Call radial_patterns:apply at the center of your effect and pass one callback function for each layer:
execute positioned <x> <y> <z> run function radial_patterns:apply {outer_func:"example:outer",middle_func:"example:middle",inner_func:"example:inner"}
Each callback runs at the block positions selected for that layer. The layers run in this order:
outer
middle
inner
Coordinates can overlap, so the same position may receive more than one callback execution. This is useful for effects that should become stronger toward the center.
Example
Create a callback:
# data/example/function/puff.mcfunction
particle minecraft:dust{color:[1.0,0.2,0.1],scale:0.8} ~ ~ ~ 0.18 0.18 0.18 0 4 force
Call the library:
execute at @s run function radial_patterns:apply {outer_func:"example:puff",middle_func:"example:puff",inner_func:"example:puff"}
For block-changing effects, keep callbacks cheap and reject irrelevant blocks first:
execute if block ~ ~ ~ #example:affected_blocks run function example:process_block
Shape
The generated patterns use 81 possible relative coordinates:
- the central
3x3x3 cube;
- one centered
3x3 face extending from each side of that cube.
This gives a compact radius-two shape without scanning every corner of a full 5x5x5 cube.
Each invocation randomly selects one generated pattern from each layer. The default release includes 8 patterns per layer, for 8 x 8 x 8 = 512 possible layer combinations.
Developer Notes
Repository layout
radial-patterns/
├── data/
│ ├── minecraft/tags/function/load.json
│ ├── radial_patterns/function/apply.mcfunction
│ ├── radial_patterns/function/load.mcfunction
│ ├── radial_patterns/function/dispatch/
│ ├── radial_patterns/function/patterns/
│ └── radial_patterns_test/function/puff.mcfunction
├── tools/generate-patterns.py
├── pack.mcmeta
├── pack.png
├── README.md
└── LICENSE
Regenerate patterns
Pattern and dispatcher files are generated ahead of time:
python3 tools/generate-patterns.py --clean --patterns 8 --seed 365 --manifest build/pattern-manifest.json
The generator validates that every coordinate is inside the canonical 81-coordinate shape and avoids duplicate patterns within each layer.
Export a release zip
From the repository root:
mkdir -p dist
zip -r dist/radial-patterns-1.0.0.zip pack.mcmeta pack.png data -x '*/.DS_Store'
Upload that zip to Modrinth as the datapack file.
Test locally
- Copy or symlink the repo into a world's
datapacks folder.
- Run
/reload.
- Run the included particle test:
execute positioned ~ ~ ~ run function radial_patterns:apply {outer_func:"radial_patterns_test:puff",middle_func:"radial_patterns_test:puff",inner_func:"radial_patterns_test:puff"}
Expected behavior: a randomized clustered particle burst appears inside the radius-two shape, and repeated calls vary because each layer selects a random generated pattern.
评论 0
登录后参与评分
还没有评论,来抢沙发吧