跳到主要内容

Lua API 参考

本参考由实时的 MagmaCore、FreeMinecraftModels 和 EliteMobs Lua 表构建器、增强器以及运行时上下文解析器生成。

Entity Table

MagmaCore 的 entity 表是通用实体值的基础;Living Entity、Player 和 FreeMinecraftModels Prop 表都继承自它。

Properties

字段类型说明
uuidstring实体 UUID。
entity_typestring小写的 Bukkit 实体类型。
is_validbool实时的有效性值。
is_deadbool实时的死亡状态。
current_locationtable/nil实时的 {x, y, z, yaw, pitch, world} 位置。
worldstring/nil实时的世界名称。
is_playerbool该实体是否为玩家。
is_hostilebool该实体是否实现了 Bukkit Monster
is_passivebool该实体是否实现了 Bukkit Animals

Methods

方法参数返回值说明
teleport(location)tablenil传送到某个位置表。
remove()nil若实体仍然有效则移除它。
set_silent(enabled)boolnil设置静默状态。
set_invulnerable(enabled)boolnil设置无敌状态。
set_gravity(enabled)boolnil设置重力状态。
set_glowing(enabled)boolnil设置发光状态。

Entity Table: EliteMobs 增强

实时的 EliteMobs 增强器会向 MagmaCore entity 表添加这些值;只有当 is_elite 为 true 时 elite 才存在。

Properties

字段类型说明
is_eliteboolEliteMobs 当前是否在跟踪该实体。
is_custom_bossbool被跟踪的精英是否为自定义 Boss。
is_significant_bossbool是否为生命值倍率高于 1 的自定义 Boss。
elitetable/nil嵌套的实时 EliteMobs 数据,仅在成功解析出精英时存在。
elite.levelint精英等级快照。
elite.namestring/nil精英显示名称快照。
elite.healthnumber实时生命值。
elite.max_healthnumber实时最大生命值。
elite.is_custom_bossbool该精英是否为自定义 Boss。
elite.health_multipliernumber已配置的生命值倍率快照。
elite.damage_multipliernumber已配置的伤害倍率快照。

Methods

方法参数返回值说明
elite.remove()nil通过 EliteMobs 移除流程移除该精英。

Entity Table: FreeMinecraftModels 增强

实时的 FreeMinecraftModels 增强器会添加这些值;只有当 is_modeled 为 true 时 model 才存在,而仅限玩家的值只会出现在玩家表上。

Properties

字段类型说明
is_modeledboolFreeMinecraftModels 是否解析出一个带模型的实体。
is_propbool该实体是否为以盔甲架为载体的 FreeMinecraftModels 道具。
modeltable/nil嵌套的模型数据,仅在带模型的实体上存在。
model.model_idstring/nil模型蓝图标识符。
model.is_dynamicbool该带模型实体是否为动态实体。
is_opbool仅限玩家的服务器 OP 状态。

Methods

方法参数返回值说明
model.play_animation(name, blend?=false, loop?=false)string, bool?=false, bool?=falsebool播放模型动画并返回是否已开始播放。
model.stop_animations()nil停止所有当前的模型动画。
model.remove()nil移除该带模型的实体。
has_permission(node)stringbool仅限玩家的权限检查。

Living Entity Table

MagmaCore 的 living entity 表继承 Entity Table 的每一个属性和方法。

Properties

字段类型说明
healthnumber实时生命值。
maximum_healthnumber实时最大生命值。
namestring/nil实时的 Bukkit 实体名称。
is_aliveboolBukkit 死亡状态的实时取反值。

Methods

方法参数返回值说明
damage(amount)numbernil造成 Bukkit 伤害。
push(x, y, z)number, number, numbernil向当前速度叠加一个向量。
set_facing(x, y, z)number, number, numbernil面向某个方向向量。
add_potion_effect(type, duration, amplifier)string (PotionEffectType), int, intnil当类型可解析时添加一个药水效果。
remove_potion_effect(type)string (PotionEffectType)nil当类型可解析时移除一个药水效果。
get_scale()number返回 scale 属性,不可用时返回 1.0
set_scale(value)numbernil在服务器支持时设置 scale 属性。

Player Table

MagmaCore 的 player 表继承 Living Entity Table 的每一个属性和方法。

Properties

字段类型说明
game_modestring小写的 Bukkit 游戏模式快照。

Methods

方法参数返回值说明
send_message(text)stringnil发送经 MagmaCore 颜色解析器处理过的文本。
get_held_item()table/nil返回主手物品的 {type, amount, display_name},空手时返回 nil。
consume_held_item(amount?=1)int?=1nil排队减少主手物品堆叠数量。
has_item(material, amount?=1)string (Material), int?=1bool检测背包中是否含有所需数量。
get_target_entity(range?=50)number?=50table/nil射线检测玩家正在注视的实体。
get_eye_location()table返回眼部位置。
get_look_direction()table返回单位 {x, y, z} 方向。
send_block_change(x, y, z, material, ticks?=-1)int, int, int, string (Material), int?=-1bool发送仅客户端可见的方块,并可在正数 ticks 后还原;无效或非方块材质返回 false。
reset_block(x, y, z)int, int, intbool排队为该玩家还原真实方块。
sleep(x, y, z)number, number, numbernil排队强制播放睡眠动画,并在醒来后还原被替换的方块。
wake_up()nil排队在玩家睡眠时将其唤醒。
show_boss_bar(text, color?=WHITE, progress, ticks?=-1)string, string (BarColor)?=WHITE, number, int?=-1nil替换玩家当前的实心 Boss 血条,并可在正数 ticks 后隐藏。
hide_boss_bar()nil移除玩家当前的 Lua Boss 血条。
show_action_bar(text, ticks?=-1)string, int?=-1nil发送一次,或每 40 ticks 重复一次直到正数时长结束。
show_title(title, subtitle?="", fade_in, stay, fade_out)string, string?="", int, int, intnil显示标题,其主标题与副标题文本经颜色处理

