跳至主要内容

Lua API 參考

Lua 腳本 API 的完整方法參考。所有方法都透過 context.table:method() 語法呼叫。

全域方法(標記為 GLOBAL)來自 Magmacore,共享核心函式庫 — 在 EliteMobs 和 FreeMinecraftModels 腳本中的運作方式完全相同。

EliteMobs 方法(標記為 ELITEMOBS)專用於 EliteMobs Boss 能力腳本。

FMM 方法(標記為 FMM)專用於 FreeMinecraftModels 物品和道具腳本。

當方法需要 Bukkit 列舉(Sound、Particle、Material 等)時,請參閱 Spigot Javadocs 以取得有效值。列舉名稱以大寫字串傳遞(例如 "DIAMOND_SWORD""ENTITY_ARROW_SHOOT")。


Entity Table GLOBAL

所有實體表上都存在的基本欄位 — 玩家、怪物、道具等所有實體。

屬性

欄位類型說明
uuidstring實體 UUID
entity_typestring實體類型(小寫)
is_validbool實體是否仍存在於世界中
is_deadbool實體已死亡
is_playerbool是否為玩家
is_hostilebool是否為怪物
is_passivebool是否為動物
is_elitebool是否為 EliteMobs 實體
is_custom_bossbool是否為 EliteMobs 自訂 Boss
is_significant_bossbool生命值倍率超過 1 的自訂 Boss(設計過的遭遇戰)
is_modeledbool是否有 FMM 模型
is_propbool是否為 FMM 道具
current_locationlocation實體位置(x、y、z、yaw、pitch、world)
worldstring世界名稱

方法

方法參數回傳說明
teleport(location)location tablenil傳送實體
remove()nil從世界移除實體
set_silent(enabled)boolnil設定靜音
set_invulnerable(enabled)boolnil設定無敵
set_gravity(enabled)boolnil設定重力
set_glowing(enabled)boolnil設定發光

橋接:entity.elite

僅在 is_elite 為 true 時存在。透過反射填充 — 不需要 EliteMobs 依賴。

欄位類型說明
levelint菁英怪等級
namestring菁英怪顯示名稱
healthdouble目前生命值
max_healthdouble最大生命值
is_custom_bossbool是否為自訂 Boss(在頂層也可用)
health_multiplierdouble設定中定義的生命值倍率
damage_multiplierdouble設定中定義的傷害倍率
remove()method移除菁英實體

橋接:entity.model

僅在 is_modeled 為 true 時存在。透過反射填充 — 不需要 FMM 依賴。

欄位類型說明
model_idstring模型藍圖名稱
play_animation(name, blend?, loop?)method播放動畫。blend 預設為 false,loop 預設為 false
stop_animations()method停止所有動畫
remove()method移除模型實體

Living Entity Table GLOBAL

繼承 Entity Table。套用於所有生物實體(怪物和玩家)。

屬性

欄位類型說明
healthdouble目前生命值
maximum_healthdouble最大生命值
namestring實體顯示名稱
is_alivebool實體未死亡

方法

方法參數回傳說明
damage(amount)doublenil對實體造成傷害
push(x, y, z)double, double, doublenil添加速度向量
set_facing(x, y, z)double, double, doublenil設定面朝方向
add_potion_effect(type, duration, amplifier)string (PotionEffectType), int, intnil按名稱施加藥水效果
remove_potion_effect(type)string (PotionEffectType)nil按名稱移除藥水效果

context.player GLOBAL

玩家實體表。繼承所有 EntityLiving Entity 欄位。

屬性

欄位類型說明
game_modestringsurvival、creative、adventure、spectator

方法

