Lua API 參考
本參考由實際運行中的 MagmaCore、FreeMinecraftModels 與 EliteMobs Lua 資料表建構器、增補器及執行時期情境解析器產生。
Entity Table
MagmaCore 的 entity table 是通用實體值的基礎;Living Entity、Player 與 FreeMinecraftModels Prop 資料表都繼承自它。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
uuid | string | 實體 UUID。 |
entity_type | string | 小寫的 Bukkit 實體型別。 |
is_valid | bool | 即時的有效性值。 |
is_dead | bool | 即時的死亡狀態。 |
current_location | table/nil | 即時的 {x, y, z, yaw, pitch, world} 位置。 |
world | string/nil | 即時的世界名稱。 |
is_player | bool | 該實體是否為玩家。 |
is_hostile | bool | 該實體是否實作 Bukkit Monster。 |
is_passive | bool | 該實體是否實作 Bukkit Animals。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
teleport(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 | 設定發光狀態。 |
Entity Table:EliteMobs 增補
實際運行的 EliteMobs 增補器會把這些值加到 MagmaCore entity table 上;只有在 is_elite 為 true 時 elite 才存在。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
is_elite | bool | EliteMobs 目前是否追蹤該實體。 |
is_custom_boss | bool | 被追蹤的 elite 是否為自訂 Boss。 |
is_significant_boss | bool | 是否為生命值倍率大於 1 的自訂 Boss。 |
elite | table/nil | 巢狀的即時 EliteMobs 資料,只有在成功解析出 elite 時才存在。 |
elite.level | int | Elite 等級快照。 |
elite.name | string/nil | Elite 顯示名稱快照。 |
elite.health | number | 即時生命值。 |
elite.max_health | number | 即時最大生命值。 |
elite.is_custom_boss | bool | 該 elite 是否為自訂 Boss。 |
elite.health_multiplier | number | 已設定的生命值倍率快照。 |
elite.damage_multiplier | number | 已設定的傷害倍率快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
elite.remove() | — | nil | 透過 EliteMobs 的移除流程移除該 elite。 |
Entity Table:FreeMinecraftModels 增補
實際運行的 FreeMinecraftModels 增補器會加入這些值;只有在 is_modeled 為 true 時 model 才存在,而僅限玩家的值只會出現在玩家資料表上。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
is_modeled | bool | FreeMinecraftModels 是否解析出一個帶模型的實體。 |
is_prop | bool | 該實體是否為以盔甲座為基底的 FreeMinecraftModels prop。 |
model | table/nil | 巢狀模型資料,只有在帶模型的實體上才存在。 |
model.model_id | string/nil | 模型藍圖識別碼。 |
model.is_dynamic | bool | 該帶模型實體是否為動態。 |
is_op | bool | 僅限玩家的伺服器管理員狀態。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
model.play_animation(name, blend?=false, loop?=false) | string, bool?=false, bool?=false | bool | 播放模型動畫並回傳是否已啟動。 |
model.stop_animations() | — | nil | 停止目前所有的模型動畫。 |
model.remove() | — | nil | 移除該帶模型的實體。 |
has_permission(node) | string | bool | 僅限玩家的權限檢查。 |
Living Entity Table
MagmaCore 的 living entity table 繼承 Entity Table 的每一個屬性與方法。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
health | number | 即時生命值。 |
maximum_health | number | 即時最大生命值。 |
name | string/nil | 即時的 Bukkit 實體名稱。 |
is_alive | bool | Bukkit 死亡狀態的即時反向值。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
damage(amount) | number | nil | 造成 Bukkit 傷害。 |
push(x, y, z) | number, number, number | nil | 將一個向量加到目前的速度上。 |
set_facing(x, y, z) | number, number, number | nil | 面向某個方向向量。 |
add_potion_effect(type, duration, amplifier) | string(PotionEffectType), int, int | nil | 在型別可解析時加入藥水效果。 |
remove_potion_effect(type) | string(PotionEffectType) | nil | 在型別可解析時移除藥水效果。 |
get_scale() | — | number | 回傳縮放屬性,無法取得時回傳 1.0。 |
set_scale(value) | number | nil | 在伺服器支援時設定縮放屬性。 |
Player Table
MagmaCore 的 player table 繼承 Living Entity Table 的每一個屬性與方法。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
game_mode | string | 小寫的 Bukkit 遊戲模式快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
send_message(text) | string | nil | 傳送經由 MagmaCore 顏色解析器處理過的文字。 |
get_held_item() | — | table/nil | 回傳主手物品的 {type, amount, display_name},空手時回傳 nil。 |
consume_held_item(amount?=1) | int?=1 | nil | 排入減少主手堆疊數量的作業。 |
has_item(material, amount?=1) | string(Material), int?=1 | bool | 測試背包中是否含有指定數量。 |
get_target_entity(range?=50) | number?=50 | table/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?=-1 | bool | 傳送僅客戶端可見的方塊,並可在正值 tick 後還原;無效或非方塊材質會回傳 false。 |
reset_block(x, y, z) | int, int, int | bool | 排入為此玩家還原真實方塊的作業。 |
sleep(x, y, z) | number, number, number | nil | 排入強制睡眠動畫,並在醒來後還原被取代的方塊。 |
wake_up() | — | nil | 排入在玩家睡眠時將其喚醒的作業。 |
show_boss_bar(text, color?=WHITE, progress, ticks?=-1) | string, string(BarColor)?=WHITE, number, int?=-1 | nil | 取代玩家目前的實心 Boss 血條,並可在正值 tick 後隱藏。 |
hide_boss_bar() | — | nil | 移除玩家目前的 Lua Boss 血條。 |
show_action_bar(text, ticks?=-1) | string, int?=-1 | nil | 傳送一次,或每 40 tick 重複一次直到正值持續時間結束。 |
show_title(title, subtitle?="", fade_in, stay, fade_out) | string, string?="", int, int, int | nil | 顯示標題,標題與副標題文字皆經過顏色處理。 |
World Table
MagmaCore 的 world table 以 context.world 形式提供;EliteMobs Boss 能力會繼承它並套用後文所述的覆寫。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
name | string | 世界名稱快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
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 | 排入放置方塊的作業;無效材質回傳 false,未載入的區塊會被排入的工作略過。 |
get_highest_block_y(x, z) | int, int | int | 回傳最高方塊的 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?=0 | nil | 生成粒子;無效名稱不會有任何作用。 |
play_sound(sound, x, y, z, volume?=1, pitch?=1) | string(Sound), number, number, number, number?=1, number?=1 | nil | 播放已註冊的音效,或小寫的具命名空間資源包音效鍵。 |
strike_lightning(x, y, z) | number, number, number | nil | 降下閃電。 |
get_time() | — | int | 以 tick 回傳世界時間。 |
set_time(ticks) | int | nil | 設定世界時間。 |
get_nearby_entities(x, y, z, radius) | number, number, number, number | table | 回傳附近的 Entity 或 Living Entity 資料表。 |
get_nearby_players(x, y, z, radius) | number, number, number, number | table | 回傳附近的 Player 資料表。 |
spawn_entity(type, x, y, z) | string(EntityType), number, number, number | table/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?=50 | table | 回傳 hit_entity、hit_location 與 hit_block 值。 |
place_temporary_block(x, y, z, material, ticks?=0, require_air?=false) | int, int, int, string(Material), int?=0, bool?=false | bool | 放置暫時方塊;無效材質或未載入的區塊回傳 false。 |
drop_item(x, y, z, material, amount?=1) | number, number, number, string(Material), int?=1 | table/nil | 自然掉落物品並回傳其 Entity Table;無效材質回傳 nil。 |
spawn_firework(x, y, z, colors, type?=BALL, power?=1) | number, number, number, table, string(FireworkEffect.Type)?=BALL, int?=1 | nil | 排入使用 Bukkit Color 常數名稱的煙火;若沒有任何名稱可解析則預設為白色。 |
strike_lightning_at_location(location) | table | nil | 在位置表所屬的世界中降下閃電。 |
play_sound_at_location(location, sound, volume?=1, pitch?=1) | table, string(Sound), number?=1, number?=1 | nil | 播放已註冊的音效,或小寫的具命名空間資源包音效鍵。 |
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?=0 | nil | 在位置表所屬的世界中生成粒子。 |
get_block_at_location(location) | table | string | 回傳小寫材質名稱;位置無效或區塊未載入時回傳 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?=false | bool | 在位置表所屬的世界中放置暫時方塊。 |
get_highest_block_y_at_location(location) | table | int/nil | 回傳最高方塊的 Y 值;位置無效時回傳 nil。 |
context.world:FreeMinecraftModels 新增功能
FreeMinecraftModels 會把這些方法註冊到它自己的 MagmaCore world table 上,因此它們會出現在 FreeMinecraftModels 物品腳本與 prop 腳本的 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.x | number | em.create_location 回傳的 X 座標。 |
location.y | number | em.create_location 回傳的 Y 座標。 |
location.z | number | em.create_location 回傳的 Z 座標。 |
location.world | string/nil | 提供給 em.create_location 時的世界名稱。 |
location.yaw | number/nil | 提供給 em.create_location 時的 yaw。 |
location.pitch | number/nil | 提供給 em.create_location 時的 pitch。 |
vector.x | number | em.create_vector 回傳的 X 分量。 |
vector.y | number | em.create_vector 回傳的 Y 分量。 |
vector.z | number | em.create_vector 回傳的 Z 分量。 |
zone.kind | string | sphere、dome、cylinder、cuboid、cone、static_ray、rotating_ray 或 translating_ray。 |
zone.radius | number/nil | 球體、半球、圓柱或圓錐的半徑。 |
zone.height | number/nil | 圓柱高度。 |
zone.x | number/nil | 長方體的 X 尺寸。 |
zone.y | number/nil | 長方體的 Y 尺寸。 |
zone.z | number/nil | 長方體的 Z 尺寸。 |
zone.length | number/nil | 圓錐或射線的長度。 |
zone.thickness | number/nil | 靜態射線的粗細。 |
zone.point_radius | number/nil | 旋轉或平移射線的點半徑。 |
zone.animation_duration | number/nil | 旋轉或平移射線的動畫持續時間。 |
zone.origin | table/nil | 由 set_center 或 set_origin 設定的位置。 |
zone.destination | table/nil | 由 set_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, number | table | 回傳一個 {x, y, z} 向量表。 |
location.add(dx?=0, dy?=0, dz?=0) | number?=0, number?=0, number?=0 | table | 就地相加並回傳同一個位置表。 |
em.zone.create_sphere_zone(radius) | number | table | 回傳帶有 set_center(location) 的球體定義。 |
em.zone.create_dome_zone(radius) | number | table | 回傳帶有 set_center(location) 的半球定義。 |
em.zone.create_cylinder_zone(radius, height) | number, number | table | 回傳帶有 set_center(location) 的圓柱定義。 |
em.zone.create_cuboid_zone(x, y, z) | number, number, number | table | 回傳帶有 set_center(location) 的長方體定義。 |
em.zone.create_cone_zone(length, radius) | number, number | table | 回傳帶有 set_origin(location) 與 set_destination(location) 的圓錐定義。 |
em.zone.create_static_ray_zone(length, thickness) | number, number | table | 回傳帶有起點與終點設定器的靜態射線定義。 |
em.zone.create_rotating_ray_zone(length, point_radius, animation_duration) | number, number, number | table | 回傳帶有起點與終點設定器的旋轉射線定義。 |
em.zone.create_translating_ray_zone(length, point_radius, animation_duration) | number, number, number | table | 回傳帶有起點與終點設定器的平移射線定義。 |
zone.set_center(location) | table | table | 將中心設為 zone.origin 並回傳同一個 zone 表。 |
zone.set_origin(location) | table | table | 設定起點並回傳同一個 zone 表。 |
zone.set_destination(location) | table | table | 設定終點並回傳同一個 zone 表。 |
em.location.is_in_dungeon(location) | table | bool | 測試已註冊的地下城區域,以及回報 dungeon 類型的擁有者。 |
em.location.is_protected(location) | table | bool | 測試內建的 WorldGuard/GriefPrevention 轉接器,以及外掛程式註冊的保護擁有者。 |
em.location.owned_by(location, namespace) | table, string | bool | 測試某個外掛程式命名空間的擁有權。 |
em.location.owners(location) | table | table | 回傳擁有者命名空間字串的陣列。 |
em.location.kinds_at(location) | table | table | 回傳擁有權類型字串的陣列。 |
em.location.has_kind(location, kind) | table, string | bool | 測試某個擁有權類型。 |
context.state
每個 MagmaCore 腳本實例都會取得一個純 Lua 資料表,其生命週期與該實例相同。可用於計數器、旗標、工作 ID,以及在各掛鉤之間共用的值。
context.state.counter = (context.state.counter or 0) + 1
context.log
MagmaCore、FreeMinecraftModels 與 EliteMobs NPC 方法
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
info(message) | string | nil | 以共用的 Lua 前綴記錄一則資訊訊息。 |
warn(message) | string | nil | 記錄一則警告。 |
error(message) | string | nil | 透過共用的警告頻道記錄。 |
EliteMobs Boss 能力方法
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
info(message) | string | nil | 記錄一則 Boss 能力的資訊訊息。 |
warn(message) | string | nil | 記錄一則警告。 |
debug(message) | string | nil | 以 Lua 能力除錯前綴記錄一則資訊訊息。 |
context.scheduler
排程工作屬於該腳本實例,並會在其關閉時被取消。下列兩套命名家族在共用的 MagmaCore 介面與 EliteMobs Boss 能力上都可使用。
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
run_later(ticks, callback) | int, function | int | 延遲後執行一次並回傳 Bukkit 工作 ID。 |
run_repeating(delay, interval, callback) | int, int, function | int | 在初始延遲後重複執行並回傳工作 ID。 |
cancel(task_id) | int | nil | 取消自己擁有的工作。 |
run_after(ticks, callback) | int, function | int | run_later 的別名。 |
run_every(interval, callback) | int, function | int | 不含初始延遲地重複執行並回傳工作 ID。 |
cancel_task(task_id) | int | nil | cancel 的別名。 |
context.cooldowns
區域冷卻以單一腳本擁有者與定義為索引鍵;全域冷卻則由同一擁有者共用。省略區域索引鍵時會使用 __lua: 加上腳本檔名。EliteMobs Boss 能力提供相同的方法名稱,但區域值使用該 Boss 的共用冷卻儲存區,全域值則使用其內建的能力冷卻。
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
local_ready(key?) | string? | bool | 測試指定索引鍵的區域冷卻是否已就緒。 |
local_remaining(key?) | string? | int | 回傳剩餘 tick 數;已就緒時回傳 0。 |
check_local(key, duration) | string/nil, int | bool | 若已就緒則啟動冷卻並回傳 true。傳入 nil 可使用預設索引鍵。 |
set_local(duration, key?) | int, string? | nil | 設定或清除區域冷卻;非正值的持續時間會清除它。 |
global_ready() | — | bool | 測試該擁有者的全域冷卻是否已就緒。 |
set_global(duration) | int | nil | 以 tick 設定全域冷卻。在共用的 MagmaCore 介面上,非正值的持續時間會清除它。 |
context.zones:共用的 MagmaCore 介面
FreeMinecraftModels 腳本、EliteMobs NPC 腳本,以及其他預設的 MagmaCore 使用者,會在目前腳本擁有者所在的世界中取得整數型的 zone 控制代碼。
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
create_sphere(x, y, z, radius) | number, number, number, number | int/nil | 註冊一個球體並回傳其控制代碼;若擁有者沒有世界則回傳 nil。 |
create_cylinder(x, y, z, radius, height) | number, number, number, number, number | int/nil | 註冊一個圓柱並回傳其控制代碼;若擁有者沒有世界則回傳 nil。 |
create_cuboid(x, y, z, x_size, y_size, z_size) | number, number, number, number, number, number | int/nil | 註冊一個長方體並回傳其控制代碼;若擁有者沒有世界則回傳 nil。 |
watch(handle, on_enter?, on_leave?) | int, function?, function? | bool/nil | 為已知的控制代碼啟用邊界追蹤。函式存在與否會決定是否啟用對應的 on_zone_enter 或 on_zone_leave 掛鉤;所提供的函式主體不會被直接呼叫。 |
unwatch(handle) | int | nil | 停止追蹤並移除該控制代碼。 |
通用的 zone 掛鉤會透過 context.player 與 context.event.player 公開穿越邊界的玩家。
context.event:共用的 MagmaCore 介面
只要共用掛鉤有目前的 Bukkit 事件或行為者,此資料表就會存在。它不會出現在排程回呼中,也不會出現在兩者皆無的掛鉤中。
| 欄位或方法 | 型別 | 說明 |
|---|---|---|
is_cancelled | bool | 建構情境表時所擷取的取消狀態;呼叫 cancel() 或 uncancel() 並不會更新此欄位。 |
cancel() | method | 取消目前的事件。僅在該事件實作 Bukkit Cancellable 時存在。 |
uncancel() | method | 取消目前事件的取消狀態。僅在該事件實作 Bukkit Cancellable 時存在。 |
player | table | 目前行為者的 Living Entity Table(若有)。 |
通用的 zone 掛鉤提供行為者但沒有可取消的 Bukkit 事件,因此它們會公開 is_cancelled = false 與 player,但不含 cancel() 或 uncancel()。
context.item
FreeMinecraftModels 物品腳本會為相符的已裝備腳本化物品取得此資料表。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
id | string | 腳本化物品的識別碼。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
material() | — | string/nil | 回傳大寫的 Material 名稱;物品未裝備時回傳 nil。 |
get_amount() | — | int | 回傳堆疊數量;未裝備時回傳 0。 |
set_amount(amount) | int | nil | 排入設定堆疊數量的作業。 |
consume(amount?=1) | int?=1 | nil | 排入減少堆疊數量的作業。 |
get_uses() | — | int | 回傳持久化的使用次數計數器,預設為 0。 |
set_uses(uses) | int | nil | 排入設定持久化使用次數計數器的作業。 |
get_durability() | — | table/nil | 回傳 {current, max};物品沒有耐久條時回傳 nil。 |
get_durability_percentage() | — | number/nil | 回傳從 0.0 到 1.0 的剩餘耐久度,或 nil。 |
use_durability(amount, can_break?=false) | int, bool?=false | nil | 排入套用固定耐久傷害的作業,除非允許損壞,否則會夾在剩餘一點。 |
use_durability_percentage(fraction, can_break?=false) | number, bool?=false | nil | 排入套用相當於最大耐久度某比例之耐久傷害的作業。 |
get_name() | — | string/nil | 回傳顯示名稱;不存在時回傳 nil。 |
set_name(name) | string | nil | 排入設定經顏色處理之顯示名稱的作業。 |
get_lore() | — | table | 回傳 lore 字串的陣列。 |
set_lore(lore) | table | nil | 排入設定經顏色處理之 lore 字串的作業。 |
context.prop
FreeMinecraftModels prop 腳本會取得此資料表;當存在支援它的實體時,它會繼承 MagmaCore Entity Table。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
model_id | string/nil | 模型藍圖名稱;沒有藍圖時回傳 nil。 |
current_location | table/nil | 即時的 prop 位置。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
play_animation(name, blend?=true, loop?=true) | string, bool?=true, bool?=true | bool | 播放指定名稱的動畫。 |
stop_animation() | — | nil | 停止目前所有的動畫。 |
hurt_visual() | — | nil | 播放紅色染色的受傷視覺效果,但不造成傷害。 |
pickup() | — | nil | 排入永久移除並掉落放置用物品的作業。 |
has_mount_points() | — | bool | 測試該 prop 是否具有騎乘點骨骼。 |
mount(player) | table | bool | 排入讓已解析的玩家騎乘到第一個可用座位的作業。 |
dismount(player) | table | bool | 排入讓已解析的玩家從此 prop 上下來的作業。 |
get_passengers() | — | table | 回傳已騎乘玩家的 Entity Table。 |
spawn_elitemobs_boss(file, x, y, z) | string, number, number, number | table/nil | 在 EliteMobs 啟用時生成一個 EliteMobs 自訂 Boss。 |
open_inventory(player, title, rows?=3) | table, string, int?=3 | bool | 排入開啟持久化儲存空間的作業,列數會被夾在 1 到 6 之間。 |
place_book(player) | table | bool | 當 prop 尚未存放書本時,排入存放一本手持之成書或書與筆的作業。 |
read_book(player) | table | bool | 排入開啟已存放成書的作業。 |
take_book(player) | table | bool | 排入將已存放的書本歸還給玩家的作業。 |
has_book() | — | bool | 測試該 prop 是否存放著書本。 |
drop_inventory() | — | bool | 排入清空持久化儲存空間並掉落其中物品的作業。 |
drop_book() | — | bool | 排入清除並掉落已存放書本的作業。 |
is_viewing_inventory(player) | table | bool | 測試該玩家是否正在檢視此 prop 所追蹤的容器。 |
set_persistent_data(key, value) | string, string | bool | 在 prop 範圍的 fmm_lua_ 索引鍵下儲存一個字串。 |
get_persistent_data(key) | string | string/nil | 回傳已儲存的字串,或 nil。 |
context.npc
EliteMobs NPC 腳本會繼承共用的 MagmaCore 情境,並加入這個 NPC 專屬的資料表。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
name | string | 已設定的 NPC 顯示名稱。 |
filename | string | NPC 設定檔的檔名。 |
uuid | string | 執行時期的 NPC UUID。 |
activation_radius | number | 已設定的啟用半徑。 |
current_location | table | 位置快照,只有在支援它的生物實體存在時才有。 |
entity_type | string | 大寫的 Bukkit 實體型別,只有在支援它的生物實體存在時才有。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
is_valid() | — | bool | 測試該 NPC 是否有效。 |
get_location() | — | table | 回傳目前的 NPC 位置,若無則退回其生成位置。該資料表也包含一個 direction 向量。 |
get_eye_location() | — | table | 回傳目前的視線位置,若無則退回生成位置。該資料表也包含一個 direction 向量。 |
get_activation_radius() | — | number | 回傳目前設定的啟用半徑。 |
get_nearby_players(radius) | number | table | 回傳附近的 Player Table。 |
face_direction_or_location(target) | table | nil | 面向一個向量方向,或朝某個位置看去。 |
say_greeting(player?) | table/string? | nil | 傳送已設定的問候語;若有觸發玩家則預設為該玩家。可接受玩家資料表、UUID 或名稱。 |
say_dialog(player?) | table/string? | nil | 以相同的玩家解析方式傳送已設定的對話。 |
say_farewell(player?) | table/string? | nil | 以相同的玩家解析方式傳送已設定的道別語。 |
play_model_animation(name) | string | nil | 當存在自訂模型時播放模型動畫。 |
EliteMobs 能力實體參考資料表
EliteMobs Boss 能力方法會為投射物、煙火與掉落方塊等非生物實體回傳這個輕量資料表。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
name | string | 實體名稱快照。 |
uuid | string | 實體 UUID。 |
entity_type | string | 大寫的 Bukkit 實體型別快照。 |
is_player | bool | 永遠為 false。 |
is_elite | bool | 永遠為 false。 |
is_mount | bool | 除非某個 Boss 將回傳的坐騎資料表標記為 true,否則為 false。 |
current_location | table | 位置快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
is_valid() | — | bool | 測試即時有效性。 |
get_location() | — | table | 回傳即時位置。 |
get_velocity() | — | table | 回傳即時速度。 |
is_on_ground() | — | bool | 測試即時的著地狀態。 |
teleport_to_location(location) | table | nil | 位置可解析時進行傳送。 |
set_velocity_vector(vector) | table | nil | 向量可解析時設定速度。 |
set_direction_vector(vector) | table | nil | 適用時設定火球方向。 |
set_yield(amount) | number | nil | 適用時設定火球威力。 |
set_gravity(enabled) | bool | nil | 設定重力。 |
detonate() | — | nil | 當該實體為煙火時引爆。 |
remove() | — | nil | 移除該實體。 |
unregister(reason?=OTHER) | string?=OTHER | nil | 以 DEATH、PHASE_BOSS_RESET、PHASE_BOSS_PHASE_END、CHUNK_UNLOAD、WORLD_UNLOAD、SHUTDOWN、EFFECT_TIMEOUT、BOSS_TIMEOUT、NPC_TIMEOUT、OTHER、UNSPECIFIED_WATCHDOG_REMOVAL、REMOVE_COMMAND、KILL_COMMAND、REINFORCEMENT_CULL、ENTITY_REPLACEMENT 或 ARENA_RESET 取消註冊。 |
is_inside_vehicle() | — | bool | 測試該實體是否正在乘坐載具。 |
has_vehicle() | — | bool | 測試是否存在載具。 |
get_vehicle() | — | table/nil | 回傳目前的載具參考。 |
set_vehicle(vehicle) | table | bool | 讓此實體乘坐已解析的載具。 |
leave_vehicle() | — | bool | 離開目前的載具。 |
has_passengers() | — | bool | 測試是否存在乘客。 |
get_passenger_count() | — | int | 回傳乘客數量。 |
get_passengers() | — | table | 回傳乘客參考。 |
add_passenger(passenger) | table | bool | 加入已解析的乘客。 |
remove_passenger(passenger) | table | bool | 移除已解析的乘客。 |
eject_passengers() | — | bool | 彈出所有乘客。 |
EliteMobs 能力生物實體資料表
EliteMobs Boss 能力的生物值使用這個獨立的資料表;Boss 資料表與 EliteMobs 能力玩家資料表都繼承自它。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
name | string | 實體名稱快照。 |
uuid | string | 實體 UUID。 |
entity_type | string | 大寫的 Bukkit 實體型別快照。 |
is_player | bool | 該實體是否為玩家。 |
is_monster | bool | 該實體是否實作 Bukkit Monster。 |
is_elite | bool | EliteMobs 是否追蹤該實體。 |
is_mount | bool | 被追蹤的自訂 Boss 是否為坐騎。 |
is_valid | bool | 有效性快照。 |
health | number | 生命值快照。 |
maximum_health | number | 最大生命值快照。 |
current_location | table | 位置快照。 |
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) | number | nil | 造成一般的 Bukkit 傷害。 |
deal_custom_damage(amount) | number | nil | 以該能力所屬 Boss 的名義造成 EliteMobs 自訂傷害。 |
deal_damage_from_boss(amount) | number | nil | 造成歸屬於該能力所屬 Boss 的 Bukkit 傷害。 |
restore_health(amount) | number | nil | 被追蹤時透過 EliteMobs 治療,否則將 Bukkit 生命值夾至最大值。 |
play_sound_at_entity(sound, volume_or_options?=1, pitch?=1) | string(Sound), number/table?=1, number?=1 | nil | 在該實體處播放已註冊或自訂的具命名空間音效。第二個參數也可改為 {volume, pitch}。 |
play_sound_at_self(sound, volume_or_options?=1, pitch?=1) | string(Sound), number/table?=1, number?=1 | nil | 在該實體處播放的別名。第二個參數也可改為 {volume, pitch}。 |
spawn_particle_at_self(particle, count?=1) | string(Particle)/table, int?=1 | nil | 在該實體處生成粒子字串或粒子規格表。 |
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?=0 | nil | 在某個位置生成粒子。 |
teleport_to_location(location) | table | nil | 位置可解析時進行傳送。 |
set_velocity_vector(vector) | table | nil | 向量可解析時設定速度。 |
set_gravity(enabled) | bool | nil | 設定重力。 |
is_on_ground() | — | bool | 測試即時的著地狀態。 |
apply_push_vector(vector, additive?=false, delay?=1) | table, bool?=false, int?=1 | nil | 延遲後套用速度,並可選擇疊加到目前速度上。 |
set_custom_name(name) | string | nil | 設定經顏色處理的自訂名稱。 |
reset_custom_name() | — | nil | 被追蹤時還原 EliteMobs 名稱,否則還原 Bukkit 名稱。 |
set_custom_name_visible(visible) | bool | nil | 設定自訂名稱的可見性。 |
set_ai_enabled(enabled, duration?=0) | bool, int?=0 | nil | 設定 AI,並在正值 tick 後切換為相反狀態。 |
set_awareness_enabled(enabled, duration?=0) | bool, int?=0 | nil | 設定生物的感知能力,並在正值 tick 後切換為相反狀態。 |
face_direction_or_location(target) | table | nil | 面向一個向量或同世界的位置。 |
play_model_animation(name) | string | nil | 可用時播放自訂模型動畫。 |
set_scale(scale, duration?=0) | number, int?=0 | nil | 設定縮放,並在正值 tick 後重設為 1.0。 |
set_invulnerable(enabled, duration?=0) | bool, int?=0 | nil | 使用 EliteMobs 的持續時間輔助功能設定無敵。 |
remove_elite() | — | nil | 透過 EliteMobs 的移除流程移除被追蹤的 elite。 |
is_healing() | — | bool | 測試被追蹤 elite 的治療狀態。 |
set_healing(enabled) | bool | nil | 設定被追蹤 elite 的治療狀態。 |
navigate_to_location(location, speed?=1, force?=false, timeout?=0) | table, number?=1, bool?=false, int?=0 | nil | 讓被追蹤的自訂 Boss 進行導航。 |
add_tag(tag, duration?=0) | string, int?=0 | nil | 加入一個標籤,並在正值 tick 後移除它。 |
remove_tag(tag) | string | nil | 移除一個標籤。 |
has_tag(tag) | string | bool | 測試實體、elite 或玩家標籤。 |
push_relative_to(location, force?=1, extra_x?=0, extra_y?=0, extra_z?=0) | table, number?=1, number?=0, number?=0, number?=0 | nil | 從某個來源位置向外推開,並可加上額外偏移量。 |
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) | table | bool | 讓此實體乘坐已解析的載具。 |
leave_vehicle() | — | bool | 離開目前的載具。 |
has_passengers() | — | bool | 測試是否存在乘客。 |
get_passenger_count() | — | int | 回傳乘客數量。 |
get_passengers() | — | table | 回傳乘客參考。 |
add_passenger(passenger) | table | bool | 加入已解析的乘客。 |
remove_passenger(passenger) | table | bool | 移除已解析的乘客。 |
eject_passengers() | — | bool | 彈出所有乘客。 |
apply_potion_effect(type, duration, amplifier?=0) | string(PotionEffectType), int, int?=0 | nil | 套用一個藥水效果。 |
set_equipment(slot, material, options?) | string(EquipmentSlot), string(Material), table? | nil | 設定裝備;options 支援 unbreakable 以及帶有 type 與 level 的 enchantments 項目。 |
set_fire_ticks(ticks) | int | nil | 設定燃燒 tick 數。 |
add_visual_freeze_ticks(ticks?=1) | int?=1 | nil | 增加冰凍 tick 數。 |
place_temporary_block(material, ticks?=0, require_air?=false) | string(Material), int?=0, bool?=false | nil | 在該實體處放置一個暫時方塊。 |
EliteMobs 能力玩家資料表
EliteMobs Boss 能力的玩家值繼承 EliteMobs 能力生物實體的每一個屬性與方法。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
game_mode | string | 大寫的 Bukkit 遊戲模式快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
send_message(text) | string | nil | 傳送經顏色處理的聊天文字。 |
show_action_bar(text) | string | nil | 傳送經顏色處理的動作列訊息。 |
show_title(title, subtitle?="", fade_in?=10, stay?=40, fade_out?=10) | string, string?="", int?=10, int?=40, int?=10 | nil | 顯示經顏色處理的標題。 |
show_boss_bar(title, color?=WHITE, style?=SOLID, duration?=40) | string, string(BarColor)?=WHITE, string(BarStyle)?=SOLID, int?=40 | nil | 顯示 Boss 血條,並在正值 tick 後移除。 |
run_command(command) | string | nil | 以該玩家的身分執行指令。 |
context.boss
EliteMobs Boss 能力會取得此資料表;它繼承 EliteMobs 能力生物實體的每一個屬性與方法,並以 elite 層級的語意覆寫此處列出的項目。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
name | string | Elite 顯示名稱或腳本檔名的快照。 |
uuid | string | Elite UUID。 |
health | number | Elite 生命值快照。 |
maximum_health | number | Elite 最大生命值快照。 |
current_location | table | Elite 位置快照。 |
level | int | Elite 等級快照。 |
damager_count | int | 傷害者數量快照。 |
is_in_combat | bool | 戰鬥狀態快照。 |
exists | bool | Elite 是否存在的快照。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
is_alive() | — | bool | 測試生物實體與 EliteMobs 的存在狀態。 |
get_health() | — | number | 回傳即時的 elite 生命值。 |
get_maximum_health() | — | number | 回傳即時的 elite 最大生命值。 |
get_location() | — | table | 回傳即時的 elite 位置。 |
restore_health(amount) | number | nil | 透過 EliteMobs 實體進行治療。 |
add_tag(tag, duration?=0) | string, int?=0 | nil | 加入一個 elite 標籤,並在正值 tick 後移除。 |
remove_tag(tag) | string | nil | 移除一個 elite 標籤。 |
has_tag(tag) | string | bool | 測試某個 elite 標籤。 |
reset_custom_name() | — | nil | 還原 elite 的顯示名稱。 |
play_sound_at_self(sound, volume_or_options?=1, pitch?=1) | string(Sound), number/table?=1, number?=1 | nil | 在 elite 位置播放已註冊或自訂的具命名空間音效。第二個參數也可改為 {volume, pitch}。 |
play_sound_at_entity(sound, volume_or_options?=1, pitch?=1) | string(Sound), number/table?=1, number?=1 | nil | 在 elite 位置播放的別名。第二個參數也可改為 {volume, pitch}。 |
spawn_particle_at_self(particle, count?=1) | string(Particle)/table, int?=1 | nil | 在 elite 位置生成粒子。 |
play_model_animation(name) | string | nil | 可用時播放自訂 Boss 的模型動畫。 |
navigate_to_location(location, speed?=1, force?=false, timeout?=0) | table, number?=1, bool?=false, int?=0 | nil | 讓自訂 Boss 進行導航。 |
get_damager_count() | — | int | 回傳即時的傷害者數量。 |
despawn() | — | nil | 以原因 OTHER 移除該 elite。 |
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) | table | bool | 讓該 Boss 乘坐已解析的實體。 |
clear_mount() | — | bool | 離開目前的載具。 |
dismount() | — | bool | clear_mount() 的別名。 |
start_tracking_fireball_system(speed?=0.5) | number?=0.5 | nil | 為怪物型 Boss 啟動追蹤火球行為。 |
handle_spirit_walk_damage(cause) | string(DamageCause) | nil | 執行 Spirit Walk 的傷害處理。 |
shield_wall_is_active() | — | bool | 測試護盾牆狀態。 |
initialize_shield_wall(charges?=1) | int?=1 | nil | 初始化護盾牆。 |
shield_wall_absorb_damage(player, damage) | table, number | bool | 嘗試吸收玩家傷害。 |
deactivate_shield_wall() | — | nil | 停用護盾牆。 |
start_zombie_necronomicon(target, file) | table, string | nil | 對生物目標啟動 Zombie Necronomicon 處理。 |
send_message(text, range?=20) | string, number?=20 | nil | 將經顏色處理的文字傳送給範圍內的玩家。 |
get_nearby_players(range) | number | table | 回傳附近的 EliteMobs 能力玩家資料表。 |
get_target_player() | — | table/nil | 當目前的生物目標是玩家時回傳它。 |
get_nearby_players_in_zone(zone) | table | table | 回傳該 zone 所包含的玩家。 |
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?=1 | nil | 取樣 zone 內部並生成粒子。 |
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?=1 | nil | 取樣 zone 邊緣並生成粒子。 |
get_particles_from_self_toward_zone(zone, particle, speed?=0.1) | table, string(Particle), number?=0.1 | table | 建立由 Boss 朝向取樣 zone 點位的方向性粒子規格。 |
get_particles_toward_self(zone, particle, speed) | table, string(Particle), number | table | 建立朝向 Boss 的方向性粒子規格;目前的建構器是從最後傳入的參數讀取 speed。 |
spawn_particles_with_vector(particles) | table | nil | 生成一組方向性粒子規格的陣列。 |
summon_reinforcement(file, zone_or_location?, level?=0) | string, table?, int?=0 | table/nil | 在取樣的 zone 點位、指定位置或 Boss 處召喚增援。 |
summon_projectile(type, origin, destination, speed?=1, options?) | string(EntityType), table, table, number?=1, table? | table/nil | 生成投射物;options 支援 custom_damage、detonation_power、yield、incendiary、gravity、glowing、invulnerable、persistent、duration、EntityEffect effect、spawn_at_origin、direction_only、track、on_land 與 max_ticks。 |
context.players:EliteMobs Boss 能力
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
current_target() | — | table/nil | 當事件行為者是玩家時回傳它;否則在 Boss 目前的生物目標是玩家時回傳該目標。 |
nearby_players(radius) | number | table | 回傳 Boss 半徑範圍內的 Player Table。 |
all_players_in_world() | — | table | 回傳 Boss 目前世界中的所有 Player Table。 |
context.entities:EliteMobs Boss 能力
這些查詢不包含 Boss 自身。生物篩選器接受 player/players、elite/elites、mob/mobs,或任何其他值以代表所有生物實體。
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
get_nearby_entities(radius, filter?="living") | number, string? | table | 回傳半徑範圍內的實體。all 或 entities 會包含非生物實體;其他篩選器則回傳生物資料表。 |
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 支援 normalize、multiplier 與向量 offset。 |
rotate_vector(vector, pitch?=0, yaw?=0) | table, number?=0, number?=0 | table | 回傳依 pitch 與 yaw(度)旋轉後的向量。 |
normalize_vector(vector) | table | table | 回傳單位向量;零向量仍為零。 |
context.zones:EliteMobs Boss 能力
EliteMobs Boss 能力會以 Elite Script 的 zone 定義查詢取代共用的整數控制代碼 zone 介面。
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
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 支援 filter 與 mode;所擁有的監看會隨腳本一起停止。 |
context.script:EliteMobs Boss 能力
此橋接介面接受與 Elite Script 的 target、zone 與相對向量 YAML 設定相同的資料表索引鍵。
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
target(spec) | table | target handle | 建立一個 target 控制代碼。 |
zone(spec) | table | zone handle | 建立一個 zone 控制代碼。 |
relative_vector(spec, location?, zone?) | table, table?, zone handle? | vector handle | 建立一個相對向量控制代碼,其動作位置預設為 Boss。 |
damage(target, amount?=0, multiplier?=1) | target handle, number?=0, number?=1 | nil | 對每一個已解析的目標實體造成傷害。 |
push(target, vector, additive?=false) | target handle, table/vector handle, bool?=false | nil | 對已解析的目標實體套用速度。 |
set_facing(target, vector) | target handle, table/vector handle | nil | 讓已解析的目標實體沿該向量面向。 |
spawn_particles(target, particles) | target handle, table/string | nil | 在已解析的目標位置生成該粒子規格。 |
Target 控制代碼方法
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
entities() | — | table | 解析並回傳 Entity Table。 |
locations() | — | table | 解析並回傳位置表。 |
first_entity() | — | table/nil | 回傳第一個已解析的實體。 |
first_location() | — | table/nil | 回傳第一個已解析的位置。 |
Zone 控制代碼方法
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
full_target(coverage?) | number? | target handle | 為形狀內部建立一個 target 控制代碼。 |
border_target(coverage?) | number? | target handle | 為邊界建立一個 target 控制代碼。 |
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 能力事件資料表
EliteMobs Boss 能力的事件值會依事件型別有條件地公開欄位與方法。
Properties
| 欄位 | 型別 | 說明 |
|---|---|---|
damage_amount | number/nil | 傷害事件的數值快照。 |
damage_cause | string/nil | 當傷害事件有提供時的 DamageCause 名稱。 |
damager | table/nil | 實體造成傷害事件中的傷害者參考。 |
projectile | table/nil | 當傷害者為投射物時的投射物參考。 |
spawn_reason | string/nil | Elite 的生成原因。 |
entity | table/nil | 死亡或 zone 事件的實體。 |
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
cancel_event() | — | nil | 取消 EliteDamageEvent 或其他可取消的事件。 |
set_damage_amount(amount) | number | nil | 取代 EliteDamageEvent 的傷害值。 |
multiply_damage_amount(multiplier) | number | nil | 將 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?=1 | nil | 覆寫版本,透過 EliteMobs 的支援接受已註冊或自訂的具命名空間音效。 |
spawn_particle_at_location(location, particle, count?=1) | table, string(Particle)/table, int?=1 | nil | 覆寫版本,接受 EliteMobs 的粒子規格表。 |
set_block_at_location(location, material, require_air?=false) | table, string(Material), bool?=false | nil | 覆寫版本,使用不會過期的 EliteMobs 暫時方塊放置。 |
place_temporary_block_at_location(location, material, ticks?=0, require_air?=false) | table, string(Material), int?=0, bool?=false | nil | 覆寫版本,使用 EliteMobs 的暫時方塊放置。 |
get_block_type_at_location(location) | table | string/nil | 回傳大寫的 Material 名稱;位置無效時回傳 nil。 |
get_highest_block_y_at_location(location) | table | int/nil | 覆寫版本,回傳最高方塊的 Y 值,或 nil。 |
get_blast_resistance_at_location(location) | table | number | 回傳方塊的爆炸抗性;位置無效時預設為 0。 |
is_air_at_location(location) | table | bool | 測試目標方塊是否為空氣。 |
is_passable_at_location(location) | table | bool | 測試 Bukkit 的可穿越性。 |
is_passthrough_at_location(location) | table | bool | 測試該材質是否為非固體。 |
is_on_floor_at_location(location) | table | bool | 測試目標為非固體且其下方為固體方塊。 |
is_standing_on_material(location, material) | table, string(Material) | bool | 測試下方的方塊。 |
strike_lightning_at_location(location) | table | nil | 覆寫版本,在降下閃電前啟用 EliteMobs 的閃電繞過機制。 |
run_empowered_lightning_task_at_location(location) | table | nil | 執行強化終界龍閃電的支援功能。 |
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?=6000 | nil | 設定 CLEAR、PRECIPITATION、RAIN 或 THUNDER。 |
run_console_command(command) | string | nil | 以主控台身分派送一則指令。 |
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 支援 silent、level、add_as_reinforcement 與 velocity。 |
spawn_entity_at_location(type, location, options?) | string(EntityType), table, table? | table/nil | 生成原版實體;options 支援 velocity、duration、EntityEffect effect、on_land 與 max_ticks。 |
spawn_falling_block_at_location(location, material, options?) | table, string(Material), table? | table/nil | 生成掉落方塊;options 支援 drop_item、hurt_entities、velocity 與 on_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, table | table/nil | 生成煙火;options 支援 effects、type、flicker、trail、colors、fade_colors、power、velocity 與 shot_at_angle,其中 type 使用 FireworkEffect.Type 名稱。 |
spawn_splash_potion_at_location(location, options) | table, table | table/nil | 生成噴濺藥水;effects 項目接受 PotionEffectType type、duration、amplifier 與 overwrite,另外還有頂層的 velocity。 |
generate_fake_explosion(locations, source?) | table, table? | nil | 為一組方塊位置陣列產生一次 EliteMobs 的假爆炸。 |
spawn_fake_gold_nugget_at_location(location, velocity, gravity?=false) | table, table, bool?=false | table/nil | 生成一個假金粒投射物。 |
run_fake_gold_nugget_damage(projectiles) | table | nil | 執行假投射物的傷害處理。 |
generate_player_loot(times?=1) | int?=1 | nil | 為符合資格的傷害者產生玩家戰利品。 |
drop_bonus_coins(multiplier?=2) | number?=2 | nil | 為符合資格的傷害者掉落額外金幣。 |
EliteMobs 假投射物資料表
spawn_fake_gold_nugget_at_location 在生成成功時會回傳此資料表。
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
get_location() | — | table | 回傳假投射物的位置。 |
set_gravity(enabled) | bool | nil | 設定假投射物的重力。 |
remove() | — | nil | 移除該假投射物。 |
is_removed() | — | bool | 測試它是否已被移除。 |
context.settings
EliteMobs Boss 能力會從同一個 world table 建構器取得此設定資料表。
Methods
| 方法 | 參數 | 回傳 | 說明 |
|---|---|---|---|
warning_visual_effects_enabled() | — | bool | 回傳目前的警告視覺效果設定。 |