World Table

MagmaCore 的 world 表以 context.world 暴露;EliteMobs Boss 能力继承它并应用后文所述的覆盖项。

Properties

字段类型说明
namestring世界名称快照。

Methods

方法参数返回值说明
get_block_at(x, y, z)int, int, intstring返回小写的 Material 名称;未加载的区块不会被加载,此时返回 air
set_block_at(x, y, z, material)int, int, int, string (Material)bool排队放置方块;无效材质返回 false,排队任务会跳过未加载的区块。
get_highest_block_y(x, z)int, intint返回最高方块的 Y 坐标。
spawn_particle(particle, x, y, z, count?=1, dx?=0, dy?=0, dz?=0, speed?=0)string (Particle), number, number, number, int?=1, number?=0, number?=0, number?=0, number?=0nil生成粒子;无效名称不做任何事。
play_sound(sound, x, y, z, volume?=1, pitch?=1)string (Sound), number, number, number, number?=1, number?=1nil播放已注册音效,或小写的带命名空间资源包音效键。
strike_lightning(x, y, z)number, number, numbernil降下闪电。
get_time()int以 tick 返回世界时间。
set_time(ticks)intnil设置世界时间。
get_nearby_entities(x, y, z, radius)number, number, number, numbertable返回附近的 Entity 或 Living Entity 表。
get_nearby_players(x, y, z, radius)number, number, number, numbertable返回附近的 Player 表。
spawn_entity(type, x, y, z)string (EntityType), number, number, numbertable/nil生成原版实体;无效类型返回 nil。
raycast(from_x, from_y, from_z, dir_x, dir_y, dir_z, max_distance?=50)number, number, number, number, number, number, number?=50table返回 hit_entityhit_locationhit_block 值。
place_temporary_block(x, y, z, material, ticks?=0, require_air?=false)int, int, int, string (Material), int?=0, bool?=falsebool放置临时方块;无效材质或未加载区块返回 false。
drop_item(x, y, z, material, amount?=1)number, number, number, string (Material), int?=1table/nil自然掉落一个物品并返回其 Entity Table;无效材质返回 nil。
spawn_firework(x, y, z, colors, type?=BALL, power?=1)number, number, number, table, string (FireworkEffect.Type)?=BALL, int?=1nil使用 Bukkit Color 常量名排队生成烟花;若无法解析出任何颜色则默认为白色。
strike_lightning_at_location(location)tablenil在位置表所在世界降下闪电。
play_sound_at_location(location, sound, volume?=1, pitch?=1)table, string (Sound), number?=1, number?=1nil播放已注册音效,或小写的带命名空间资源包音效键。
spawn_particle_at_location(location, particle, count?=1, dx?=0, dy?=0, dz?=0, speed?=0)table, string (Particle), int?=1, number?=0, number?=0, number?=0, number?=0nil在位置表所在世界生成粒子。
get_block_at_location(location)tablestring返回小写材质名称;位置无效或区块未加载时返回 air
set_block_at_location(location, material)table, string (Material)bool在位置表所在世界排队放置方块。
place_temporary_block_at_location(location, material, ticks?=0, require_air?=false)table, string (Material), int?=0, bool?=falsebool在位置表所在世界放置临时方块。
get_highest_block_y_at_location(location)tableint/nil返回最高方块的 Y 坐标;位置无效时返回 nil。

context.world:FreeMinecraftModels 追加内容

FreeMinecraftModels 会把这些方法注册到它自己的 MagmaCore world 表上,因此它们会出现在 FreeMinecraftModels 物品脚本和道具脚本的 context.world 上。当 EliteMobs 未启用或玩家无法解析时,每个方法都返回 false;当 location 参数缺失或不可用时,会回退到该玩家的位置。

Methods

方法参数返回值说明
drop_elitemobs_procedural_loot(player, level, location?)table/string, int, table?bool为该玩家掉落一件程序化生成的 EliteMobs 物品;当程序化物品掉落被禁用时返回 false。
drop_elitemobs_random_loot(player, level, location?)table/string, int, table?bool按给定等级为该玩家掷取 EliteMobs 战利品表。
drop_elitemobs_custom_loot(player, file, level, location?)table/string, string, int, table?bool为该玩家掉落指定的 EliteMobs 自定义物品文件;当文件无法解析时返回 false。

player 参数接受玩家表、UUID 字符串或精确的玩家名称。location 参数接受位置表,或带有 current_location 的实体表。

em 辅助表

MagmaCore 会在任何脚本钩子运行之前全局暴露这张表。

Properties

辅助构造函数返回下列紧凑数据表。

字段类型说明
location.xnumberem.create_location 返回的 X 坐标。
location.ynumberem.create_location 返回的 Y 坐标。
location.znumberem.create_location 返回的 Z 坐标。
location.worldstring/nil传给 em.create_location 时的世界名称。
location.yawnumber/nil传给 em.create_location 时的 yaw。
location.pitchnumber/nil传给 em.create_location 时的 pitch。
vector.xnumberem.create_vector 返回的 X 分量。
vector.ynumberem.create_vector 返回的 Y 分量。
vector.znumberem.create_vector 返回的 Z 分量。
zone.kindstringspheredomecylindercuboidconestatic_rayrotating_raytranslating_ray
zone.radiusnumber/nil球体、穹顶、圆柱或圆锥的半径。
zone.heightnumber/nil圆柱高度。
zone.xnumber/nil立方体的 X 尺寸。
zone.ynumber/nil立方体的 Y 尺寸。
zone.znumber/nil立方体的 Z 尺寸。
zone.lengthnumber/nil圆锥或射线的长度。
zone.thicknessnumber/nil静态射线的粗细。
zone.point_radiusnumber/nil旋转射线或平移射线的点半径。
zone.animation_durationnumber/nil旋转射线或平移射线的动画时长。
zone.origintable/nilset_centerset_origin 设置的位置。
zone.destinationtable/nilset_destination 设置的位置。