方法參數回傳說明
send_message(text)stringnil發送聊天訊息。支援顏色代碼
get_held_item()table 或 nil回傳 type、amount、display_name 欄位,空手則為 nil
consume_held_item(amount?)int (預設 1)nil減少手持物品堆疊數量
has_item(material, amount?)string (Material), int (預設 1)bool檢查物品欄中的材料
get_target_entity(range?)num (預設 50)entity 或 nil射線投射取得玩家正在看的實體
get_eye_location()location玩家眼睛位置
get_look_direction()vector單位方向向量
send_block_change(x, y, z, material, ticks?)int, int, int, string (Material), int (可選)bool發送假方塊。提供 ticks 時自動重設
reset_block(x, y, z)int, int, intbool將假方塊重設為真實方塊
sleep(x, y, z)num, num, numnil在指定位置的床上睡眠動畫
wake_up()nil從睡眠中醒來
show_boss_bar(text, color?, progress, ticks?)string, string (BarColor, 預設 WHITE), num, int (可選)nil顯示 Boss 血條。提供 ticks 後自動隱藏。支援顏色代碼
hide_boss_bar()nil移除 Boss 血條
show_action_bar(text, ticks?)string, int (可選)nil顯示動作欄。ticks 大於 0 時重複顯示。支援顏色代碼
show_title(title, subtitle?, fadeIn, stay, fadeOut)string, string (預設空), int, int, intnil顯示標題畫面。支援顏色代碼

context.world GLOBAL

世界操作。所有腳本類型皆可用。

屬性

欄位類型說明
namestring世界名稱

方法

方法參數回傳說明
get_block_at(x, y, z)int, int, intstringMaterial 名稱(小寫)
set_block_at(x, y, z, material)int, int, int, string (Material)bool放置方塊
get_highest_block_y(x, z)int, intint最高非空氣方塊的 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?=0nil生成粒子效果
play_sound(sound, x, y, z, volume?, pitch?)string (Sound), num, num, num, float?=1, float?=1nil播放音效
strike_lightning(x, y, z)num, num, numnil召喚閃電
get_time()int世界時間(以刻為單位)
set_time(ticks)longnil設定世界時間
get_nearby_entities(x, y, z, radius)num, num, num, numtable實體表陣列
get_nearby_players(x, y, z, radius)num, num, num, numtable玩家實體表陣列
spawn_entity(type, x, y, z)string (EntityType), num, num, numentity生成原版實體
raycast(fx, fy, fz, dx, dy, dz, max?)num, num, num, num, num, num, num?=50table回傳 hit_entity、hit_location、hit_block 欄位
place_temporary_block(x, y, z, material, ticks?, require_air?)int, int, int, string (Material), int?=0, bool?=falsebool放置指定 ticks 後自動復原的方塊
drop_item(x, y, z, material, amount?)num, num, num, string (Material), int?=1entity在位置自然掉落物品實體
spawn_firework(x, y, z, colors, type?, power?)num, num, num, table, string (FireworkEffect.Type)?=BALL, int?=1nil生成煙火

context.boss ELITEMOBS

EliteMobs Lua 能力腳本的 Boss 實體表。繼承所有 EliteMobs Living Entity 方法。屬性透過專用 getter 方法重新整理。

屬性

欄位類型說明
namestringBoss 顯示名稱
uuidstring菁英實體 UUID
healthdouble目前生命值(快照)
maximum_healthdouble最大生命值(快照)
current_locationlocationBoss 位置(快照)
levelintBoss 等級
damager_countint對此 Boss 造成過傷害的玩家數量
is_in_combatboolBoss 是否在戰鬥中
existsboolBoss 實體是否存在

方法

