Lua API 參考
Lua 腳本 API 的完整方法參考。所有方法皆透過 context.table:method() 語法呼叫。
Global 方法(標示為 GLOBAL)來自共用核心函式庫 Magmacore。它們適用於 FreeMinecraftModels 腳本以及其他 MagmaCore ScriptInstance 的使用者。EliteMobs Boss 能力會重複使用相同的 Lua 沙盒,但提供 Boss 專屬的 context 表與方法名稱;EliteMobs NPC 腳本在同一套 MagmaCore 執行環境上執行,會收到完整的共享 context,並額外取得僅供 NPC 使用的 context.npc 表。關於這些變體,請參見下方的 EliteMobs 區段以及 NPC 腳本。
EliteMobs 方法(標示為 ELITEMOBS)專屬於 EliteMobs Boss 能力腳本與 NPC 腳本。
FMM 方法(標示為 FMM)專屬於 FreeMinecraftModels 物品與道具(prop)腳本。
當方法需要 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 的欄位,請參見下方的橋接區段。
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(設計過的戰鬥) |
entity.elite 僅在 is_elite 為 true 時存在。
| 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 道具(prop) |
entity.model 僅在 is_modeled 為 true 時存在。
| 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 | 玩家是否為伺服器管理員 |
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 | — | 火球威力(yield) |
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 | 依傷害原因處理靈魂行走(spirit walk)傷害 |
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 | 對目標啟動死靈之書(necronomicon) |
context.npc ELITEMOBS NPC
EliteMobs NPC Lua 腳本中的 NPC 表。NPC 腳本位於 plugins/EliteMobs/npc_scripts/,並透過 NPC 設定的 scripts: 清單附加。NPC 腳本在與所有其他介面相同的 MagmaCore 執行環境上執行,會收到完整的共享 context —— 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 專屬的 hooks 包含 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 身分造成自訂 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 | 新增標籤,於 ticks 後自動移除 |
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 | 設定火球威力(yield) |
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 周圍指定半徑內的玩家表陣列 |
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 | 半徑內的實體。"all"/"entities" 回傳所有實體(包含非生物實體);其他值則回傳依類別篩選的生物實體:"player(s)"、"elite(s)"、"mob(s)",或預設=所有生物實體 |
get_entities_in_box(center, halfX, halfY, halfZ, filter?) | location, double, double, double, string?="living" | table | 軸對齊盒子內的生物實體(filter 值與上方相同;僅限非 all 模式) |
get_all_entities(filter?) | string?="living" | table | Boss 所在世界中的所有生物實體(filter 值同上) |
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、切換狀態,以及任何你需要在 hooks 之間共享的資料。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 | 在初始 delay 之後每隔 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 | 記錄資訊訊息 |
warn(message) | string | nil | 記錄警告訊息 |
error(message) | string | nil | 記錄錯誤/警告訊息 |
EliteMobs variant
| Method | Args | Returns | Description |
|---|---|---|---|
info(message) | string | nil | 記錄資訊訊息 |
warn(message) | string | nil | 記錄警告訊息 |
debug(message) | string | nil | 記錄除錯訊息(以 info 等級顯示並帶有 debug 前綴) |
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 | 建立球形區域,回傳 handle |
create_cylinder(x, y, z, radius, height) | num, num, num, num, num | int | 建立圓柱區域,回傳 handle |
create_cuboid(x, y, z, xSize, ySize, zSize) | num, num, num, num, num, num | int | 建立長方體區域,回傳 handle |
watch(handle, on_enter?, on_leave?) | int, function?, function? | bool | 啟用區域追蹤。傳入函式引數會啟用 on_zone_enter / on_zone_leave;函式本體不會被直接呼叫。區域 hooks 會為跨越邊界的玩家收到 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 | 監控區域的進入/離開。Callbacks:{on_enter = fn, on_leave = fn}。Options 支援 filter 與 mode |
context.event GLOBAL
觸發當前腳本執行的 hook 之事件資料表。會在由事件驅動的 hooks,以及提供玩家主體的通用 MagmaCore 區域進入/離開 hooks 中存在;在 on_game_tick、排程回呼,或沒有玩家的生命週期 hooks 中則不存在。
Global (Magmacore) variant
| Field / Method | Type | Description |
|---|---|---|
is_cancelled | bool | 建立 context 時的取消狀態;在 cancel() / uncancel() 之後不會重新整理 |
cancel() | method | 當背後的 Bukkit 事件可取消時,取消該事件 |
uncancel() | method | 當背後的 Bukkit 事件可取消時,解除該事件的取消 |
player | entity table | 事件中涉及的玩家(若有) |
通用區域 hooks 會填入 player,但並非由可取消的 Bukkit 事件支援,因此 cancel() 與 uncancel() 在此不存在。
關於 EliteMobs 事件表(提供傷害量、傷害原因等),請參見 EliteMobs Event Table。
context.script ELITEMOBS
與 EliteMobs Elite Script 系統的橋接。讓 Lua 能力可以透過 Lua 表(欄位名稱與 Elite Script YAML 設定相同)使用以 YAML 為基礎的目標、區域與相對向量系統。
Methods
| Method | Args | Returns | Description |
|---|---|---|---|
target(spec) | table | target handle | 從 Elite Script target spec 表建立目標 handle |
zone(spec) | table | zone handle | 從 Elite Script zone spec 表建立區域 handle |
relative_vector(spec, location?, zone?) | table, location, zone handle | vector handle | 從 Elite Script vector spec 建立相對向量 |
damage(target, amount?, multiplier?) | target handle, double?=0, double?=1 | nil | 對 target 中所有實體造成傷害 |
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 target 設定相同的鍵(例如 {targetType = "NEARBY_PLAYERS", range = 20})。
| Method | Args | Returns | Description |
|---|---|---|---|
entities() | — | table | target 處的實體表陣列 |
locations() | — | table | target 處的位置表陣列 |
first_entity() | — | entity or nil | target 處的第一個實體 |
first_location() | — | location or nil | target 處的第一個位置 |
Zone Handle
由 context.script:zone(spec) 回傳。spec 表使用與 Elite Script YAML zone 設定相同的鍵(例如 {shape = "SPHERE", radius = 5, target = {targetType = "SELF"}})。
| Method | Args | Returns | Description |
|---|---|---|---|
full_target(coverage?) | number | target handle | 區域內部位置的目標 handle |
border_target(coverage?) | number | target handle | 區域邊界位置的目標 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 relative vector 設定相同的鍵。
| Method | Args | Returns | Description |
|---|---|---|---|
resolve() | — | vector | 為當前 context 計算該向量 |
context.world (EliteMobs) ELITEMOBS
EliteMobs 能力腳本的 Boss 專屬世界表。Boss 能力以通用 MagmaCore 世界表為起點,因此座標式輔助函式(如 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 表會傳遞給傷害與生成 hooks。欄位會依事件類型而異。
| Field / Method | Type | Present When | Description |
|---|---|---|---|
damage_amount | double | Damage events | 原始傷害量 |
damage_cause | string | Damage events | DamageCause 名稱 |
damager | entity table | Damage-by-entity events | 造成傷害的實體 |
projectile | entity table | Projectile damage events | 造成傷害的投射物 |
spawn_reason | string | Spawn event | 生成原因名稱 |
entity | entity table | Death/zone events | 相關實體 |
cancel_event() | method | Most events | 取消事件 |
set_damage_amount(amount) | method (double) | Damage events | 覆寫傷害量 |
multiply_damage_amount(multiplier) | method (double) | Damage events | 將當前傷害乘上倍率 |
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 | Black | &l | Bold |
&1 | Dark Blue | &m | |
&2 | Dark Green | &n | Underline |
&3 | Dark Aqua | &o | Italic |
&4 | Dark Red | &r | Reset |
&5 | Dark Purple | ||
&6 | Gold | ||
&7 | Gray | ||
&8 | Dark Gray | ||
&9 | Blue | ||
&a | Green | ||
&b | Aqua | ||
&c | Red | ||
&d | Light Purple | ||
&e | Yellow | ||
&f | White |
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