Methods

方法参数返回值说明
em.create_location(x, y, z, world?, yaw?, pitch?)number, number, number, string?, number?, number?table返回一个位置表。
em.create_vector(x, y, z)number, number, numbertable返回一个 {x, y, z} 向量表。
location.add(dx?=0, dy?=0, dz?=0)number?=0, number?=0, number?=0table就地相加并返回同一个位置表。
em.zone.create_sphere_zone(radius)numbertable返回带 set_center(location) 的球体定义。
em.zone.create_dome_zone(radius)numbertable返回带 set_center(location) 的穹顶定义。
em.zone.create_cylinder_zone(radius, height)number, numbertable返回带 set_center(location) 的圆柱定义。
em.zone.create_cuboid_zone(x, y, z)number, number, numbertable返回带 set_center(location) 的立方体定义。
em.zone.create_cone_zone(length, radius)number, numbertable返回带 set_origin(location)set_destination(location) 的圆锥定义。
em.zone.create_static_ray_zone(length, thickness)number, numbertable返回带起点和终点设置器的静态射线定义。
em.zone.create_rotating_ray_zone(length, point_radius, animation_duration)number, number, numbertable返回带起点和终点设置器的旋转射线定义。
em.zone.create_translating_ray_zone(length, point_radius, animation_duration)number, number, numbertable返回带起点和终点设置器的平移射线定义。
zone.set_center(location)tabletable将中心设为 zone.origin 并返回同一个 zone 表。
zone.set_origin(location)tabletable设置起点并返回同一个 zone 表。
zone.set_destination(location)tabletable设置终点并返回同一个 zone 表。
em.location.is_in_dungeon(location)tablebool检测已注册的地下城区域,以及报告 dungeon 类型的归属方。
em.location.is_protected(location)tablebool检测内置的 WorldGuard/GriefPrevention 适配器以及插件注册的保护归属方。
em.location.owned_by(location, namespace)table, stringbool按插件命名空间检测归属关系。
em.location.owners(location)tabletable返回归属方命名空间字符串数组。
em.location.kinds_at(location)tabletable返回归属类型字符串数组。
em.location.has_kind(location, kind)table, stringbool检测某个归属类型。

context.state

每个 MagmaCore 脚本实例都会收到一张普通 Lua 表,它在该实例的生命周期内持续存在。可用于计数器、标志位、任务 ID,以及在各钩子之间共享的值。

context.state.counter = (context.state.counter or 0) + 1

context.log

MagmaCore、FreeMinecraftModels 与 EliteMobs NPC 方法

方法参数返回值说明
info(message)stringnil以共享的 Lua 前缀记录一条信息性消息。
warn(message)stringnil记录一条警告。
error(message)stringnil通过共享的警告通道记录。

EliteMobs Boss 能力方法

方法参数返回值说明
info(message)stringnil记录一条 Boss 能力的信息性消息。
warn(message)stringnil记录一条警告。
debug(message)stringnil以 Lua 能力调试前缀记录一条信息性消息。

context.scheduler

计划任务归属于脚本实例,并在实例关闭时被取消。下面两套命名系列在共享的 MagmaCore 接口和 EliteMobs Boss 能力上都可用。

方法参数返回值说明
run_later(ticks, callback)int, functionint延迟后运行一次,并返回 Bukkit 任务 ID。
run_repeating(delay, interval, callback)int, int, functionint在初始延迟之后重复运行,并返回任务 ID。
cancel(task_id)intnil取消一个自己拥有的任务。
run_after(ticks, callback)int, functionintrun_later 的别名。
run_every(interval, callback)int, functionint无初始延迟地重复运行,并返回任务 ID。
cancel_task(task_id)intnilcancel 的别名。

context.cooldowns

本地冷却按单个脚本归属方与定义作为键;全局冷却由同一个归属方共享。省略本地键时使用 __lua: 加脚本文件名。EliteMobs Boss 能力暴露同样的方法名,但本地值使用该 Boss 的共享冷却存储,全局值使用其内置的能力冷却。

方法参数返回值说明
local_ready(key?)string?bool检测所键控的本地冷却是否就绪。
local_remaining(key?)string?int返回剩余 tick 数;已就绪时返回 0
check_local(key, duration)string/nil, intbool若已就绪则启动冷却并返回 true。传入 nil 以使用默认键。
set_local(duration, key?)int, string?nil设置或清除本地冷却;非正数时长会清除它。
global_ready()bool检测归属方的全局冷却是否就绪。
set_global(duration)intnil以 tick 设置全局冷却。在共享的 MagmaCore 接口上,非正数时长会清除它。

context.zones:共享的 MagmaCore 接口

FreeMinecraftModels 脚本、EliteMobs NPC 脚本以及其他默认的 MagmaCore 消费者会在当前脚本归属方所在的世界中收到整数型区域句柄。

方法参数返回值说明
create_sphere(x, y, z, radius)number, number, number, numberint/nil注册一个球体并返回其句柄;归属方没有世界时返回 nil。
create_cylinder(x, y, z, radius, height)number, number, number, number, numberint/nil注册一个圆柱并返回其句柄;归属方没有世界时返回 nil。
create_cuboid(x, y, z, x_size, y_size, z_size)number, number, number, number, number, numberint/nil注册一个立方体并返回其句柄;归属方没有世界时返回 nil。
watch(handle, on_enter?, on_leave?)int, function?, function?bool/nil为一个已知句柄启用边界跟踪。函数是否存在决定是否启用对应的 on_zone_enteron_zone_leave 钩子;传入的函数体本身不会被直接调用。
unwatch(handle)intnil停止跟踪并移除该句柄。