方法參數回傳說明
is_alive()boolBoss 實體是否存活(即時檢查)
get_health()double目前生命值(即時)
get_maximum_health()double最大生命值(即時)
get_location()location目前位置(即時)
restore_health(amount)doublenil治療 Boss
despawn()nil移除 Boss 實體
get_damager_count()int即時攻擊者計數
add_tag(tag, ticks?)string, int?=0nil添加標籤,設定 ticks 後自動移除
remove_tag(tag)stringnil移除標籤
has_tag(tag)stringbool檢查標籤
reset_custom_name()nil重設名稱為設定預設值
play_sound_at_self(sound, volume?, pitch?)string (Sound), float?=1, float?=1nil在 Boss 位置播放音效
play_sound_at_entity(sound, volume?, pitch?)string (Sound), float?=1, float?=1nil在 Boss 位置播放音效(別名)
spawn_particle_at_self(particle, count?)string (Particle) 或 table, int?=1nil在 Boss 位置生成粒子
play_model_animation(name)stringnil播放 FMM 模型動畫(需要 FMM 模型)
navigate_to_location(location, speed?, force?, timeout?)location, double?=1, bool?=false, int?=0nil尋路到指定位置
send_message(text, range?)string, double?=20nil向附近玩家發送訊息。支援顏色代碼
get_nearby_players(range)doubletable範圍內的玩家表陣列
get_target_player()player 或 nil目前的怪物目標(如果是玩家)
get_nearby_players_in_zone(zone)zone tabletable區域形狀內的玩家
get_ender_dragon_phase()string 或 nilEnderDragon.Phase 名稱
set_ender_dragon_phase(phase)string (EnderDragon.Phase)nil設定終界龍階段
summon_reinforcement(file, zone?, level?)string, zone 或 nil, int?=0entity 或 nil生成增援 Boss
summon_projectile(type, origin, dest, speed?, options?)string (EntityType), location, location, double?=1, tableentity生成追蹤投射物

summon_projectile 選項

選項類型預設值說明
custom_damagenumber覆蓋投射物傷害
detonation_powerstring爆炸威力等級
yieldnumber火球威力
incendiarybooltrue火球是否引燃
gravitybool啟用重力
glowingboolfalse設定發光
invulnerableboolfalse設定無敵
persistentbooltrue設定持久
durationint0指定刻後自動移除
effectstring生成時播放的 EntityEffect
spawn_at_originboolfalse在起點生成而非從 Boss 發射
direction_onlyboolfalse設定方向但不設速度(火球)
trackbooltrue註冊為菁英投射物
on_landfunction投射物著地時的回呼:function(location, entity)
max_ticksint6000強制著地回呼前的最大刻數

區域/粒子方法

方法參數回傳說明
spawn_particles_in_zone(zone, particle, ...)zone, particle spec, coverage?=1.0nil在區域內填充粒子
spawn_particles_in_zone_border(zone, particle, ...)zone, particle spec, coverage?=1.0nil在區域邊界描繪粒子
get_particles_from_self_toward_zone(zone, particle, speed?)zone, string, double?=0.1table從 Boss 到區域的方向性粒子
get_particles_toward_self(zone, particle, speed?)zone, string, double?=0.1table從區域到 Boss 的方向性粒子
spawn_particles_with_vector(particles)tablenil生成方向性粒子陣列

特殊能力支援

方法參數回傳說明
start_tracking_fireball_system(speed?)double?=0.5nil啟動追蹤火球 AI
handle_spirit_walk_damage(cause)string (DamageCause)nil按原因處理靈魂行走傷害
shield_wall_is_active()bool護盾牆是否啟用
initialize_shield_wall(charges?)int?=1nil啟動護盾牆
shield_wall_absorb_damage(player, damage)entity table, doublebool嘗試吸收傷害
deactivate_shield_wall()nil停用護盾牆
start_zombie_necronomicon(target, file)entity table, stringnil對目標啟動死靈書

EliteMobs Living Entity Table ELITEMOBS

在 EliteMobs 能力腳本內建立的實體表(來自 context.boss、事件資料、區域回呼和世界查詢)使用擴展的生物實體表,在全域 Living Entity 之上包含額外方法。context.boss 繼承所有這些方法。

屬性

欄位類型說明
namestring實體顯示名稱
uuidstring實體 UUID
entity_typestring實體類型名稱
is_playerbool是否為玩家
is_monsterbool是否為怪物
is_elitebool是否為 EliteMobs 實體
is_validbool實體是否仍存在
healthdouble目前生命值(快照)
maximum_healthdouble最大生命值(快照)
current_locationlocation實體位置(快照)
game_modestring遊戲模式(僅限玩家)

方法

