ArLib
适用于 Minecraft 26.1+(数据包格式 101)的工具类数据包库。
它包含以下功能:聊天功能、玩家管理、战斗、世界控制、数学辅助、实体工具、物品栏实用工具、音效以及传送功能。
它还帮助开发者进行日志记录,
除非另有说明,所有函数都使用通过 arlib:input 存储传递的宏参数。
一般用法模式:
data merge storage arlib:input {param1:"value1", param2:"value2"}
function arlib:<category>/<name> with storage arlib:input
日志截图

文档
文档
调试/开发日志
ArLib 内置了调试日志系统。仅在启用调试模式时才会显示日志消息,并且仅对拥有 arlib.debug 标签的玩家可见。
设置
# 启用调试日志
scoreboard players set #debug arlib.dev 1
# 为某玩家显示日志消息
tag @s add arlib.debug
# 为某玩家隐藏日志消息
tag @s remove arlib.debug
# 完全禁用调试日志
scoreboard players set #debug arlib.dev 0
ArLib 的“Loaded.”消息也仅在调试开启时出现。
日志函数
所有日志函数均接受单个 message 参数。
chat/info - 青色 [INFO] 前缀。
data merge storage arlib:input {message:"Player entered zone."}
function arlib:chat/info with storage arlib:input
chat/success - 绿色 [OK] 前缀。
data merge storage arlib:input {message:"Arena ready."}
function arlib:chat/success with storage arlib:input
chat/warn - 黄色 [WARN] 前缀。
data merge storage arlib:input {message:"Low on resources."}
function arlib:chat/warn with storage arlib:input
chat/error - 深红色 [ERROR] 前缀。
data merge storage arlib:input {message:"Target not found."}
function arlib:chat/error with storage arlib:input
聊天
chat/send - 向特定目标发送格式化聊天消息。
| 参数 | 描述 |
|---|---|
| prefix | 括号中显示的标签,例如 "INFO" |
| color | 前缀的颜色代码 (0-f) |
| message | 消息文本 |
| target | 玩家选择器,例如 "@a", "@s" |
data merge storage arlib:input {prefix:"INFO", color:"6", message:"Hello!", target:"@a"}
function arlib:chat/send with storage arlib:input
chat/broadcast - 与 chat/send 相同,但始终发送给所有玩家。无需 target 参数。
| 参数 | 描述 |
|---|---|
| prefix | 括号中显示的标签 |
| color | 前缀的颜色代码 (0-f) |
| message | 消息文本 |
data merge storage arlib:input {prefix:"SERVER", color:"b", message:"Restarting soon."}
function arlib:chat/broadcast with storage arlib:input
chat/title - 在屏幕上显示标题和副标题。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| title | 主标题文本 |
| subtitle | 副标题文本 |
data merge storage arlib:input {target:"@a", title:"Welcome!", subtitle:"Enjoy your stay."}
function arlib:chat/title with storage arlib:input
chat/actionbar - 在动作栏(快捷栏上方)显示消息。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| message | 消息文本 |
data merge storage arlib:input {target:"@s", message:"Mana: 50/100"}
function arlib:chat/actionbar with storage arlib:input
chat/clear - 通过用空白行刷屏来清除玩家的聊天记录。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@a"}
function arlib:chat/clear with storage arlib:input
玩家
player/heal - 完全治愈玩家。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@s"}
function arlib:player/heal with storage arlib:input
player/feed - 完全恢复食物值和饱和度。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@s"}
function arlib:player/feed with storage arlib:input
player/clear_effects - 移除所有药水效果。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@a"}
function arlib:player/clear_effects with storage arlib:input
player/freeze - 通过将移动速度和跳跃强度设置为 0 来冻结或解冻玩家。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| state | "freeze"(冻结)或 "unfreeze"(解冻) |
data merge storage arlib:input {target:"@s", state:"freeze"}
function arlib:player/freeze with storage arlib:input
data merge storage arlib:input {target:"@s", state:"unfreeze"}
function arlib:player/freeze with storage arlib:input
战斗
combat/damage - 对目标造成特定数量的伤害。1 = 半颗心。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| amount | 伤害量(以半颗心为单位) |
data merge storage arlib:input {target:"@p", amount:"6"}
function arlib:combat/damage with storage arlib:input
combat/set_health - 将玩家的生命值设置为精确值。临时更改最大生命值,治疗,然后将最大生命值恢复为 20。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| health | 生命值(1-20,1 = 半颗心) |
data merge storage arlib:input {target:"@s", health:"6"}
function arlib:combat/set_health with storage arlib:input
世界
world/time_set - 使用命名预设设置世界时间。
| 参数 | 描述 |
|---|---|
| time | "day"(白天)、"noon"(正午)、"night"(夜晚)或 "midnight"(午夜) |
data merge storage arlib:input {time:"noon"}
function arlib:world/time_set with storage arlib:input
world/weather_set - 设置天气。
| 参数 | 描述 |
|---|---|
| weather | "clear"(晴朗)、"rain"(下雨)或 "thunder"(雷雨) |
data merge storage arlib:input {weather:"thunder"}
function arlib:world/weather_set with storage arlib:input
Time
time/is_day - 如果为白天(0-12999 刻),则将 #is_day arlib.temp 设置为 1,否则为 0。无参数。
function arlib:time/is_day
execute if score #is_day arlib.temp matches 1 run say It's daytime!
time/is_night - 如果为夜晚(13000-23999 刻),则将 #is_night arlib.temp 设置为 1,否则为 0。无参数。
function arlib:time/is_night
execute if score #is_night arlib.temp matches 1 run function my_pack:night_logic
Math
所有数学函数均基于计分板数值进行操作。需要先运行 arlib:load。
math/clamp - 将计分板数值限制在最小值和最大值之间。
| 参数 | 描述 |
|---|---|
| target | 计分板持有者,例如 "@s" 或 "#score" |
| objective | 计分板目标名称 |
| min | 最小值 |
| max | 最大值 |
data merge storage arlib:input {target:"@s", objective:"health", min:"0", max:"20"}
function arlib:math/clamp with storage arlib:input
math/abs - 将计分板数值设置为其绝对值。
| 参数 | 描述 |
|---|---|
| target | 计分板持有者 |
| objective | 计分板目标名称 |
scoreboard players set @s velocity -42
data merge storage arlib:input {target:"@s", objective:"velocity"}
function arlib:math/abs with storage arlib:input
# @s velocity 现在为 42
math/random - 生成一个随机数并将其存储在计分板中。
| 参数 | 描述 |
|---|---|
| target | 计分板持有者 |
| objective | 计分板目标名称 |
| min | 最小值(包含) |
| max | 最大值(包含) |
data merge storage arlib:input {target:"@s", objective:"dice", min:"1", max:"6"}
function arlib:math/random with storage arlib:input
Entity
entity/kill_type - 杀死所有指定类型的实体。
| 参数 | 描述 |
|---|---|
| type | 实体类型,例如 "minecraft:zombie" |
data merge storage arlib:input {type:"minecraft:creeper"}
function arlib:entity/kill_type with storage arlib:input
entity/count_type - 统计所有指定类型的实体数量,并将结果存储在计分板中。
| 参数 | 描述 |
|---|---|
| type | 实体类型 |
| target | 用于存储结果的计分板持有者 |
| objective | 计分板目标 |
data merge storage arlib:input {type:"minecraft:zombie", target:"#count", objective:"arlib.temp"}
function arlib:entity/count_type with storage arlib:input
execute if score #count arlib.temp matches 10.. run say Too many zombies!
entity/freeze_all - 为所有指定类型的实体设置或移除 NoAI 标签。
| 参数 | 描述 |
|---|---|
| type | 实体类型 |
| noai | "1b" 表示冻结,"0b" 表示解冻 |
data merge storage arlib:input {type:"minecraft:creeper", noai:"1b"}
function arlib:entity/freeze_all with storage arlib:input
entity/glow - 赋予所有指定类型的实体发光效果。
| 参数 | 描述 |
|---|---|
| type | 实体类型 |
| duration | 持续时间(秒),或使用 "infinite" 表示无限 |
data merge storage arlib:input {type:"minecraft:zombie", duration:"10"}
function arlib:entity/glow with storage arlib:input
entity/glow_remove - 移除所有指定类型的实体的发光效果。
| 参数 | 描述 |
|---|---|
| type | 实体类型 |
data merge storage arlib:input {type:"minecraft:creeper"}
function arlib:entity/glow_remove with storage arlib:input
Inventory
inventory/clear_slot - 通过将其替换为空气来清除特定的物品栏槽位。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| slot | 槽位名称(见下文) |
常用槽位:container.0 到 container.8(快捷栏),container.9 到 container.35(主背包),armor.head(头盔),armor.chest(胸甲),armor.legs(护腿),armor.feet(靴子),weapon.offhand(副手)。
data merge storage arlib:input {target:"@s", slot:"container.0"}
function arlib:inventory/clear_slot with storage arlib:input
inventory/give_safe - 仅在玩家至少有一个空物品栏槽位时给予物品。如果背包已满则显示警告。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| item | 物品 ID,例如 "minecraft:diamond" |
| count | 给予的数量 |
data merge storage arlib:input {target:"@s", item:"minecraft:golden_apple", count:"3"}
function arlib:inventory/give_safe with storage arlib:input
inventory/swap_offhand - 交换玩家的主手和副手物品。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@s"}
function arlib:inventory/swap_offhand with storage arlib:input
Sound
sound/play - 向目标播放声音。使用主音量通道,音量为 1,音调为 1。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
| sound | 声音 ID,例如 "minecraft:entity.experience_orb.pickup" |
data merge storage arlib:input {target:"@s", sound:"minecraft:block.note_block.pling"}
function arlib:sound/play with storage arlib:input
sound/alert - 向玩家播放一段短促的高音调“叮”声。
| 参数 | 描述 |
|---|---|
| target | 玩家选择器 |
data merge storage arlib:input {target:"@a"}
function arlib:sound/alert with storage arlib:input
传送
tp/save - 将执行者的玩家当前位置保存至指定名称的槽位中。必须以该玩家身份运行(as @s)。
| 参数 | 描述 |
|---|---|
| name | 路点的名称 |
data merge storage arlib:input {name:"home"}
execute as @s run function arlib:tp/save with storage arlib:input
tp/load - 将执行者玩家传送至之前保存的位置。必须以该玩家身份运行。
| 参数 | 描述 |
|---|---|
| name | 已保存路点的名称 |
data merge storage arlib:input {name:"home"}
execute as @s run function arlib:tp/load with storage arlib:input
tp/swap - 交换两名玩家的位置。
| 参数 | 描述 |
|---|---|
| player1 | 第一名玩家的实体选择器 |
| player2 | 第二名玩家的实体选择器 |
data merge storage arlib:input {player1:"@a[tag=red]", player2:"@a[tag=blue]"}
function arlib:tp/swap with storage arlib:input
你是这个资源的作者?登录后可认领此资源。
相似资源
此数据包添加了属于阿瓦里海盗的独特结构,将他们的独特风格带入你的 Minecraft 世界!兼容性:1.20 至 26.3
一个 Minecraft 光线投射库,能够精确检测玩家正在查看的方块,包括像台阶和楼梯这样的特殊方块形状。
此数据包添加了新的“祝福模式”难度。
允许服务器管理员方便地禁用 Xaero's Map 系列模组中的实体雷达、小地图等功能,使竞技游戏更加公平。
手持潜影盒时可直接打开,无需将其放置在地面上。只需按住 Shift 并右键点击即可访问你的潜影盒。
为你的 Minecraft 世界添加了超过 900 个新的进度
评论 0
登录后参与评分
还没有评论,来抢沙发吧