通用区域钩子通过 context.playercontext.event.player 暴露跨越边界的玩家。

context.event:共享的 MagmaCore 接口

当共享钩子存在当前 Bukkit 事件或行为者时,这张表才存在。计划回调以及两者皆无的钩子中不存在这张表。

字段或方法类型说明
is_cancelledbool构建上下文表时捕获的取消状态;调用 cancel()uncancel() 不会刷新该字段。
cancel()method取消当前事件。仅当事件实现了 Bukkit Cancellable 时存在。
uncancel()method撤销当前事件的取消。仅当事件实现了 Bukkit Cancellable 时存在。
playertable当前行为者可用时,为其提供的 Living Entity Table。

通用区域钩子提供行为者但没有可取消的 Bukkit 事件,因此它们暴露 is_cancelled = falseplayer,但没有 cancel()uncancel()

context.item

FreeMinecraftModels 物品脚本会为匹配的已装备脚本化物品收到这张表。

Properties

字段类型说明
idstring脚本化物品标识符。

Methods

方法参数返回值说明
material()string/nil返回大写的 Material 名称;物品未装备时返回 nil。
get_amount()int返回堆叠数量;未装备时返回 0
set_amount(amount)intnil排队设置堆叠数量。
consume(amount?=1)int?=1nil排队减少堆叠数量。
get_uses()int返回持久化的使用次数计数器,默认为 0
set_uses(uses)intnil排队设置持久化的使用次数计数器。
get_durability()table/nil返回 {current, max};物品没有耐久条时返回 nil。
get_durability_percentage()number/nil返回从 0.01.0 的剩余耐久,或 nil。
use_durability(amount, can_break?=false)int, bool?=falsenil排队施加固定耐久损耗;除非允许损坏,否则钳制到剩余一点。
use_durability_percentage(fraction, can_break?=false)number, bool?=falsenil排队施加等于最大耐久某一比例的耐久损耗。
get_name()string/nil返回显示名称;不存在时返回 nil。
set_name(name)stringnil排队设置经颜色处理的显示名称。
get_lore()table返回 lore 字符串数组。
set_lore(lore)tablenil排队设置经颜色处理的 lore 字符串。

context.prop

FreeMinecraftModels 道具脚本会收到这张表;当存在承载实体时,它继承 MagmaCore 的 Entity Table。

Properties

字段类型说明
model_idstring/nil模型蓝图名称;不存在蓝图时为 nil。
current_locationtable/nil实时的道具位置。

Methods

方法参数返回值说明
play_animation(name, blend?=true, loop?=true)string, bool?=true, bool?=truebool播放指定名称的动画。
stop_animation()nil停止所有当前动画。
hurt_visual()nil播放红色染色受伤特效但不造成伤害。
pickup()nil排队永久移除并掉落一个放置物品。
has_mount_points()bool检测该道具是否具有骑乘点骨骼。
mount(player)tablebool排队让已解析的玩家骑乘到第一个可用座位上。
dismount(player)tablebool排队让已解析的玩家从该道具上下来。
get_passengers()table返回已骑乘玩家的 Entity Table。
spawn_elitemobs_boss(file, x, y, z)string, number, number, numbertable/nil当 EliteMobs 已启用时生成一个 EliteMobs 自定义 Boss。
open_inventory(player, title, rows?=3)table, string, int?=3bool排队打开持久化存储,rows 钳制在 16 之间。
place_book(player)tablebool当道具尚未存放书本时,排队存入一本手持的成书或书与笔。
read_book(player)tablebool排队打开已存放的成书。
take_book(player)tablebool排队把已存放的书本归还给玩家。
has_book()bool检测该道具是否存放着书本。
drop_inventory()bool排队清空持久化存储并掉落其中的物品。
drop_book()bool排队清空并掉落已存放的书本。
is_viewing_inventory(player)tablebool检测该玩家是否正在查看此道具所跟踪的容器界面。
set_persistent_data(key, value)string, stringbool在道具范围内的 fmm_lua_ 键下存储一个字符串。
get_persistent_data(key)stringstring/nil返回已存储的字符串,或 nil。

context.npc

EliteMobs NPC 脚本继承共享的 MagmaCore 上下文,并追加这张 NPC 专属表。

Properties

字段类型说明
namestring已配置的 NPC 显示名称。
filenamestringNPC 配置文件名。
uuidstring运行时 NPC UUID。
activation_radiusnumber已配置的激活半径。
current_locationtable位置快照,仅在承载的生物实体存在时出现。
entity_typestring大写的 Bukkit 实体类型,仅在承载的生物实体存在时出现。

Methods

方法参数返回值说明
is_valid()bool检测该 NPC 是否有效。
get_location()table返回当前 NPC 位置,回退到其出生位置。该表还包含一个 direction 向量。
get_eye_location()table返回当前眼部位置,回退到出生位置。该表还包含一个 direction 向量。
get_activation_radius()number返回当前已配置的激活半径。
get_nearby_players(radius)numbertable返回附近的 Player Table。
face_direction_or_location(target)tablenil面向某个向量方向,或朝向某个位置看去。
say_greeting(player?)table/string?nil发送已配置的问候语,可用时默认发给触发的玩家。接受玩家表、UUID 或名称。
say_dialog(player?)table/string?nil以相同的玩家解析方式发送已配置的对话。
say_farewell(player?)table/string?nil以相同的玩家解析方式发送已配置的告别语。
play_model_animation(name)stringnil当存在自定义模型时播放模型动画。

EliteMobs Power Entity Reference Table

对于抛射物、烟花、下落方块等非生物实体,EliteMobs Boss 能力方法会返回这张轻量表。

Properties