方法參數回傳說明
is_alive()bool實體是否存活(即時檢查)
is_ai_enabled()boolAI 是否啟用
is_frozen()boolBoss 是否被凍結(僅限 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)doublenil造成一般傷害
deal_custom_damage(amount)doublenil造成來自能力 Boss 的自訂 Boss 攻擊傷害
deal_damage_from_boss(amount)doublenil造成歸因於能力 Boss 實體的傷害
restore_health(amount)doublenil治療實體(菁英怪使用 EliteMobs 治療)
play_sound_at_entity(sound, volume?, pitch?)string (Sound), float?=1, float?=1nil在實體位置播放音效
play_sound_at_self(sound, volume?, pitch?)string (Sound), float?=1, float?=1nil在實體位置播放音效(別名)
spawn_particle_at_self(particle, count?)string (Particle) 或 table, int?=1nil在實體位置生成粒子
spawn_particles_at_location(loc, particle, count?)location, particle spec, int?=1nil在指定位置生成粒子
teleport_to_location(location)locationnil傳送實體
set_velocity_vector(vector)vectornil設定速度
set_gravity(enabled)boolnil設定重力
apply_push_vector(vector, additive?, delay?)vector, bool?=false, int?=1nil延遲後施加速度。additive 會加到現有速度上
push_relative_to(location, force?, extraX?, extraY?, extraZ?)location, double?=1, double?=0, double?=0, double?=0nil將實體推離指定位置
set_custom_name(name)stringnil設定自訂顯示名稱。支援顏色代碼
reset_custom_name()nil重設名稱為 EliteMobs 預設值
set_custom_name_visible(visible)boolnil切換名稱可見性
set_ai_enabled(enabled, duration?)bool, int?=0nil設定 AI 狀態。指定 duration 刻後自動恢復
set_awareness_enabled(enabled, duration?)bool, int?=0nil設定怪物感知。指定 duration 刻後自動恢復
face_direction_or_location(target)vector 或 locationnil面朝方向或看向位置
play_model_animation(name)stringnil播放 FMM 模型動畫(需要 FMM 模型)
set_scale(scale, duration?)double, int?=0nil設定實體縮放。指定 duration 刻後自動恢復為 1.0
set_invulnerable(enabled, duration?)bool, int?=0nil設定無敵。指定 duration 刻後自動恢復
set_healing(enabled)boolnil設定菁英怪治療狀態
navigate_to_location(location, speed?, force?, timeout?)location, double?=1, bool?=false, int?=0nil尋路到指定位置(僅限 CustomBossEntity)
add_tag(tag, ticks?)string, int?=0nil添加標籤,指定 ticks 後自動移除
remove_tag(tag)stringnil移除標籤
has_tag(tag)stringbool檢查標籤
overlaps_box_at_location(center, halfX?, halfY?, halfZ?)location, double?=0.5, double?=halfX, double?=halfXbool實體包圍盒是否與指定位置的方框重疊
remove_elite()nil透過 EliteMobs 移除管道移除
apply_potion_effect(type, duration, amplifier?)string (PotionEffectType), int, int?=0nil施加藥水效果
set_equipment(slot, material, options?)string (EquipmentSlot), string (Material), tablenil設定裝備欄位物品
set_fire_ticks(ticks)intnil設定著火刻數
add_visual_freeze_ticks(ticks?)int?=1nil添加冰凍視覺效果刻數
place_temporary_block(material, ticks?, visual?)string (Material), int?=0, bool?=falsenil在實體位置放置臨時方塊

set_equipment 選項

選項類型預設值說明
unbreakableboolfalse使物品不可破壞
enchantmentstable{type = "ENCHANT_NAME", level = 1} 表的陣列

EliteMobs 玩家方法

EliteMobs 腳本中的玩家擁有所有 EliteMobs 生物實體方法,外加:

方法參數回傳說明
send_message(text)stringnil發送聊天訊息。支援顏色代碼
show_action_bar(text)stringnil顯示動作欄文字。支援顏色代碼
show_title(title, subtitle?, fadeIn?, stay?, fadeOut?)string, string?="", int?=10, int?=40, int?=10nil顯示標題畫面。支援顏色代碼
show_boss_bar(title, color?, style?, duration?)string, string (BarColor)?=WHITE, string (BarStyle)?=SOLID, int?=40nil顯示 Boss 血條。指定 duration 刻後自動隱藏。支援顏色代碼
run_command(command)stringnil以玩家身份執行指令

EliteMobs 實體引用表

