Random Structures
一个 Minecraft 数据包,会定期在每个玩家的位置放置随机的原版结构或特性。
功能说明
每隔一段时间(默认为 1 分钟),每个在线玩家都有机会在他们站立的位置生成随机的结构(村庄、林地府邸、要塞)或随机的特性(树木、矿脉、蘑菇)。
配置
#global 假人上有两个计分板值用于控制行为。在数据包加载后,你可以在游戏中(或通过 /function 文件)修改它们:
| 计分板目标 |
默认值 |
含义 |
rs_interval_ticks |
1200 |
尝试放置的间隔刻数(1200 刻 = 60 秒,假设 TPS 为 20)。 |
rs_structure_percent |
25 |
放置完整结构的概率百分比(1–100)。 |
示例命令:
scoreboard players set #global rs_interval_ticks 600
scoreboard players set #global rs_structure_percent 50
工作原理
该数据包位于 randstruct 命名空间下,并挂钩到原版的 #minecraft:load 和 #minecraft:tick 函数标签:
load -> 创建数据包使用的计分板目标,并在首次加载时设置可配置选项的默认值。
tick -> 推进刻计数器;一旦达到配置的间隔,它重置并为每个玩家运行 place_random。
place_random -> 掷出 1–100 的数字。如果落在 rs_structure_percent 范围内,则调用 place_structure。否则调用 place_feature。然后在特殊情况下克隆每个玩家周围 16×16×16 的区域,以处理因放置的结构/特性而出现的幽灵方块问题。
place_structure -> 从原版结构中随机选择一个,并放置在每个玩家的位置。
place_feature -> 从原版特性中随机选择一个,并放置在每个玩家的位置。
这两个放置函数都会将放置的内容记录在 randstruct:data 存储中,并通过 tellraw 在聊天中宣布。
安装
将此文件夹复制到世界的 datapacks 目录中,然后运行 /reload(如果尚未启用,请运行 /datapack enable "file/random_structures")。
兼容性
数据包格式为 101.2-107.1,涵盖 26.2 快照至 26.2 正式版。虽然技术上兼容 1.20.2+(具体为 23w31a+),但特性/结构 ID 列表包含了 1.20.2 之后添加的内容。任何在较旧版本中尚不存在的结构 ID 都会静默失败,无法放置任何内容。
注意事项
- 放置使用玩家的精确位置,因此结构可能会覆盖现有的地形、建筑,或在已加载区块之外部分生成。
Random Structures
A Minecraft data pack that periodically places a random vanilla structure or feature at each player's location.
What it does
Every interval (1 minute by default), each online player has a chance to have a random structure (village, woodland mansion, stronghold) or a random feature (tree, ore vein, mushroom) generated where they are standing.
Configuration
There are 2 scoreboard values on the #global fake player that control behavior. Change them in-game (or via a /function file) after the pack has loaded:
| Scoreboard objective |
Default |
Meaning |
rs_interval_ticks |
1200 |
Ticks between placement attempts (1200 ticks = 60 seconds at 20 TPS). |
rs_structure_percent |
25 |
Percent chance (1–100) of placing a full structure instead of a feature. |
Example commands:
scoreboard players set #global rs_interval_ticks 600
scoreboard players set #global rs_structure_percent 50
How it works
The pack lives under the randstruct namespace and hooks into vanilla's #minecraft:load and #minecraft:tick function tags:
load -> creates the scoreboard objectives used by the pack and sets default values for the configurable options the first time the pack loads.
tick -> advances a tick counter; once it reaches the configured interval, it resets and runs place_random for every player.
place_random -> rolls a 1–100 number. If it falls within rs_structure_percent, it calls place_structure. Otherwise it calls place_feature. It then clones a 16×16×16 area around each players in niche cases where ghost blocks appear from the placed structure/feature.
place_structure -> rolls one of the vanilla structures and places it at each player's position.
place_feature -> rolls one of the vanilla features and places it at each player's position.
Both placement functions record what they placed in the randstruct:data storage and announce it in the chat via tellraw.
Installation
Copy this folder into the world's datapacks directory, then run /reload (or /datapack enable "file/random_structures" if it isn't enabled yet).
Compatibility
Data pack format is 101.2-107.1, covering the 26.2 snapshots through the 26.2 release. While technically compatible with 1.20.2+ (specifically 23w31a+), the feature/structure ID lists include things added well after 1.20.2. Any structure ID that doesn't exist yet in an older version will silently fail to place anything.
Notes
- Placement uses the player's exact position, so structures can overwrite existing terrain, builds, or generate partially outside loaded chunks.
评论 0
登录后参与评分
还没有评论,来抢沙发吧