字段类型说明
namestring实体名称快照。
uuidstring实体 UUID。
entity_typestring大写的 Bukkit 实体类型快照。
is_playerbool恒为 false。
is_elitebool恒为 false。
is_mountbool除非某个 Boss 将返回的坐骑表标记为 true,否则为 false。
current_locationtable位置快照。

Methods

方法参数返回值说明
is_valid()bool检测实时有效性。
get_location()table返回实时位置。
get_velocity()table返回实时速度。
is_on_ground()bool检测实时的着地状态。
teleport_to_location(location)tablenil当位置可解析时传送。
set_velocity_vector(vector)tablenil当向量可解析时设置速度。
set_direction_vector(vector)tablenil适用时设置火球方向。
set_yield(amount)numbernil适用时设置火球威力。
set_gravity(enabled)boolnil设置重力。
detonate()nil当实体为烟花时引爆。
remove()nil移除该实体。
unregister(reason?=OTHER)string?=OTHERnil使用 DEATHPHASE_BOSS_RESETPHASE_BOSS_PHASE_ENDCHUNK_UNLOADWORLD_UNLOADSHUTDOWNEFFECT_TIMEOUTBOSS_TIMEOUTNPC_TIMEOUTOTHERUNSPECIFIED_WATCHDOG_REMOVALREMOVE_COMMANDKILL_COMMANDREINFORCEMENT_CULLENTITY_REPLACEMENTARENA_RESET 注销。
is_inside_vehicle()bool检测该实体是否正在乘坐载具。
has_vehicle()bool检测是否存在载具。
get_vehicle()table/nil返回当前载具引用。
set_vehicle(vehicle)tablebool让该实体乘坐已解析的载具。
leave_vehicle()bool离开当前载具。
has_passengers()bool检测是否存在乘客。
get_passenger_count()int返回乘客数量。
get_passengers()table返回乘客引用。
add_passenger(passenger)tablebool添加已解析的乘客。
remove_passenger(passenger)tablebool移除已解析的乘客。
eject_passengers()bool弹出每一位乘客。

EliteMobs Power Living Entity Table

EliteMobs Boss 能力的生物值使用这张独立的表;Boss 表和 EliteMobs Power Player 表都继承它。

Properties

字段类型说明
namestring实体名称快照。
uuidstring实体 UUID。
entity_typestring大写的 Bukkit 实体类型快照。
is_playerbool该实体是否为玩家。
is_monsterbool该实体是否实现了 Bukkit Monster
is_eliteboolEliteMobs 是否在跟踪该实体。
is_mountbool被跟踪的自定义 Boss 是否为坐骑。
is_validbool有效性快照。
healthnumber生命值快照。
maximum_healthnumber最大生命值快照。
current_locationtable位置快照。

Methods

方法参数返回值说明
is_alive()bool检测实时的有效性与死亡状态。
is_ai_enabled()bool返回实时的 AI 状态。
is_frozen()bool返回 EliteMobs 自定义 Boss 的冻结设置,或 false。
get_location()table返回实时位置。
get_eye_location()table返回实时眼部位置。
get_height()number返回 Bukkit 实体高度。
get_health()number返回实时生命值。
get_maximum_health()number返回实时最大生命值。
get_velocity()table返回实时速度。
deal_damage(amount)numbernil造成通用的 Bukkit 伤害。
deal_custom_damage(amount)numbernil以该能力所属 Boss 的名义造成 EliteMobs 自定义伤害。
deal_damage_from_boss(amount)numbernil造成归因于该能力所属 Boss 的 Bukkit 伤害。
restore_health(amount)numbernil被跟踪时通过 EliteMobs 治疗,否则将 Bukkit 生命值钳制到上限。
play_sound_at_entity(sound, volume_or_options?=1, pitch?=1)string (Sound), number/table?=1, number?=1nil在该实体处播放已注册音效或自定义命名空间音效。第二个参数也可以改为 {volume, pitch}
play_sound_at_self(sound, volume_or_options?=1, pitch?=1)string (Sound), number/table?=1, number?=1nil在该实体处播放的别名。第二个参数也可以改为 {volume, pitch}
spawn_particle_at_self(particle, count?=1)string (Particle)/table, int?=1nil在该实体处生成粒子字符串或粒子规格表。
spawn_particles_at_location(location, particle, count?=1, dx?=0, dy?=0, dz?=0, speed?=0)table, string (Particle), int?=1, number?=0, number?=0, number?=0, number?=0nil在某个位置生成粒子。
teleport_to_location(location)tablenil当位置可解析时传送。
set_velocity_vector(vector)tablenil当向量可解析时设置速度。
set_gravity(enabled)boolnil设置重力。
is_on_ground()bool检测实时的着地状态。
apply_push_vector(vector, additive?=false, delay?=1)table, bool?=false, int?=1nil延迟之后施加速度,可选择叠加到当前速度之上。
set_custom_name(name)stringnil设置经颜色处理的自定义名称。
reset_custom_name()nil被跟踪时还原 EliteMobs 名称,否则还原 Bukkit 名称。
set_custom_name_visible(visible)boolnil设置自定义名称的可见性。
set_ai_enabled(enabled, duration?=0)bool, int?=0nil设置 AI,并在正数 ticks 之后切换为相反状态。
set_awareness_enabled(enabled, duration?=0)bool, int?=0nil设置怪物感知,并在正数 ticks 之后切换为相反状态。
face_direction_or_location(target)tablenil面向某个向量或同世界的位置。
play_model_animation(name)stringnil可用时播放自定义模型动画。
set_scale(scale, duration?=0)number, int?=0nil设置缩放,并在正数 ticks 之后重置为 1.0
set_invulnerable(enabled, duration?=0)bool, int?=0nil使用 EliteMobs 时长辅助器设置无敌状态。
remove_elite()nil通过 EliteMobs 移除流程移除被跟踪的精英。
is_healing()bool检测被跟踪精英的治疗状态。
set_healing(enabled)boolnil设置被跟踪精英的治疗状态。
navigate_to_location(location, speed?=1, force?=false, timeout?=0)table, number?=1, bool?=false, int?=0nil让被跟踪的自定义 Boss 寻路。
add_tag(tag, duration?=0)string, int?=0nil添加一个标签,并在正数 ticks 之后移除。
remove_tag(tag)stringnil移除一个标签。
has_tag(tag)stringbool检测实体、精英或玩家标签。
push_relative_to(location, force?=1, extra_x?=0, extra_y?=0, extra_z?=0)table, number?=1, number?=0, number?=0, number?=0nil从源位置向外推开,并可附加偏移量。
overlaps_box_at_location(center, half_x?=0.5, half_y?=half_x, half_z?=half_x)table, number?=0.5, number?, number?bool检测实体碰撞箱与所请求的箱体是否相交。
is_inside_vehicle()bool检测该实体是否正在乘坐载具。
has_vehicle()bool检测是否存在载具。
get_vehicle()table/nil返回当前载具引用。
set_vehicle(vehicle)tablebool让该实体乘坐已解析的载具。
leave_vehicle()bool离开当前载具。
has_passengers()bool检测是否存在乘客。
get_passenger_count()int返回乘客数量。
get_passengers()table返回乘客引用。
add_passenger(passenger)tablebool添加已解析的乘客。
remove_passenger(passenger)tablebool移除已解析的乘客。
eject_passengers()bool弹出每一位乘客。
apply_potion_effect(type, duration, amplifier?=0)string (PotionEffectType), int, int?=0nil施加一个药水效果。
set_equipment(slot, material, options?)string (EquipmentSlot), string (Material), table?nil设置装备;options 支持 unbreakable,以及带 typelevelenchantments 条目。
set_fire_ticks(ticks)intnil设置着火 tick 数。
add_visual_freeze_ticks(ticks?=1)int?=1nil增加冰冻 tick 数。
place_temporary_block(material, ticks?=0, require_air?=false)string (Material), int?=0, bool?=falsenil在该实体处放置一个临时方块。