非生物實體(投射物、掉落方塊、煙火)從 EliteMobs 生成方法回傳的輕量引用表:

欄位 / 方法參數回傳說明
namestring實體名稱
uuidstring實體 UUID
entity_typestring實體類型名稱
is_playerbool始終為 false
is_elitebool始終為 false
is_valid()bool實體是否仍然有效(即時檢查)
current_locationlocation位置(快照)
get_location()location目前位置(即時)
get_velocity()vector目前速度向量
is_on_ground()bool實體是否在地面上
teleport_to_location(location)locationnil傳送實體
set_velocity_vector(vector)vectornil設定速度
set_direction_vector(vector)vectornil設定方向(僅限火球)
set_yield(amount)doublenil設定火球威力
set_gravity(enabled)boolnil設定重力
detonate()nil引爆煙火
remove()nil移除實體
unregister(reason?)string?=OTHERnil從 EliteMobs 實體追蹤器中取消註冊

context.players ELITEMOBS

EliteMobs 能力腳本中可用的玩家查詢表。提供輔助方法以查找相對於 Boss 的玩家。

方法參數回傳說明
current_target()player 或 nil如果是玩家則為事件參與者,或 Boss 的目前怪物目標(如果是玩家)
nearby_players(radius)doubletableBoss 範圍內的玩家表陣列
all_players_in_world()tableBoss 所在世界中所有玩家表的陣列

context.entities ELITEMOBS

EliteMobs 能力腳本中可用的實體查詢表。提供輔助方法以查找相對於 Boss 的實體。所有查詢都排除 Boss 本身。

方法參數回傳說明
get_nearby_entities(radius, filter?)double, string?="living"table範圍內的實體。篩選器:"living""all""entities"
get_entities_in_box(center, halfX, halfY, halfZ, filter?)location, double, double, double, string?="living"table軸對齊方框內的實體
get_all_entities(filter?)string?="living"tableBoss 所在世界中的所有實體
get_direct_target_entity()entity 或 nil觸發事件的直接目標實體
get_boss_spawn_location()locationBoss 的原始生成位置

context.vectors ELITEMOBS

EliteMobs 能力腳本中可用的向量數學工具。

方法參數回傳說明
get_vector_between_locations(from, to, options?)location, location, tablevector從來源到目標的向量。選項可以修改結果
rotate_vector(vector, pitch?, yaw?)vector, double?=0, double?=0vector按俯仰和偏航旋轉向量(度)
normalize_vector(vector)vectorvector正規化為單位長度

context.cooldowns GLOBAL

冷卻時間管理。本地冷卻時間為每個腳本實例獨立計算;全域冷卻時間在同一實體/擁有者的所有腳本之間共享。如果未提供鍵值,則預設為腳本的檔案名稱。

方法參數回傳說明
local_ready(key?)string(可選)bool本地冷卻時間是否已過期
local_remaining(key?)string(可選)int本地冷卻時間剩餘刻數(就緒時為 0)
check_local(key?, duration)string(可選), intbool如果就緒,啟動冷卻時間並回傳 true;否則回傳 false
set_local(duration, key?)long, string(可選)nil設定本地冷卻時間持續指定刻數
global_ready()bool全域冷卻時間是否已過期
set_global(duration)longnil設定全域冷卻時間持續指定刻數

在 EliteMobs 能力腳本中,本地冷卻時間在同一 Boss 實體的所有能力之間共享,全域冷卻時間使用 Boss 內建的能力冷卻系統。


context.scheduler GLOBAL

任務排程。所有任務在腳本關閉時自動取消。

Global(Magmacore)變體

方法參數回傳說明
run_later(ticks, callback)int, functionint在指定刻數後執行回呼。回傳任務 ID
run_repeating(delay, interval, callback)int, int, functionint在初始延遲後,每隔指定刻數執行回呼。回傳任務 ID
cancel(taskId)intnil取消已排程的任務

EliteMobs 變體

方法參數回傳說明
run_after(ticks, callback)int, functionint在指定刻數後執行回呼。回傳任務 ID
run_every(ticks, callback)int, functionint每 N 刻執行回呼。回傳任務 ID
cancel_task(taskId)intnil取消已排程的任務

