Lua API 参考
Lua 脚本 API 的完整方法参考。所有方法均通过 context.table:method() 语法调用。
Global 方法(标记为 GLOBAL)来自共享核心库 Magmacore。它们适用于 FreeMinecraftModels 脚本以及其他 MagmaCore ScriptInstance 消费者。EliteMobs Boss 能力复用同一个 Lua 沙箱,但暴露的是 Boss 专属的 context 表和方法名;EliteMobs NPC 脚本运行在同一个 MagmaCore 运行时上,会接收完整的共享上下文外加 NPC 专属的 context.npc 表。这些变体请参阅下方的 EliteMobs 章节以及 NPC 脚本。
EliteMobs 方法(标记为 ELITEMOBS)专用于 EliteMobs Boss 能力脚本和 NPC 脚本。
FMM 方法(标记为 FMM)专用于 FreeMinecraftModels 的物品和道具脚本。
当方法需要 Bukkit 枚举(Sound、Particle、Material 等)时,请参阅 Spigot Javadocs 查询有效值。枚举名称以全大写字符串传入(例如 "DIAMOND_SWORD"、"ENTITY_ARROW_SHOOT")。
Entity Table GLOBAL
所有实体表通用的基础字段 —— 玩家、生物、道具,任何实体都包含这些字段。
Properties
| Field | Type | Description |
|---|---|---|
uuid | string | 实体的 UUID |
entity_type | string | 实体类型(小写) |
is_valid | bool | 实体在世界中仍然存在 |
is_dead | bool | 实体已死亡 |
is_player | bool | 是否为玩家 |
is_hostile | bool | 是否为怪物(Monster) |
is_passive | bool | 是否为动物(Animal) |
current_location | location | 实体位置(x、y、z、yaw、pitch、world) |
world | string | 世界名称 |
当安装了相关插件时,插件专属的增强器可能会添加额外的顶层字段。EliteMobs 和 FreeMinecraftModels 的字段请参阅下方的桥接(bridge)章节。
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
teleport(location) | location table | nil | 传送实体 |
remove() | — | nil | 将实体从世界中移除 |
set_silent(enabled) | bool | nil | 设置是否静音 |
set_invulnerable(enabled) | bool | nil | 设置是否无敌 |
set_gravity(enabled) | bool | nil | 设置是否受重力影响 |
set_glowing(enabled) | bool | nil | 设置是否发光 |
Bridge: entity.elite
当安装了 EliteMobs 时,由 EliteMobs 的实体增强器添加。该增强器会添加以下顶层标志:
| Field | Type | Description |
|---|---|---|
is_elite | bool | 是否为 EliteMobs 实体 |
is_custom_boss | bool | 是否为 EliteMobs 自定义 Boss |
is_significant_boss | bool | 生命值倍率大于 1 的自定义 Boss(设计过的遭遇战) |
仅在 is_elite 为 true 时,entity.elite 才会存在。
| Field | Type | Description |
|---|---|---|
level | int | 精英怪物等级 |
name | string | 精英的显示名称 |
health | double | 当前生命值 |
max_health | double | 最大生命值 |
is_custom_boss | bool | 是否为自定义 Boss(顶层也可用) |
health_multiplier | double | 配置文件定义的生命值倍率 |
damage_multiplier | double | 配置文件定义的伤害倍率 |
remove() | method | 移除该精英实体 |
Bridge: entity.model
当安装了 FMM 时,由 FreeMinecraftModels 的实体增强器添加。该增强器会添加以下顶层标志:
| Field | Type | Description |
|---|---|---|
is_modeled | bool | 拥有 FMM 模型 |
is_prop | bool | 是否为 FMM 道具 |
仅在 is_modeled 为 true 时,entity.model 才会存在。
| Field | Type | Description |
|---|---|---|
model_id | string | 模型蓝图名称 |
is_dynamic | bool | 是否为 FMM DynamicEntity(true)或静态道具(false) |
play_animation(name, blend?, loop?) | method | 播放动画。blend 默认为 false,loop 默认为 false |
stop_animations() | method | 停止所有动画 |
remove() | method | 移除该模型化实体 |
Bridge: player permissions
当安装了 FMM 时,由 FreeMinecraftModels 的实体增强器添加。以下字段只会出现在玩家实体表上:
| Field / Method | Args | Returns | Description |
|---|---|---|---|
has_permission(node) | string | bool | 玩家是否拥有指定的权限节点 |
is_op | — | bool | 玩家是否为服务器管理员(OP) |
Living Entity Table GLOBAL
继承自 Entity Table。适用于所有生物实体(生物和玩家)。
Properties
| Field | Type | Description |
|---|---|---|
health | double | 当前生命值 |
maximum_health | double | 最大生命值 |
name | string | 实体显示名称 |
is_alive | bool | 实体未死亡 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
damage(amount) | double | nil | 对实体造成伤害 |
push(x, y, z) | double, double, double | nil | 添加速度向量 |
set_facing(x, y, z) | double, double, double | nil | 设置朝向方向 |
add_potion_effect(type, duration, amplifier) | string (PotionEffectType), int, int | nil | 按名称施加药水效果 |
remove_potion_effect(type) | string (PotionEffectType) | nil | 按名称移除药水效果 |
get_scale() | — | number | 当前实体缩放比例(在不支持 generic.scale 属性的服务器上默认为 1.0) |
set_scale(value) | double | nil | 通过 generic.scale 属性设置实体缩放比例(在 1.20.5 之前的服务器上为空操作) |
context.player GLOBAL
玩家实体表。继承所有 Entity 与 Living Entity 字段。
Properties
| Field | Type | Description |
|---|---|---|
game_mode | string | survival、creative、adventure、spectator |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
send_message(text) | string | nil | 发送聊天消息。支持颜色代码 |
get_held_item() | — | table or nil | 返回包含 type、amount、display_name 字段的表,或在手为空时返回 nil。type 为全大写的 Bukkit Material 名称 |
consume_held_item(amount?) | int (default 1) | nil | 减少手持物品堆叠数量 |
has_item(material, amount?) | string (Material), int (default 1) | bool | 检查背包中是否含有该材质 |
get_target_entity(range?) | num (default 50) | entity or nil | 通过射线检测获取玩家正在注视的实体 |
get_eye_location() | — | location | 玩家眼部位置 |
get_look_direction() | — | vector | 单位方向向量 |
send_block_change(x, y, z, material, ticks?) | int, int, int, string (Material), int (optional) | bool | 发送假方块。若指定 ticks,则在该时长后自动还原 |
reset_block(x, y, z) | int, int, int | bool | 将假方块还原为真实方块 |
sleep(x, y, z) | num, num, num | nil | 在指定位置播放床上睡眠动画 |
wake_up() | — | nil | 从睡眠中唤醒 |
show_boss_bar(text, color?, progress, ticks?) | string, string (BarColor, default WHITE), num, int (optional) | nil | 显示 Boss 血条。在 ticks 后自动隐藏。支持颜色代码 |
hide_boss_bar() | — | nil | 移除 Boss 血条 |
show_action_bar(text, ticks?) | string, int (optional) | nil | 显示动作栏。当 ticks 大于 0 时会重复显示。支持颜色代码 |
show_title(title, subtitle?, fadeIn, stay, fadeOut) | string, string (default empty), int, int, int | nil | 显示标题界面。支持颜色代码 |
context.world GLOBAL
面向 FreeMinecraftModels 脚本以及其他 Magmacore 支持的 ScriptInstance 运行时的世界操作。EliteMobs Boss 能力从这同一个基础表出发,并叠加下方列出的 EliteMobs context.world 新增项和重写项。
context.world 方法有两种可互换的形式:坐标式(x, y, z)和位置表式(*_at_location 变体)。两种形式在通用接口上都可用,而 EliteMobs Boss 能力在保留共享基础方法的同时,额外添加了 Boss 专属的位置表助手。
Properties
| Field | Type | Description |
|---|---|---|
name | string | 世界名称 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
get_block_at(x, y, z) | int, int, int | string | Material 名称(小写)。若区块未加载则返回 "air" |
set_block_at(x, y, z, material) | int, int, int, string (Material) | bool | 若材质有效则排队放置方块;未加载的区块会被跳过 |
get_highest_block_y(x, z) | int, int | int | 最高非空气方块的 Y 坐标 |
spawn_particle(particle, x, y, z, count?, dx?, dy?, dz?, speed?) | string (Particle), num, num, num, int?=1, num?=0, num?=0, num?=0, num?=0 | nil | 生成粒子效果 |
play_sound(sound, x, y, z, volume?, pitch?) | string (Sound), num, num, num, float?=1, float?=1 | nil | 播放声音 |
strike_lightning(x, y, z) | num, num, num | nil | 召唤闪电 |
get_time() | — | int | 世界时间(以 tick 为单位) |
set_time(ticks) | long | nil | 设置世界时间 |
get_nearby_entities(x, y, z, radius) | num, num, num, num | table | 实体表数组 |
get_nearby_players(x, y, z, radius) | num, num, num, num | table | 玩家实体表数组 |
spawn_entity(type, x, y, z) | string (EntityType), num, num, num | entity or nil | 生成原版实体;若实体类型无效则返回 nil |
raycast(fx, fy, fz, dx, dy, dz, max?) | num, num, num, num, num, num, num?=50 | table | 返回包含 hit_entity、hit_location、hit_block 字段的表 |
place_temporary_block(x, y, z, material, ticks?, require_air?) | int, int, int, string (Material), int?=0, bool?=false | bool | 排队放置在 ticks 后自动还原的方块。若材质无效或区块未加载则返回 false |
drop_item(x, y, z, material, amount?) | num, num, num, string (Material), int?=1 | entity or nil | 在该位置自然地掉落物品实体;若材质无效则返回 nil |
spawn_firework(x, y, z, colors, type?, power?) | num, num, num, table, string (FireworkEffect.Type)?=BALL, int?=1 | nil | 生成烟花 |
strike_lightning_at_location(loc) | location | nil | 召唤闪电 |
play_sound_at_location(loc, sound, volume?, pitch?) | location, string (Sound), float?=1, float?=1 | nil | 播放声音 |
spawn_particle_at_location(loc, particle, count?, dx?, dy?, dz?, speed?) | location, string (Particle), int?=1, num?=0, num?=0, num?=0, num?=0 | nil | 生成粒子效果 |
get_block_at_location(loc) | location | string | Material 名称(小写)。若区块未加载则返回 "air" |
set_block_at_location(loc, material) | location, string (Material) | bool | 若材质有效则排队放置方块;未加载的区块会被跳过 |
place_temporary_block_at_location(loc, material, ticks?, require_air?) | location, string (Material), int?=0, bool?=false | bool | 排队放置在 ticks 后自动还原的方块。若材质无效或区块未加载则返回 false |
get_highest_block_y_at_location(loc) | location | int or nil | 最高非空气方块的 Y 坐标 |
em helpers GLOBAL
在所有 MagmaCore Lua 运行时中通过 em 表暴露的全局助手构造器。
Constructors
| Method | Args | Returns | Description |
|---|---|---|---|
em.create_location(x, y, z, world?, yaw?, pitch?) | num, num, num, string?, num?, num? | location | 位置表,包含 x、y、z,可选的 world、yaw、pitch,以及一个原地修改的 add(dx, dy, dz) 方法 |
em.create_vector(x, y, z) | num, num, num | vector | 包含 x、y、z 的向量表 |
Zone Builders
区域构造器返回纯粹的区域定义表。球体、穹顶、圆柱体和长方体包含 :set_center(location)。锥体和射线区域包含 :set_origin(location) 和 :set_destination(location)。
| Method | Args | Returns | Description |
|---|---|---|---|
em.zone.create_sphere_zone(radius) | num | zone | { kind = "sphere", radius = ... } |
em.zone.create_dome_zone(radius) | num | zone | { kind = "dome", radius = ... } |
em.zone.create_cylinder_zone(radius, height) | num, num | zone | { kind = "cylinder", radius = ..., height = ... } |
em.zone.create_cuboid_zone(x, y, z) | num, num, num | zone | 长方体的半边长 |
em.zone.create_cone_zone(length, radius) | num, num | zone | 带起点/终点设置器的锥体定义 |
em.zone.create_static_ray_zone(length, thickness) | num, num | zone | 静态射线定义 |
em.zone.create_rotating_ray_zone(length, point_radius, animation_duration) | num, num, num | zone | 旋转射线定义 |
em.zone.create_translating_ray_zone(length, point_radius, animation_duration) | num, num, num | zone | 平移射线定义 |
em.location GLOBAL
挂载在全局 em 表上的位置查询助手。底层由 Magmacore 的 LocationQueryRegistry 和 LocationOwnership 服务支持,该服务汇集来自已注册提供方(EliteMobs 地下城/世界包区域、WorldGuard、GriefPrevention 等)的结果。所有函数都接受位置表({x, y, z, world}),在位置无效时返回安全的默认值。
| Method | Args | Returns | Description |
|---|---|---|---|
em.location.is_in_dungeon(loc) | location | bool | 该位置是否位于任意已注册地下城区域内 |
em.location.is_protected(loc) | location | bool | 是否有任何提供方将该位置标记为受保护(WorldGuard、GriefPrevention、EM 区域等) |
em.location.owned_by(loc, namespace) | location, string | bool | 该位置是否归指定命名空间所有(例如 "EliteMobs") |
em.location.owners(loc) | location | table | 声明拥有该位置的命名空间字符串数组 |
em.location.kinds_at(loc) | location | table | 该位置的类型标签数组(例如 "elitemobs"、"world_package"、"open_world_dungeon"、地下城规模分类) |
em.location.has_kind(loc, kind) | location, string | bool | 该位置是否带有指定的类型标签 |
context.boss ELITEMOBS
EliteMobs Lua 能力脚本中的 Boss 实体表。继承所有 EliteMobs Living Entity 方法。属性通过专用 getter 刷新。
Properties
| Field | Type | Description |
|---|---|---|
name | string | Boss 显示名称 |
uuid | string | 精英实体 UUID |
health | double | 当前生命值(快照) |
maximum_health | double | 最大生命值(快照) |
current_location | location | Boss 位置(快照) |
level | int | Boss 等级 |
damager_count | int | 对该 Boss 造成过伤害的玩家数量 |
is_in_combat | bool | Boss 处于战斗中 |
exists | bool | Boss 实体存在 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
is_alive() | — | bool | Boss 实体是否存活(实时检查) |
get_health() | — | double | 当前生命值(实时) |
get_maximum_health() | — | double | 最大生命值(实时) |
get_location() | — | location | 当前位置(实时) |
restore_health(amount) | double | nil | 为 Boss 治疗 |
despawn() | — | nil | 移除 Boss 实体 |
get_damager_count() | — | int | 实时的造伤者数量 |
add_tag(tag, ticks?) | string, int?=0 | nil | 添加标签,若指定 ticks 则到时自动移除 |
remove_tag(tag) | string | nil | 移除标签 |
has_tag(tag) | string | bool | 检查标签 |
reset_custom_name() | — | nil | 将名称重置为配置文件默认值 |
play_sound_at_self(sound, volume?, pitch?) | string(Minecraft 声音键,例如 "entity.wither.spawn"), float?=1, float?=1 | nil | 在 Boss 位置播放声音 |
play_sound_at_entity(sound, volume?, pitch?) | string(Minecraft 声音键,例如 "entity.wither.spawn"), float?=1, float?=1 | nil | 在 Boss 位置播放声音(别名) |
spawn_particle_at_self(particle, count?) | string (Particle) or table, int?=1 | nil | 在 Boss 位置生成粒子 |
play_model_animation(name) | string | nil | 播放 FMM 模型动画(需要 FMM 模型) |
has_mount() | - | bool | 该 Boss 是否正骑乘一个坐骑实体 |
get_mount() | - | entity or nil | 当前坐骑实体的引用,带有 is_mount = true 标记 |
set_mount(entity) | entity table | bool | 让 Boss 骑乘指定的实体 |
clear_mount() | - | bool | 让 Boss 离开其当前载具 |
dismount() | - | bool | clear_mount() 的别名 |
navigate_to_location(location, speed?, force?, timeout?) | location, double?=1, bool?=false, int?=0 | nil | 寻路前往该位置 |
send_message(text, range?) | string, double?=20 | nil | 向附近玩家发送消息。支持颜色代码 |
get_nearby_players(range) | double | table | 范围内的玩家表数组 |
get_target_player() | — | player or nil | 当前生物目标,如果是玩家的话 |
get_nearby_players_in_zone(zone) | zone table | table | 区域形状内的玩家 |
get_ender_dragon_phase() | — | string or nil | EnderDragon.Phase 名称 |
set_ender_dragon_phase(phase) | string (EnderDragon.Phase) | nil | 设置末影龙阶段 |
summon_reinforcement(file, zone?, level?) | string, zone or nil, int?=0 | entity or nil | 召唤增援 Boss |
summon_projectile(type, origin, dest, speed?, options?) | string (EntityType), location, location, double?=1, table | entity or nil | 生成可跟踪的弹射物;若类型或位置无效则返回 nil |
summon_projectile options
| Option | Type | Default | Description |
|---|---|---|---|
custom_damage | number | — | 覆盖弹射物伤害 |
detonation_power | string | — | 爆炸威力等级 |
yield | number | — | 火球当量 |
incendiary | bool | true | 火球点燃 |
gravity | bool | — | 启用重力 |
glowing | bool | false | 设置发光 |
invulnerable | bool | false | 设置无敌 |
persistent | bool | true | 设置为持久化 |
duration | int | 0 | 在 ticks 后自动移除 |
effect | string | — | 生成时播放的 EntityEffect |
spawn_at_origin | bool | false | 在原点生成,而不是从 Boss 处发射 |
direction_only | bool | false | 仅设置方向而不设置速度(火球用) |
track | bool | true | 注册为精英弹射物 |
on_land | function | — | 弹射物落地时的回调:function(location, entity) |
max_ticks | int | 6000 | 强制触发落地回调前的最大 tick 数 |
Zone/Particle Methods
| Method | Args | Returns | Description |
|---|---|---|---|
spawn_particles_in_zone(zone, particle, ...) | zone, particle spec, coverage?=1.0 | nil | 用粒子填充区域 |
spawn_particles_in_zone_border(zone, particle, ...) | zone, particle spec, coverage?=1.0 | nil | 用粒子勾勒区域轮廓 |
get_particles_from_self_toward_zone(zone, particle, speed?) | zone, string, double?=0.1 | table | 从 Boss 指向区域的定向粒子 |
get_particles_toward_self(zone, particle, speed?) | zone, string, double?=0.1 | table | 从区域指向 Boss 的定向粒子 |
spawn_particles_with_vector(particles) | table | nil | 生成定向粒子数组 |
Special Power Support
| Method | Args | Returns | Description |
|---|---|---|---|
start_tracking_fireball_system(speed?) | double?=0.5 | nil | 启动跟踪火球 AI |
handle_spirit_walk_damage(cause) | string (DamageCause) | nil | 根据伤害原因处理灵魂行走伤害 |
shield_wall_is_active() | — | bool | 盾墙是否激活 |
initialize_shield_wall(charges?) | int?=1 | nil | 激活盾墙 |
shield_wall_absorb_damage(player, damage) | entity table, double | bool | 尝试吸收伤害 |
deactivate_shield_wall() | — | nil | 关闭盾墙 |
start_zombie_necronomicon(target, file) | entity table, string | nil | 对目标启动死灵之书 |
context.npc ELITEMOBS NPC
EliteMobs NPC Lua 脚本中的 NPC 表。NPC 脚本位于 plugins/EliteMobs/npc_scripts/,并通过 NPC 配置的 scripts: 列表挂接。NPC 脚本与其他所有接口运行在同一个 MagmaCore 运行时上,会接收完整的共享上下文 —— context.world、context.zones、context.scheduler、context.cooldowns、context.log、context.event、context.player、context.state —— 外加此处记录的 NPC 专属 context.npc 表。
Properties
| Field | Type | Description |
|---|---|---|
name | string | NPC 显示名称 |
filename | string | NPC 配置文件名 |
uuid | string | 运行时 NPC 的 UUID |
activation_radius | double | 配置的激活半径 |
current_location | location | NPC 实体存在时的快照位置 |
entity_type | string | NPC 实体存在时的 Bukkit 实体类型 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
is_valid() | - | bool | NPC 背后的实体是否仍然有效 |
get_location() | - | location | 当前 NPC 位置,或生成位置作为后备 |
get_eye_location() | - | location | 当前眼部位置,或生成位置作为后备 |
get_activation_radius() | - | double | 当前配置的激活半径 |
get_nearby_players(radius) | double | table | NPC 附近的玩家表 |
face_direction_or_location(target) | vector or location | nil | 朝向某方向或望向某位置 |
say_greeting(player?) | player、UUID、name 或 nil | nil | 发送配置的问候语。在可用时默认发给触发的玩家 |
say_dialog(player?) | player、UUID、name 或 nil | nil | 发送配置的对话。在可用时默认发给触发的玩家 |
say_farewell(player?) | player、UUID、name 或 nil | nil | 发送配置的告别文本。在可用时默认发给触发的玩家 |
play_model_animation(name) | string | nil | 若可用则播放自定义模型动画;否则为安全的空操作 |
NPC 专属的钩子包括 on_spawn、on_remove、on_game_tick、on_npc_interact、on_npc_proximity_enter 和 on_npc_proximity_leave。完整的工作流和冷却细节请参阅 EliteMobs NPC 脚本。
EliteMobs Living Entity Table ELITEMOBS
在 EliteMobs 能力脚本内创建的实体表(来自 context.boss、事件数据、区域回调和世界查询)使用扩展过的生物实体表,其方法在全局 Living Entity 之外还包含额外内容。context.boss 继承所有这些方法。
Properties
| Field | Type | Description |
|---|---|---|
name | string | 实体显示名称 |
uuid | string | 实体 UUID |
entity_type | string | 实体类型名称 |
is_player | bool | 是否为玩家 |
is_monster | bool | 是否为怪物(Monster) |
is_elite | bool | 是否为 EliteMobs 实体 |
is_valid | bool | 实体仍然存在 |
is_mount | bool | 当此实体表代表一个 Boss 坐骑时为 true |
health | double | 当前生命值(快照) |
maximum_health | double | 最大生命值(快照) |
current_location | location | 实体位置(快照) |
game_mode | string | 游戏模式(EliteMobs 中为大写:SURVIVAL、CREATIVE、ADVENTURE、SPECTATOR) |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
is_alive() | — | bool | 实体是否存活(实时检查) |
is_ai_enabled() | — | bool | AI 是否启用 |
is_frozen() | — | bool | Boss 是否被冻结(仅 CustomBossEntity) |
is_on_ground() | — | bool | 实体是否在地面上 |
is_healing() | — | bool | 精英是否正在恢复 |
get_location() | — | location | 当前位置(实时) |
get_eye_location() | — | location | 眼部位置(实时) |
get_height() | — | double | 实体高度 |
get_health() | — | double | 当前生命值(实时) |
get_maximum_health() | — | double | 最大生命值(实时) |
get_velocity() | — | vector | 当前速度向量 |
deal_damage(amount) | double | nil | 造成普通伤害 |
deal_custom_damage(amount) | double | nil | 以该能力所属 Boss 的身份造成自定义攻击伤害 |
deal_damage_from_boss(amount) | double | nil | 造成归属于该能力 Boss 实体的伤害 |
restore_health(amount) | double | nil | 治疗实体(若为精英则使用 EliteMobs 的治疗机制) |
play_sound_at_entity(sound, volume?, pitch?) | string(Minecraft 声音键,例如 "entity.ender_dragon.growl"), float?=1, float?=1 | nil | 在实体位置播放声音 |
play_sound_at_self(sound, volume?, pitch?) | string(Minecraft 声音键,例如 "entity.ender_dragon.growl"), float?=1, float?=1 | nil | 在实体位置播放声音(别名) |
spawn_particle_at_self(particle, count?) | string (Particle) or table, int?=1 | nil | 在实体位置生成粒子 |
spawn_particles_at_location(loc, particle, count?) | location, particle spec, int?=1 | nil | 在指定位置生成粒子 |
teleport_to_location(location) | location | nil | 传送实体 |
set_velocity_vector(vector) | vector | nil | 设置速度 |
set_gravity(enabled) | bool | nil | 设置是否受重力影响 |
apply_push_vector(vector, additive?, delay?) | vector, bool?=false, int?=1 | nil | 延迟后施加速度。additive 表示叠加到现有速度上 |
push_relative_to(location, force?, extraX?, extraY?, extraZ?) | location, double?=1, double?=0, double?=0, double?=0 | nil | 将实体从指定位置推开 |
set_custom_name(name) | string | nil | 设置自定义显示名称。支持颜色代码 |
reset_custom_name() | — | nil | 将名称重置为 EliteMobs 默认值 |
set_custom_name_visible(visible) | bool | nil | 切换名称是否可见 |
set_ai_enabled(enabled, duration?) | bool, int?=0 | nil | 设置 AI 状态。在 duration ticks 后自动恢复 |
set_awareness_enabled(enabled, duration?) | bool, int?=0 | nil | 设置生物的感知。在 duration ticks 后自动恢复 |
face_direction_or_location(target) | vector or location | nil | 朝向某方向或望向某位置 |
play_model_animation(name) | string | nil | 播放 FMM 模型动画(需要 FMM 模型) |
is_inside_vehicle() | - | bool | 实体是否正骑乘另一个实体 |
has_vehicle() | - | bool | 实体是否拥有载具 |
get_vehicle() | - | entity or nil | 当前载具实体的引用 |
set_vehicle(entity) | entity table | bool | 让此实体骑乘指定载具 |
leave_vehicle() | - | bool | 让此实体离开其当前载具 |
has_passengers() | - | bool | 此实体是否有乘客 |
get_passenger_count() | - | int | 乘客数量 |
get_passengers() | - | table | 乘客实体引用数组 |
add_passenger(entity) | entity table | bool | 为此实体添加一名乘客 |
remove_passenger(entity) | entity table | bool | 从此实体移除一名乘客 |
eject_passengers() | - | bool | 弹出所有乘客 |
set_scale(scale, duration?) | double, int?=0 | nil | 设置实体缩放比例。在 duration ticks 后自动恢复为 1.0 |
set_invulnerable(enabled, duration?) | bool, int?=0 | nil | 设置无敌。在 duration ticks 后自动恢复 |
set_healing(enabled) | bool | nil | 设置精英的治疗状态 |
navigate_to_location(location, speed?, force?, timeout?) | location, double?=1, bool?=false, int?=0 | nil | 寻路前往该位置(仅 CustomBossEntity) |
add_tag(tag, ticks?) | string, int?=0 | nil | 添加标签,到时自动移除 |
remove_tag(tag) | string | nil | 移除标签 |
has_tag(tag) | string | bool | 检查标签 |
overlaps_box_at_location(center, halfX?, halfY?, halfZ?) | location, double?=0.5, double?=halfX, double?=halfX | bool | 实体的包围盒是否与某位置上的盒子重叠 |
remove_elite() | — | nil | 通过 EliteMobs 的清理流程移除 |
apply_potion_effect(type, duration, amplifier?) | string (PotionEffectType), int, int?=0 | nil | 施加药水效果 |
set_equipment(slot, material, options?) | string (EquipmentSlot), string (Material), table | nil | 设置装备槽中的物品 |
set_fire_ticks(ticks) | int | nil | 设置着火 ticks |
add_visual_freeze_ticks(ticks?) | int?=1 | nil | 增加冻结视觉 ticks |
place_temporary_block(material, ticks?, requireAir?) | string (Material), int?=0, bool?=false | nil | 在实体位置放置临时方块 |
set_equipment options
| Option | Type | Default | Description |
|---|---|---|---|
unbreakable | bool | false | 设置物品为不可破坏 |
enchantments | table | — | {type = "ENCHANT_NAME", level = 1} 数组 |
EliteMobs Player Methods
EliteMobs 脚本中的玩家拥有所有 EliteMobs 生物实体方法,外加:
| Method | Args | Returns | Description |
|---|---|---|---|
send_message(text) | string | nil | 发送聊天消息。支持颜色代码 |
show_action_bar(text) | string | nil | 显示动作栏文字。支持颜色代码 |
show_title(title, subtitle?, fadeIn?, stay?, fadeOut?) | string, string?="", int?=10, int?=40, int?=10 | nil | 显示标题界面。支持颜色代码 |
show_boss_bar(title, color?, style?, duration?) | string, string (BarColor)?=WHITE, string (BarStyle)?=SOLID, int?=40 | nil | 显示 Boss 血条。在 duration ticks 后自动隐藏。支持颜色代码 |
run_command(command) | string | nil | 以玩家身份执行命令 |
EliteMobs Entity Reference Table
由 EliteMobs 生成方法返回的非生物实体(弹射物、坠落方块、烟花)会获得一个轻量级的引用表:
| Field / Method | Args | Returns | Description |
|---|---|---|---|
name | — | string | 实体名称 |
uuid | — | string | 实体 UUID |
entity_type | — | string | 实体类型名称 |
is_player | — | bool | 始终为 false |
is_elite | — | bool | 始终为 false |
is_valid() | — | bool | 实体是否仍然有效(实时检查) |
current_location | — | location | 位置(快照) |
get_location() | — | location | 当前位置(实时) |
get_velocity() | — | vector | 当前速度向量 |
is_on_ground() | — | bool | 实体是否在地面上 |
teleport_to_location(location) | location | nil | 传送实体 |
set_velocity_vector(vector) | vector | nil | 设置速度 |
set_direction_vector(vector) | vector | nil | 设置方向(仅火球) |
set_yield(amount) | double | nil | 设置火球当量 |
set_gravity(enabled) | bool | nil | 设置是否受重力影响 |
detonate() | — | nil | 引爆烟花 |
remove() | — | nil | 移除实体 |
unregister(reason?) | string?=OTHER | nil | 从 EliteMobs 实体跟踪器中注销 |
context.players ELITEMOBS
EliteMobs 能力脚本中可用的玩家查询表。提供相对于 Boss 查找玩家的辅助方法。
| Method | Args | Returns | Description |
|---|---|---|---|
current_target() | — | player or nil | 若事件的当事者是玩家则返回该玩家,否则返回 Boss 当前的生物目标(若为玩家) |
nearby_players(radius) | double | table | Boss 周围 radius 范围内的玩家表数组 |
all_players_in_world() | — | table | Boss 所在世界中所有玩家的表数组 |
context.entities ELITEMOBS
EliteMobs 能力脚本中可用的实体查询表。提供相对于 Boss 查找实体的辅助方法。所有查询都排除 Boss 自身。
| Method | Args | Returns | Description |
|---|---|---|---|
get_nearby_entities(radius, filter?) | double, string?="living" | table | radius 范围内的实体。"all"/"entities" 返回所有实体(包括非生物);其他任意值则返回按类别过滤的生物实体:"player(s)"、"elite(s)"、"mob(s)",默认 = 所有生物实体 |
get_entities_in_box(center, halfX, halfY, halfZ, filter?) | location, double, double, double, string?="living" | table | 轴对齐盒子内的生物实体(过滤值同上;仅支持非 all 模式) |
get_all_entities(filter?) | string?="living" | table | Boss 所在世界中的所有生物实体(过滤值同上) |
get_direct_target_entity() | — | entity or nil | 触发事件中的直接目标实体 |
get_boss_spawn_location() | — | location | Boss 的原始生成位置 |
context.vectors ELITEMOBS
EliteMobs 能力脚本中可用的向量数学工具。
| Method | Args | Returns | Description |
|---|---|---|---|
get_vector_between_locations(from, to, options?) | location, location, table | vector | 从源指向目标的向量。Options 可修改结果 |
rotate_vector(vector, pitch?, yaw?) | vector, double?=0, double?=0 | vector | 按 pitch 和 yaw(角度)旋转向量 |
normalize_vector(vector) | vector | vector | 归一化为单位长度 |
context.state GLOBAL
一个在脚本实例的整个生命周期内持续存在的普通 Lua 表。用它来存储标志、计数器、任务 ID、开关状态以及任何你需要在钩子之间共享的数据。context.state 是脚本自有的持久化表;大多数其他 context 表会按需重建或惰性重新创建。FMM 出于性能考虑会按道具缓存 context.prop,但其 current_location 等实时字段在读取时仍会刷新。
context.state.counter = (context.state.counter or 0) + 1
context.cooldowns GLOBAL
冷却管理。本地冷却作用于单个脚本实例;全局冷却在同一实体/所有者上的所有脚本之间共享。如果未提供 key,则默认使用脚本文件名。
| Method | Args | Returns | Description |
|---|---|---|---|
local_ready(key?) | string (optional) | bool | 本地冷却是否已经结束 |
local_remaining(key?) | string (optional) | int | 本地冷却剩余的 ticks(就绪时为 0) |
check_local(key?, duration) | string (optional), int | bool | 若就绪,则开始冷却并返回 true;否则返回 false |
set_local(duration, key?) | long, string (optional) | nil | 设置本地冷却,时长为 duration ticks |
global_ready() | — | bool | 全局冷却是否已经结束 |
set_global(duration) | long | nil | 设置全局冷却,时长为 duration ticks |
在 EliteMobs 能力脚本中,本地冷却在同一 Boss 实体上的所有能力之间共享,而全局冷却使用 Boss 内置的能力冷却系统。
EliteMobs NPC 脚本使用共享的冷却参数顺序 check_local(key?, duration);参阅 NPC 脚本。
context.scheduler GLOBAL
任务调度。所有任务在脚本关闭时会自动取消。
Global (Magmacore) variant
FreeMinecraftModels 脚本和 EliteMobs NPC 脚本使用此共享变体。下方 EliteMobs 风格的名称是同一调度器上的别名,因此在通用接口上两种命名风格都有效。
| Method | Args | Returns | Description |
|---|---|---|---|
run_later(ticks, callback) | int, function | int | ticks 后运行回调。返回任务 ID |
run_repeating(delay, interval, callback) | int, int, function | int | 在初始延迟后每 interval ticks 运行一次回调。返回任务 ID |
cancel(taskId) | int | nil | 取消已调度的任务 |
EliteMobs variant
| Method | Args | Returns | Description |
|---|---|---|---|
run_after(ticks, callback) | int, function | int | ticks 后运行回调。返回任务 ID |
run_every(ticks, callback) | int, function | int | 每 N ticks 运行一次回调。返回任务 ID |
cancel_task(taskId) | int | nil | 取消已调度的任务 |
context.log GLOBAL
用于脚本调试的日志工具。
Global (Magmacore / FMM) variant
| Method | Args | Returns | Description |
|---|---|---|---|
info(message) | string | nil | 记录 info 级消息 |
warn(message) | string | nil | 记录 warning 级消息 |
error(message) | string | nil | 记录 error/warning 级消息 |
EliteMobs variant
| Method | Args | Returns | Description |
|---|---|---|---|
info(message) | string | nil | 记录 info 级消息 |
warn(message) | string | nil | 记录 warning 级消息 |
debug(message) | string | nil | 记录 debug 级消息(以 debug 前缀作为 info 显示) |
context.zones GLOBAL
面向 FreeMinecraftModels 脚本以及其他 Magmacore 支持的 ScriptInstance 运行时的区域创建与监控。EliteMobs Boss 能力使用下方的 EliteMobs context.zones 变体。
Global (Magmacore) variant
| Method | Args | Returns | Description |
|---|---|---|---|
create_sphere(x, y, z, radius) | num, num, num, num | int | 创建球形区域,返回句柄 |
create_cylinder(x, y, z, radius, height) | num, num, num, num, num | int | 创建圆柱形区域,返回句柄 |
create_cuboid(x, y, z, xSize, ySize, zSize) | num, num, num, num, num, num | int | 创建长方体区域,返回句柄 |
watch(handle, on_enter?, on_leave?) | int, function?, function? | bool | 启用区域跟踪。传入函数参数会启用 on_zone_enter / on_zone_leave;函数体不会被直接调用。区域钩子会接收跨越边界的玩家对应的 context.player / context.event.player |
unwatch(handle) | int | nil | 停止跟踪区域 |
EliteMobs variant
| Method | Args | Returns | Description |
|---|---|---|---|
get_entities_in_zone(zone, options?) | zone table, table | table | 获取区域内的实体。Options:filter、mode |
get_locations_in_zone(zone, options?) | zone table, table | table | 获取区域内的位置。Options:coverage、mode |
zone_contains(zone, location, mode?) | zone table, location, string?="full" | bool | 位置是否位于区域内("full" 或 "border") |
watch_zone(zone, callbacks, options?) | zone table, table, table? | nil | 监视区域的进入/离开。回调:{on_enter = fn, on_leave = fn}。Options 支持 filter 和 mode |
context.event GLOBAL
触发当前脚本执行的钩子对应的事件数据表。在事件驱动的钩子以及提供了玩家当事者的通用 MagmaCore 区域进入/离开钩子中存在;在 on_game_tick、调度回调或没有玩家的生命周期钩子中不存在。
Global (Magmacore) variant
| Field / Method | Type | Description |
|---|---|---|
is_cancelled | bool | 构建上下文时的取消状态;在 cancel() / uncancel() 之后不会刷新 |
cancel() | method | 当底层 Bukkit 事件可取消时,取消该事件 |
uncancel() | method | 当底层 Bukkit 事件可取消时,撤销取消 |
player | entity table | 参与事件的玩家(如有) |
通用区域钩子会填充 player,但其背后并非可取消的 Bukkit 事件,因此那里不存在 cancel() 和 uncancel()。
关于 EliteMobs 的事件表(提供伤害值、伤害类型等),请参阅 EliteMobs Event Table。
context.script ELITEMOBS
通往 EliteMobs Elite Script 系统的桥梁。让 Lua 能力可以通过与 Elite Script YAML 配置同名的 Lua 表使用基于 YAML 的目标、区域和相对向量系统。
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
target(spec) | table | target handle | 从 Elite Script 目标规范表创建目标句柄 |
zone(spec) | table | zone handle | 从 Elite Script 区域规范表创建区域句柄 |
relative_vector(spec, location?, zone?) | table, location, zone handle | vector handle | 从 Elite Script 向量规范创建相对向量 |
damage(target, amount?, multiplier?) | target handle, double?=0, double?=1 | nil | 对目标中的所有实体造成伤害 |
push(target, vector, additive?) | target handle, vector or vector handle, bool?=false | nil | 以速度推动目标实体 |
set_facing(target, vector) | target handle, vector or vector handle | nil | 设置目标实体的朝向 |
spawn_particles(target, particles) | target handle, table or string | nil | 在目标位置生成粒子 |
Target Handle
由 context.script:target(spec) 返回。spec 表使用与 Elite Script YAML 目标配置相同的键名(例如 {targetType = "NEARBY_PLAYERS", range = 20})。
| Method | Args | Returns | Description |
|---|---|---|---|
entities() | — | table | 目标处的实体表数组 |
locations() | — | table | 目标处的位置表数组 |
first_entity() | — | entity or nil | 目标处的第一个实体 |
first_location() | — | location or nil | 目标处的第一个位置 |
Zone Handle
由 context.script:zone(spec) 返回。spec 表使用与 Elite Script YAML 区域配置相同的键名(例如 {shape = "SPHERE", radius = 5, target = {targetType = "SELF"}})。
| Method | Args | Returns | Description |
|---|---|---|---|
full_target(coverage?) | number | target handle | 区域内部位置的目标句柄 |
border_target(coverage?) | number | target handle | 区域边界位置的目标句柄 |
full_locations(coverage?) | number | table | 内部位置数组 |
border_locations(coverage?) | number | table | 边界位置数组 |
full_entities() | — | table | 区域内部的实体 |
border_entities() | — | table | 区域边界上的实体 |
contains(location, mode?) | location, string?="full" | bool | 位置是否位于区域内 |
watch(callbacks, mode?) | table, string?="full" | int | 监视进入/离开。返回任务 ID |
Vector Handle
由 context.script:relative_vector(spec) 返回。spec 表使用与 Elite Script YAML 相对向量配置相同的键名。
| Method | Args | Returns | Description |
|---|---|---|---|
resolve() | — | vector | 为当前上下文计算向量 |
context.world (EliteMobs) ELITEMOBS
EliteMobs 能力脚本的 Boss 专属世界表。Boss 能力从通用的 MagmaCore world 表起步,因此 get_block_at(...)、set_block_at(...)、spawn_particle(...) 等坐标助手仍然可用。下方的方法是 EliteMobs 的新增项或 Boss 专属的重写项,主要是位置表形式和 Boss 助手。
Block Queries
| Method | Args | Returns | Description |
|---|---|---|---|
get_block_type_at_location(loc) | location | string or nil | Material 名称 |
get_highest_block_y_at_location(loc) | location | int or nil | 最高方块的 Y 坐标 |
get_blast_resistance_at_location(loc) | location | double | 爆炸抗性值 |
is_air_at_location(loc) | location | bool | 方块是否为空气 |
is_passable_at_location(loc) | location | bool | 方块是否可通过 |
is_passthrough_at_location(loc) | location | bool | 方块是否非实心 |
is_on_floor_at_location(loc) | location | bool | 该处为空气且下方为实心方块 |
is_standing_on_material(loc, material) | location, string (Material) | bool | 下方方块是否匹配指定材质 |
Block Manipulation
| Method | Args | Returns | Description |
|---|---|---|---|
set_block_at_location(loc, material, requireAir?) | location, string (Material), bool?=false | nil | 放置方块。若 requireAir 为 true,则只替换空气 |
place_temporary_block_at_location(loc, material, ticks?, requireAir?) | location, string, int?=0, bool?=false | nil | 放置方块,在 ticks 后自动移除。若 requireAir 为 true,则只替换空气 |
Spawning
| Method | Args | Returns | Description |
|---|---|---|---|
spawn_boss_at_location(file, loc?, level?) | string, location?=boss loc, int?=boss level | entity or nil | 生成自定义 Boss |
spawn_custom_boss_at_location(file, loc, options?) | string, location, table | entity or nil | 带选项生成 Boss(level、silent、add_as_reinforcement、velocity) |
spawn_entity_at_location(type, loc, options?) | string (EntityType), location, table | entity or nil | 带选项生成原版实体(velocity、duration、effect、on_land、max_ticks) |
spawn_falling_block_at_location(loc, material, options?) | location, string (Material), table | entity or nil | 生成坠落方块(drop_item、hurt_entities、velocity、on_land) |
spawn_reinforcement_at_location(file, loc, level?, velocity?) | string, location, int?=0, vector | entity or nil | 生成绑定到 Boss 的增援 |
spawn_fireworks_at_location(loc, config) | location, table | entity or nil | 生成烟花 |
spawn_splash_potion_at_location(loc, config) | location, table | entity or nil | 生成喷溅药水 |
Effects and Utility
| Method | Args | Returns | Description |
|---|---|---|---|
play_sound_at_location(loc, sound, volume?, pitch?) | location, string(Minecraft 声音键,例如 "entity.blaze.shoot"), float?=1, float?=1 | nil | 播放声音 |
spawn_particle_at_location(loc, particle, count?) | location, string (Particle) or table, int?=1 | nil | 生成粒子 |
strike_lightning_at_location(loc) | location | nil | 召唤闪电(绕过 EM 保护) |
run_empowered_lightning_task_at_location(loc) | location | nil | 强化闪电特效 |
generate_fake_explosion(locations, center?) | table of locations, location | nil | 无伤害的视觉爆炸 |
spawn_fake_gold_nugget_at_location(loc, velocity, gravity?) | location, vector, bool?=false | fake projectile or nil | 生成视觉用的金粒弹射物 |
run_fake_gold_nugget_damage(projectiles) | table | nil | 对假弹射物进行伤害检测 |
set_world_time(time) or (loc, time) | long, or location + long | nil | 设置世界时间 |
set_world_weather(weather, duration?) or (loc, weather, duration?) | string (CLEAR, RAIN, PRECIPITATION, THUNDER), int?=6000 | nil | 设置天气 |
run_console_command(command) | string | nil | 执行控制台命令 |
generate_player_loot(times?) | int?=1 | nil | 为造伤玩家进行这么多次玩家战利品掷骰 |
drop_bonus_coins(multiplier?) | double?=2 | nil | 在 Boss 处掉落额外金币 |
context.settings (EliteMobs)
| Method | Args | Returns | Description |
|---|---|---|---|
warning_visual_effects_enabled() | — | bool | 配置中是否启用了警告视觉特效 |
EliteMobs Event Table
context.event 表会传递给伤害和生成钩子。字段因事件类型而异。
| Field / Method | Type | Present When | Description |
|---|---|---|---|
damage_amount | double | 伤害事件 | 原始伤害值 |
damage_cause | string | 伤害事件 | DamageCause 名称 |
damager | entity table | 实体造伤事件 | 造成伤害的实体 |
projectile | entity table | 弹射物伤害事件 | 造成伤害的弹射物 |
spawn_reason | string | 生成事件 | 生成原因名称 |
entity | entity table | 死亡/区域事件 | 相关实体 |
cancel_event() | method | 大多数事件 | 取消事件 |
set_damage_amount(amount) | method (double) | 伤害事件 | 覆盖伤害值 |
multiply_damage_amount(multiplier) | method (double) | 伤害事件 | 乘上当前伤害 |
context.item FMM
在 FMM 物品脚本中访问。通过 PDC 标签从玩家装备槽中解析出对应的脚本物品。
读取方法在调用时检查当前装备的匹配物品。写入方法会将其变更排队到 Bukkit 主线程上并返回 nil。
Properties
| Field | Type | Description |
|---|---|---|
id | string | 物品的脚本标识符 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
material() | — | string | Material 名称 |
get_amount() | — | int | 堆叠数量 |
set_amount(n) | int | nil | 排队设置堆叠数量 |
consume(n?) | int?=1 | nil | 排队减少 n 个数量,归零时移除 |
get_uses() | — | int | PDC 存储的使用计数器 |
set_uses(n) | int | nil | 排队设置 PDC 使用计数器 |
get_durability() | — | table or nil | 返回包含 current 和 max 字段的表,无耐久条时返回 nil |
get_durability_percentage() | — | number or nil | 0.0--1.0 的剩余比例,否则为 nil |
use_durability(amount, can_break?) | int, bool?=false | nil | 排队按固定值减少耐久。当为 false 时,会将耐久钳制在剩余 1 |
use_durability_percentage(fraction, can_break?) | number, bool?=false | nil | 排队按最大耐久的比例减少(0.0--1.0) |
get_name() | — | string or nil | 显示名称 |
set_name(s) | string | nil | 排队设置显示名称。支持颜色代码 |
get_lore() | — | table | lore 字符串数组 |
set_lore(table) | table | nil | 排队从字符串数组设置 lore |
context.prop FMM
在 FMM 道具脚本中访问。继承自承载用盔甲架的所有 Entity 字段。
Properties
| Field | Type | Description |
|---|---|---|
model_id | string | 蓝图模型名称 |
current_location | location | 道具当前位置 |
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
play_animation(name, blend?, loop?) | string, bool?=true, bool?=true | bool | 播放指定动画 |
stop_animation() | — | nil | 停止当前所有动画 |
hurt_visual() | — | nil | 红色受伤闪烁,无实际伤害 |
pickup() | — | nil | 排队移除道具并掉落对应放置物品 |
has_mount_points() | — | bool | 道具是否拥有挂载点骨骼 |
mount(player) | entity table | bool | 排队挂载检查;返回 true 表示基本引用有效 |
dismount(player) | entity table | bool | 排队卸载检查;返回 true 表示基本引用有效 |
get_passengers() | — | table | 已挂载玩家的实体表数组 |
spawn_elitemobs_boss(file, x, y, z) | string, num, num, num | entity or nil | 生成 EliteMobs Boss(需要 EliteMobs) |
open_inventory(player, title, rows?) | entity table, string, int?=3 | bool | 排队打开持久化箱子界面(rows 钳制在 1--6)。标题支持颜色代码 |
place_book(player) | entity table | bool | 排队将玩家手中的成书/可写书存储到道具上 |
read_book(player) | entity table | bool | 排队打开已存储的书以供阅读 |
take_book(player) | entity table | bool | 排队将存储的书归还给玩家 |
has_book() | — | bool | 是否存有一本书 |
drop_inventory() | — | bool | 排队掉落所有已存储物品并清空存储 |
drop_book() | — | bool | 排队掉落已存储的书并清空存储 |
is_viewing_inventory(player) | entity table | bool | 玩家是否正打开此道具的界面 |
set_persistent_data(key, value) | string, string | bool | 在道具的 PDC 中存储字符串 |
get_persistent_data(key) | string | string or nil | 从道具的 PDC 中获取字符串 |
Color Codes
所有标注支持颜色代码的方法都使用 Magmacore 的 ChatColorConverter。这些格式可以在任何字符串中自由混用:
Legacy codes
使用 & 加颜色/格式字符:
| Code | Color | Code | Format |
|---|---|---|---|
&0 | 黑色 | &l | 粗体 |
&1 | 深蓝色 | &m | |
&2 | 深绿色 | &n | 下划线 |
&3 | 深青色 | &o | 斜体 |
&4 | 深红色 | &r | 重置 |
&5 | 深紫色 | ||
&6 | 金色 | ||
&7 | 灰色 | ||
&8 | 深灰色 | ||
&9 | 蓝色 | ||
&a | 绿色 | ||
&b | 青色 | ||
&c | 红色 | ||
&d | 浅紫色 | ||
&e | 黄色 | ||
&f | 白色 |
Hex colors
使用 6 位十六进制指定精确的 RGB 颜色:
&#FF5500 -- ampersand prefix
<#FF5500> -- tag syntax
Gradients
在文本范围内于两种或多种颜色之间平滑插值:
<gradient:#FF0000:#0000FF>This text fades red to blue</gradient>
<g:#FF0000:#00FF00:#0000FF>Three-color gradient</g>
简写 g 与 gradient 完全等价。你可以串联任意数量的颜色节点。
Rainbow
以全饱和度循环遍历完整的色相光谱。可选的数字参数会偏移起始色相(相位偏移):
<rainbow>Full rainbow text</rainbow>
<r:0.5>Rainbow with a shifted starting hue</r>
Common Types
location
{ x = number, y = number, z = number, yaw = number, pitch = number, world = string }
vector
{ x = number, y = number, z = number }
entity table
任何带有 uuid 字段的表。来自 context 的玩家与实体表可以直接使用:
context.player -- valid entity table
context.world:get_nearby_entities(x,y,z,r) -- returns array of entity tables