EliteMobs Power Player Table

EliteMobs Boss 能力的玩家值继承 EliteMobs Power Living Entity 的每一个属性和方法。

Properties

字段类型说明
game_modestring大写的 Bukkit 游戏模式快照。

Methods

方法参数返回值说明
send_message(text)stringnil发送经颜色处理的聊天文本。
show_action_bar(text)stringnil发送经颜色处理的动作栏。
show_title(title, subtitle?="", fade_in?=10, stay?=40, fade_out?=10)string, string?="", int?=10, int?=40, int?=10nil显示经颜色处理的标题。
show_boss_bar(title, color?=WHITE, style?=SOLID, duration?=40)string, string (BarColor)?=WHITE, string (BarStyle)?=SOLID, int?=40nil显示 Boss 血条,并在正数 ticks 之后移除。
run_command(command)stringnil以该玩家身份执行一条命令。

context.boss

EliteMobs Boss 能力会收到这张表,它继承 EliteMobs Power Living Entity 的每一个属性和方法,并用精英层面的语义覆盖此处列出的行。

Properties

字段类型说明
namestring精英显示名称或脚本文件名快照。
uuidstring精英 UUID。
healthnumber精英生命值快照。
maximum_healthnumber精英最大生命值快照。
current_locationtable精英位置快照。
levelint精英等级快照。
damager_countint伤害者数量快照。
is_in_combatbool战斗状态快照。
existsbool精英存在性快照。

Methods