context.log GLOBAL

用於除錯腳本的日誌工具。

方法參數回傳說明
info(message)stringnil記錄資訊訊息
warn(message)stringnil記錄警告訊息
error(message)stringnil記錄錯誤/警告訊息
debug(message)stringnil記錄除錯訊息(以除錯前綴顯示為資訊)

context.zones GLOBAL

區域建立與監控。在所有腳本類型中可用。

Global(Magmacore)變體

方法參數回傳說明
create_sphere(x, y, z, radius)num, num, num, numint建立球形區域,回傳控制代碼
create_cylinder(x, y, z, radius, height)num, num, num, num, numint建立圓柱形區域,回傳控制代碼
create_cuboid(x, y, z, xSize, ySize, zSize)num, num, num, num, num, numint建立長方體區域,回傳控制代碼
watch(handle, on_enter?, on_leave?)int, function, functionbool開始追蹤玩家進入/離開區域的事件
unwatch(handle)intnil停止追蹤區域

EliteMobs 變體

方法參數回傳說明
get_entities_in_zone(zone, options?)zone table, tabletable取得區域內的實體。選項:filter、mode
get_locations_in_zone(zone, options?)zone table, tabletable取得區域內的位置。選項:coverage、mode
zone_contains(zone, location, mode?)zone table, location, string?="full"bool位置是否在區域內("full" 或 "border")
watch_zone(zone, callbacks, mode?)zone table, table, string?="full"int監控區域的進入/離開。回呼:{on_enter = fn, on_leave = fn}

context.event GLOBAL

觸發當前腳本執行的鉤子的事件資料表。僅在事件驅動的鉤子中存在(不在 on_tick 中)。

Global(Magmacore)變體

欄位 / 方法類型說明
is_cancelledbool事件當前是否已取消
cancel()method取消事件
uncancel()method取消對事件的取消
playerentity table事件中涉及的玩家(如果有)

關於 EliteMobs 事件表(提供傷害數值、傷害原因等),請參閱 EliteMobs 事件表


context.script ELITEMOBS

連接 EliteMobs Elite Script 系統的橋樑。讓 Lua 能力使用基於 YAML 的目標、區域和相對向量系統,透過與 Elite Script YAML 設定相同欄位名稱的 Lua 表來實現。

方法

方法參數回傳說明
target(spec)tabletarget handle從 Elite Script 目標規格表建立目標控制代碼
zone(spec)tablezone handle從 Elite Script 區域規格表建立區域控制代碼
relative_vector(spec, location?, zone?)table, location, zone handlevector handle從 Elite Script 向量規格建立相對向量
damage(target, amount?, multiplier?)target handle, double?=0, double?=1nil對目標中的所有實體造成傷害
push(target, vector, additive?)target handle, vector or vector handle, bool?=falsenil以速度推動目標實體
set_facing(target, vector)target handle, vector or vector handlenil設定目標實體的面朝方向
spawn_particles(target, particles)target handle, table or stringnil在目標位置生成粒子效果

Target Handle

context.script:target(spec) 回傳。規格表使用與 Elite Script YAML 目標設定相同的鍵值(例如 {targetType = "NEARBY_PLAYERS", range = 20})。

方法參數回傳說明
entities()table目標處的實體陣列
locations()table目標處的位置陣列
first_entity()entity or nil目標處的第一個實體
first_location()location or nil目標處的第一個位置

Zone Handle

context.script:zone(spec) 回傳。規格表使用與 Elite Script YAML 區域設定相同的鍵值(例如 {shape = "SPHERE", radius = 5, target = {targetType = "SELF"}})。

方法參數回傳說明
full_target(coverage?)numbertarget handle區域內部位置的目標控制代碼
border_target(coverage?)numbertarget handle區域邊界位置的目標控制代碼
full_locations(coverage?)numbertable內部位置陣列
border_locations(coverage?)numbertable邊界位置陣列
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) 回傳。規格表使用與 Elite Script YAML 相對向量設定相同的鍵值。

方法參數回傳說明
resolve()vector計算當前上下文的向量