方法参数返回值说明
is_alive()bool检测生物实体以及 EliteMobs 的存在状态。
get_health()number返回实时的精英生命值。
get_maximum_health()number返回实时的精英最大生命值。
get_location()table返回实时的精英位置。
restore_health(amount)numbernil通过 EliteMobs 实体进行治疗。
add_tag(tag, duration?=0)string, int?=0nil添加一个精英标签,并在正数 ticks 之后移除。
remove_tag(tag)stringnil移除一个精英标签。
has_tag(tag)stringbool检测一个精英标签。
reset_custom_name()nil还原精英显示名称。
play_sound_at_self(sound, volume_or_options?=1, pitch?=1)string (Sound), number/table?=1, number?=1nil在精英位置播放已注册音效或自定义命名空间音效。第二个参数也可以改为 {volume, pitch}
play_sound_at_entity(sound, volume_or_options?=1, pitch?=1)string (Sound), number/table?=1, number?=1nil在精英位置播放的别名。第二个参数也可以改为 {volume, pitch}
spawn_particle_at_self(particle, count?=1)string (Particle)/table, int?=1nil在精英位置生成粒子。
play_model_animation(name)stringnil可用时播放自定义 Boss 模型动画。
navigate_to_location(location, speed?=1, force?=false, timeout?=0)table, number?=1, bool?=false, int?=0nil让自定义 Boss 寻路。
get_damager_count()int返回实时的伤害者数量。
despawn()nilOTHER 原因移除该精英。
get_ender_dragon_phase()string/nil返回 EnderDragon.Phase 名称,或 nil。
set_ender_dragon_phase(phase)string (EnderDragon.Phase)nil设置一个有效的末影龙阶段。
has_mount()bool检测该 Boss 是否有存活的坐骑载具。
get_mount()table/nil返回标记了 is_mount = true 的坐骑引用。
set_mount(mount)tablebool让该 Boss 乘坐已解析的实体。
clear_mount()bool离开当前载具。
dismount()boolclear_mount() 的别名。
start_tracking_fireball_system(speed?=0.5)number?=0.5nil为怪物型 Boss 启动追踪火球行为。
handle_spirit_walk_damage(cause)string (DamageCause)nil运行 Spirit Walk 伤害处理。
shield_wall_is_active()bool检测护盾墙状态。
initialize_shield_wall(charges?=1)int?=1nil初始化护盾墙。
shield_wall_absorb_damage(player, damage)table, numberbool尝试吸收玩家伤害。
deactivate_shield_wall()nil停用护盾墙。
start_zombie_necronomicon(target, file)table, stringnil对某个生物目标启动 Zombie Necronomicon 处理。
send_message(text, range?=20)string, number?=20nil向范围内的玩家发送经颜色处理的文本。
get_nearby_players(range)numbertable返回附近的 EliteMobs Power Player 表。
get_target_player()table/nil当前怪物目标是玩家时返回该目标。
get_nearby_players_in_zone(zone)tabletable返回该区域内包含的玩家。
spawn_particles_in_zone(zone, particle, count?=1, dx?=0, dy?=0, dz?=0, speed?=0, coverage?=1)table, string (Particle), int?=1, number?=0, number?=0, number?=0, number?=0, number?=1nil对区域内部采样并生成粒子。
spawn_particles_in_zone_border(zone, particle, count?=1, dx?=0, dy?=0, dz?=0, speed?=0, coverage?=1)table, string (Particle), int?=1, number?=0, number?=0, number?=0, number?=0, number?=1nil对区域边缘采样并生成粒子。
get_particles_from_self_toward_zone(zone, particle, speed?=0.1)table, string (Particle), number?=0.1table构建从 Boss 指向采样区域点的定向粒子规格。
get_particles_toward_self(zone, particle, speed)table, string (Particle), numbertable构建指向 Boss 的定向粒子规格;当前的实时构建器会从最后一个传入参数读取 speed。
spawn_particles_with_vector(particles)tablenil生成一组定向粒子规格。
summon_reinforcement(file, zone_or_location?, level?=0)string, table?, int?=0table/nil在采样的区域点、某个位置或 Boss 处召唤增援。
summon_projectile(type, origin, destination, speed?=1, options?)string (EntityType), table, table, number?=1, table?table/nil生成一个抛射物;options 支持 custom_damagedetonation_poweryieldincendiarygravityglowinginvulnerablepersistentdurationEntityEffect effectspawn_at_origindirection_onlytrackon_landmax_ticks

context.players:EliteMobs Boss 能力

方法参数返回值说明
current_target()table/nil当事件行为者是玩家时返回该行为者,否则在 Boss 当前的怪物目标是玩家时返回该目标。
nearby_players(radius)numbertable返回 Boss 半径范围内的 Player Table。
all_players_in_world()table返回 Boss 当前世界中的所有 Player Table。

context.entities:EliteMobs Boss 能力

这些查询不包含 Boss 自身。生物过滤器接受 player/playerselite/elitesmob/mobs,或任意其他值以表示所有生物实体。

方法参数返回值说明
get_nearby_entities(radius, filter?="living")number, string?table返回半径范围内的实体。allentities 会包含非生物实体;其他过滤器返回生物表。
get_entities_in_box(center, half_x, half_y, half_z, filter?="living")table, number, number, number, string?table返回轴对齐箱体内部的生物实体。
get_all_entities(filter?="living")string?table返回 Boss 所在世界中匹配的生物实体。
get_direct_target_entity()table/nil返回当前钩子提供的直接目标。
get_boss_spawn_location()table返回 Boss 最初的出生位置。

context.vectors:EliteMobs Boss 能力

方法参数返回值说明
get_vector_between_locations(source, destination, options?)table, table, table?table返回同世界两个位置之间的向量;输入无效或跨世界时返回 {x=0,y=0,z=0}。options 支持 normalizemultiplier 和向量 offset
rotate_vector(vector, pitch?=0, yaw?=0)table, number?=0, number?=0table返回按 pitch 和 yaw(单位为度)旋转后的向量。
normalize_vector(vector)tabletable返回单位向量;零向量仍为零。

context.zones:EliteMobs Boss 能力

EliteMobs Boss 能力用 Elite Script 区域定义查询取代了共享的整数句柄区域接口。

方法参数返回值说明
get_entities_in_zone(zone, options?)table, table?table返回匹配的生物实体。options 支持 filter 以及 mode = "full""border"
get_locations_in_zone(zone, options?)table, table?table返回采样得到的位置。options 支持 coverage 以及 mode = "full""border"
zone_contains(zone, location, mode?="full")table, table, string?bool检测该位置是否位于完整形状内或边界上。
watch_zone(zone, callbacks, options?)table, table, table?nil使用 {on_enter, on_leave} 回调进行监视。options 支持 filtermode;所拥有的监视会随脚本一同停止。

context.script:EliteMobs Boss 能力

这个桥接层接受与 Elite Script 目标、区域和相对向量 YAML 配置相同的表键。

Methods

方法参数返回值说明
target(spec)tabletarget handle创建一个目标句柄。
zone(spec)tablezone handle创建一个区域句柄。
relative_vector(spec, location?, zone?)table, table?, zone handle?vector handle创建一个相对向量句柄,其动作位置默认为 Boss。
damage(target, amount?=0, multiplier?=1)target handle, number?=0, number?=1nil对每个解析出的目标实体造成伤害。
push(target, vector, additive?=false)target handle, table/vector handle, bool?=falsenil对解析出的目标实体施加速度。
set_facing(target, vector)target handle, table/vector handlenil让解析出的目标实体沿该向量朝向。
spawn_particles(target, particles)target handle, table/stringnil在解析出的目标位置生成该粒子规格。

目标句柄方法

方法参数返回值说明
entities()table解析并返回 Entity Table。
locations()table解析并返回位置表。
first_entity()table/nil返回第一个解析出的实体。
first_location()table/nil返回第一个解析出的位置。

区域句柄方法