context.world (EliteMobs) ELITEMOBS

EliteMobs 能力腳本的擴展世界表。在全域 world 表之上添加 Boss 特定的生成、方塊檢查和效果。

方塊查詢

方法參數回傳說明
get_block_type_at_location(loc)locationstring 或 nilMaterial 名稱
get_highest_block_y_at_location(loc)locationint 或 nil最高方塊 Y
get_blast_resistance_at_location(loc)locationdouble爆炸抗性值
is_air_at_location(loc)locationbool方塊是否為空氣
is_passable_at_location(loc)locationbool方塊是否可通過
is_passthrough_at_location(loc)locationbool方塊是否非實心
is_on_floor_at_location(loc)locationbool空氣且下方有實心方塊
is_standing_on_material(loc, material)location, string (Material)bool下方方塊是否匹配指定材料

方塊操作

方法參數回傳說明
set_block_at_location(loc, material, visual?)location, string (Material), bool?=falsenil放置方塊。visual=true 為假方塊
place_temporary_block_at_location(loc, material, ticks?, visual?)location, string, int?=0, bool?=falsenil放置方塊,指定 ticks 後自動移除

生成

方法參數回傳說明
spawn_boss_at_location(file, loc?, level?)string, location?=boss loc, int?=boss levelentity 或 nil生成自訂 Boss
spawn_custom_boss_at_location(file, loc, options?)string, location, tableentity 或 nil使用選項生成 Boss(level、silent、add_as_reinforcement、velocity)
spawn_entity_at_location(type, loc, options?)string (EntityType), location, tableentity使用選項生成原版實體(velocity、duration、effect、on_land、max_ticks)
spawn_falling_block_at_location(loc, material, options?)location, string (Material), tableentity生成掉落方塊(drop_item、hurt_entities、velocity、on_land)
spawn_reinforcement_at_location(file, loc, level?, velocity?)string, location, int?=0, vectorentity 或 nil生成綁定到 Boss 的增援
spawn_fireworks_at_location(loc, config)location, tableentity 或 nil生成煙火
spawn_splash_potion_at_location(loc, config)location, tableentity 或 nil生成噴濺藥水

效果與工具

方法參數回傳說明
play_sound_at_location(loc, sound, volume?, pitch?)location, string (Sound), float?=1, float?=1nil播放音效
spawn_particle_at_location(loc, particle, count?)location, string (Particle) 或 table, int?=1nil生成粒子
strike_lightning_at_location(loc)locationnil召喚閃電(繞過 EM 保護)
run_empowered_lightning_task_at_location(loc)locationnil強化閃電效果
generate_fake_explosion(locations, center?)table of locations, locationnil無傷害的視覺爆炸
spawn_fake_gold_nugget_at_location(loc, velocity, gravity?)location, vector, bool?=falsefake projectile生成視覺金粒投射物
run_fake_gold_nugget_damage(projectiles)tablenil對假投射物執行傷害檢查
set_world_time(time) or (loc, time)long, 或 location + longnil設定世界時間
set_world_weather(weather, duration?) or (loc, weather, duration?)string (CLEAR, RAIN, PRECIPITATION, THUNDER), int?=6000nil設定天氣
run_console_command(command)stringnil執行主控台指令
generate_player_loot(level?)int?=1nil為攻擊者生成戰利品
drop_bonus_coins(multiplier?)double?=2nil在 Boss 位置掉落額外金幣

context.settings (EliteMobs)

方法參數回傳說明
warning_visual_effects_enabled()bool設定中是否啟用警告視覺效果

EliteMobs 事件表

context.event 表傳遞給傷害和生成鉤子。欄位因事件類型而異。

欄位 / 方法類型存在時機說明
damage_amountdouble傷害事件原始傷害量
damage_causestring傷害事件DamageCause 名稱
damagerentity table實體傷害事件造成傷害的實體
projectileentity table投射物傷害事件造成傷害的投射物
spawn_reasonstring生成事件生成原因名稱
entityentity table死亡/區域事件相關實體
cancel_event()method大多數事件取消事件
set_damage_amount(amount)method (double)傷害事件覆蓋傷害量
multiply_damage_amount(multiplier)method (double)傷害事件乘以目前傷害

context.item FMM

在 FMM 物品腳本中存取。透過 PDC 標籤從玩家的裝備欄位解析特定的腳本物品。

屬性

欄位類型說明
idstring物品的腳本識別碼

方法

方法參數回傳說明
material()stringMaterial 名稱
get_amount()int堆疊大小
set_amount(n)intnil設定堆疊大小
consume(n?)int?=1nil減少 n 個數量,為零時移除
get_uses()intPDC 儲存的使用計數器
set_uses(n)intnil設定 PDC 使用計數器
get_durability()table 或 nil回傳 currentmax 欄位,無耐久度條則為 nil
get_durability_percentage()number 或 nil0.0--1.0 剩餘比例,或 nil
use_durability(amount, can_break?)int, bool?=falsenil減少固定值耐久度。為 false 時夾持到 1 剩餘
use_durability_percentage(fraction, can_break?)number, bool?=falsenil減少最大值的比例耐久度(0.0--1.0)
get_name()string 或 nil顯示名稱
set_name(s)stringnil設定顯示名稱。支援顏色代碼
get_lore()table說明文字字串陣列
set_lore(table)tablenil從字串陣列設定說明文字

context.prop FMM

在 FMM 道具腳本中存取。從支撐的盔甲架繼承所有 Entity 欄位。

屬性

欄位類型說明
model_idstring藍圖模型名稱
current_locationlocation道具的目前位置

方法

方法參數回傳說明
play_animation(name, blend?, loop?)string, bool?=true, bool?=truebool播放命名動畫
stop_animation()nil停止所有目前動畫
hurt_visual()nil紅色閃光效果,不造成傷害
pickup()nil移除道具並掉落放置物品
has_mount_points()bool道具是否有安裝點骨骼
mount(player)entity tablebool將玩家安裝到第一個可用座位
dismount(player)entity tablebool讓玩家下馬
get_passengers()table已安裝玩家的實體表陣列
spawn_elitemobs_boss(file, x, y, z)string, num, num, numentity 或 nil生成 EliteMobs Boss(需要 EliteMobs)
open_inventory(player, title, rows?)entity table, string, int?=3bool開啟持久箱子物品欄(1--6 行)。標題支援顏色代碼
place_book(player)entity tablebool將玩家手持的書本存放到道具上
read_book(player)entity tablebool開啟存放的書本供閱讀
take_book(player)entity tablebool將存放的書本歸還給玩家
has_book()bool是否有存放的書本
drop_inventory()bool掉落所有存放的物品並清空
drop_book()bool掉落存放的書本並清空
is_viewing_inventory(player)entity tablebool玩家是否正在查看此道具的物品欄
set_persistent_data(key, value)string, stringbool在道具的 PDC 中儲存字串
get_persistent_data(key)stringstring 或 nil從道具的 PDC 中擷取字串

顏色代碼

所有標記為支援顏色代碼的方法都使用 Magmacore 的 ChatColorConverter。這些格式可以在任何字串中自由混合:

傳統代碼

使用 & 後接顏色/格式字元:

代碼顏色代碼格式
&0黑色&l粗體
&1深藍&m刪除線
&2深綠&n底線
&3深青&o斜體
&4深紅&r重設
&5深紫
&6金色
&7灰色
&8深灰
&9藍色
&a綠色
&b青色
&c紅色
&d淡紫
&e黃色
&f白色

十六進位顏色

使用 6 位十六進位的精確 RGB 顏色:

&#FF5500          -- ampersand prefix
<#FF5500> -- tag syntax

漸層

在文字間平滑地在兩種或多種顏色之間插值:

<gradient:#FF0000:#0000FF>This text fades red to blue</gradient>
<g:#FF0000:#00FF00:#0000FF>Three-color gradient</g>

縮寫 ggradient 的作用完全相同。您可以串聯任意數量的顏色停止點。

彩虹

在完整色調範圍內循環。可選飽和度(0--100):

<rainbow>Full rainbow text</rainbow>
<r:50>Pastel rainbow (50% saturation)</r>

常見類型

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