方法参数返回值说明
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?="full")table, string?bool检测是否属于完整形状或边界。
watch(callbacks, mode?="full")table, string?int启动一个自己拥有的 {on_enter, on_leave} 监视并返回其任务 ID。

相对向量句柄方法

方法参数返回值说明
resolve()table为当前上下文解析该向量。

EliteMobs Power Event Table

EliteMobs Boss 能力的事件值会按事件类型有条件地暴露字段和方法。

Properties

字段类型说明
damage_amountnumber/nil伤害事件的数值快照。
damage_causestring/nil当伤害事件暴露该值时,为 DamageCause 名称。
damagertable/nil实体造成伤害事件中的伤害来源引用。
projectiletable/nil当伤害来源是抛射物时的抛射物引用。
spawn_reasonstring/nil精英生成原因。
entitytable/nil死亡或区域事件中的实体。

Methods

方法参数返回值说明
cancel_event()nil取消 EliteDamageEvent 或其他可取消事件。
set_damage_amount(amount)numbernil替换 EliteDamageEvent 的伤害值。
multiply_damage_amount(multiplier)numbernil乘算 EliteDamageEvent 的伤害值。

context.world:EliteMobs 追加与覆盖

EliteMobs Boss 能力继承 MagmaCore World Table 的每一行,并追加或覆盖下列方法。

Methods

方法参数返回值说明
play_sound_at_location(location, sound, volume?=1, pitch?=1)table, string (Sound), number?=1, number?=1nil覆盖版本,可通过 EliteMobs 支持接受已注册音效或自定义命名空间音效。
spawn_particle_at_location(location, particle, count?=1)table, string (Particle)/table, int?=1nil覆盖版本,可接受 EliteMobs 粒子规格表。
set_block_at_location(location, material, require_air?=false)table, string (Material), bool?=falsenil覆盖版本,使用 EliteMobs 临时方块放置且不设过期时间。
place_temporary_block_at_location(location, material, ticks?=0, require_air?=false)table, string (Material), int?=0, bool?=falsenil覆盖版本,使用 EliteMobs 临时方块放置。
get_block_type_at_location(location)tablestring/nil返回大写的 Material 名称;位置无效时返回 nil。
get_highest_block_y_at_location(location)tableint/nil覆盖版本,返回最高方块的 Y 坐标,或 nil。
get_blast_resistance_at_location(location)tablenumber返回方块的爆炸抗性;位置无效时默认为 0
is_air_at_location(location)tablebool检测目标方块是否为空气。
is_passable_at_location(location)tablebool检测 Bukkit 可通过性。
is_passthrough_at_location(location)tablebool检测该材质是否为非固体。
is_on_floor_at_location(location)tablebool检测目标为非固体且其下方为固体方块。
is_standing_on_material(location, material)table, string (Material)bool检测下方的方块。
strike_lightning_at_location(location)tablenil覆盖版本,在降下闪电之前启用 EliteMobs 闪电绕过机制。
run_empowered_lightning_task_at_location(location)tablenil运行强化末影龙闪电支持。
set_world_time(time) / set_world_time(location, time)int/table, int?nil设置 Boss 所在世界的时间,或所传位置所在世界的时间。
set_world_weather(weather, duration?=6000) / set_world_weather(location, weather, duration?=6000)string/table, string/int?, int?=6000nil设置 CLEARPRECIPITATIONRAINTHUNDER
run_console_command(command)stringnil以控制台身份派发一条命令。
spawn_boss_at_location(file, location?, level?)string, table?, int?table/nil在所传位置或当前位置、以所传等级或当前等级生成一个自定义 Boss。
spawn_custom_boss_at_location(file, location, options?)string, table, table?table/nil生成一个自定义 Boss;options 支持 silentleveladd_as_reinforcementvelocity
spawn_entity_at_location(type, location, options?)string (EntityType), table, table?table/nil生成一个原版实体;options 支持 velocitydurationEntityEffect effecton_landmax_ticks
spawn_falling_block_at_location(location, material, options?)table, string (Material), table?table/nil生成一个下落方块;options 支持 drop_itemhurt_entitiesvelocityon_land
spawn_reinforcement_at_location(file, location, level?=0, velocity?)string, table, int?=0, table?table/nil召唤一个与该 Boss 绑定的增援。
spawn_fireworks_at_location(location, options)table, tabletable/nil生成烟花;options 支持 effectstypeflickertrailcolorsfade_colorspowervelocityshot_at_angle,其中 type 使用 FireworkEffect.Type 名称。
spawn_splash_potion_at_location(location, options)table, tabletable/nil生成一瓶喷溅药水;effects 条目接受 PotionEffectTypetypedurationamplifieroverwrite,以及顶层的 velocity
generate_fake_explosion(locations, source?)table, table?nil为一组方块位置生成 EliteMobs 的假爆炸。
spawn_fake_gold_nugget_at_location(location, velocity, gravity?=false)table, table, bool?=falsetable/nil生成一个假金粒抛射物。
run_fake_gold_nugget_damage(projectiles)tablenil运行假抛射物的伤害判定。
generate_player_loot(times?=1)int?=1nil为符合条件的伤害者生成玩家战利品。
drop_bonus_coins(multiplier?=2)number?=2nil为符合条件的伤害者掉落额外金币。

EliteMobs Fake Projectile Table

当生成成功时,spawn_fake_gold_nugget_at_location 会返回这张表。

Methods

方法参数返回值说明
get_location()table返回假抛射物的位置。
set_gravity(enabled)boolnil设置假抛射物的重力。
remove()nil移除该假抛射物。
is_removed()bool检测它是否已被移除。

context.settings

EliteMobs Boss 能力会从同一个 world 表构建器收到这张设置表。

Methods

方法参数返回值说明
warning_visual_effects_enabled()bool返回当前的警告视觉特效设置。