Pular para o conteúdo principal

Lua API Reference

Complete method reference for the Lua scripting API. All methods are called via context.table:method() syntax.

Global methods (marked GLOBAL) come from Magmacore, the shared core library — they work identically in EliteMobs and FreeMinecraftModels scripts.

EliteMobs methods (marked ELITEMOBS) are specific to EliteMobs boss power scripts.

FMM methods (marked FMM) are specific to FreeMinecraftModels item and prop scripts.

Where a method requires a Bukkit enum (Sound, Particle, Material, etc.), see the Spigot Javadocs for valid values. Enum names are passed as uppercase strings (e.g., "DIAMOND_SWORD", "ENTITY_ARROW_SHOOT").


Entity Table GLOBAL

Base fields present on all entity tables — players, mobs, props, anything.

Properties

FieldTypeDescription
uuidstringEntity UUID
entity_typestringEntity type (lowercase)
is_validboolEntity still exists in the world
is_deadboolEntity is dead
is_playerboolIs a player
is_hostileboolIs a Monster
is_passiveboolIs an Animal
is_eliteboolIs an EliteMobs entity
is_custom_bossboolIs an EliteMobs custom boss
is_significant_bossboolCustom boss with health multiplier over 1 (designed encounter)
is_modeledboolHas an FMM model
is_propboolIs an FMM prop
current_locationlocationEntity position (x, y, z, yaw, pitch, world)
worldstringWorld name

Methods

MethodArgsReturnsDescription
teleport(location)location tablenilTeleport entity
remove()nilRemove entity from world
set_silent(enabled)boolnilSet silent
set_invulnerable(enabled)boolnilSet invulnerable
set_gravity(enabled)boolnilSet gravity
set_glowing(enabled)boolnilSet glowing

Bridge: entity.elite

Only present when is_elite is true. Populated via reflection — no EliteMobs dependency required.

FieldTypeDescription
levelintElite mob level
namestringElite display name
healthdoubleCurrent health
max_healthdoubleMax health
is_custom_bossboolIs a custom boss (also available at top level)
health_multiplierdoubleConfig-defined health multiplier
damage_multiplierdoubleConfig-defined damage multiplier
remove()methodRemove the elite entity

Bridge: entity.model

Only present when is_modeled is true. Populated via reflection — no FMM dependency required.

FieldTypeDescription
model_idstringModel blueprint name
play_animation(name, blend?, loop?)methodPlay animation
stop_animations()methodStop all animations
remove()methodRemove the modeled entity

Living Entity Table GLOBAL

Extends Entity Table. Applied to all living entities (mobs and players).

Properties

FieldTypeDescription
healthdoubleCurrent health
maximum_healthdoubleMax health
namestringEntity display name
is_aliveboolEntity is not dead

Methods

MethodArgsReturnsDescription
damage(amount)doublenilDeal damage to entity
push(x, y, z)double, double, doublenilAdd velocity vector
set_facing(x, y, z)double, double, doublenilSet look direction
add_potion_effect(type, duration, amplifier)string (PotionEffectType), int, intnilApply potion effect by name
remove_potion_effect(type)string (PotionEffectType)nilRemove potion effect by name

context.player GLOBAL

Player entity table. Inherits all Entity and Living Entity fields.

Properties

FieldTypeDescription
game_modestringsurvival, creative, adventure, spectator

Methods

MethodArgsReturnsDescription
send_message(text)stringnilSend chat message. Supports color codes
get_held_item()table or nilReturns type, amount, display_name fields, or nil if empty hand
consume_held_item(amount?)int (default 1)nilReduce held item stack by amount
has_item(material, amount?)string (Material), int (default 1)boolCheck inventory for material
get_target_entity(range?)num (default 50)entity or nilRaycast for entity player is looking at
get_eye_location()locationPlayer eye position
get_look_direction()vectorUnit direction vector
send_block_change(x, y, z, material, ticks?)int, int, int, string (Material), int (optional)boolSend fake block. Auto-resets after ticks if given
reset_block(x, y, z)int, int, intboolReset fake block to real
sleep(x, y, z)num, num, numnilBed sleep animation at location
wake_up()nilWake from sleep
show_boss_bar(text, color?, progress, ticks?)string, string (BarColor, default WHITE), num, int (optional)nilDisplay boss bar. Auto-hides after ticks. Supports color codes
hide_boss_bar()nilRemove boss bar
show_action_bar(text, ticks?)string, int (optional)nilShow action bar. Repeats if ticks greater than 0. Supports color codes
show_title(title, subtitle?, fadeIn, stay, fadeOut)string, string (default empty), int, int, intnilShow title screen. Supports color codes

context.world GLOBAL

World operations. Available in all script types.

Properties

FieldTypeDescription
namestringWorld name

Methods

MethodArgsReturnsDescription
get_block_at(x, y, z)int, int, intstringMaterial name (lowercase)
set_block_at(x, y, z, material)int, int, int, string (Material)boolPlace block
get_highest_block_y(x, z)int, intintY of highest non-air block
spawn_particle(particle, x, y, z, count?, dx?, dy?, dz?, speed?)string (Particle), num, num, num, int, num, num, num, num (last 5 optional, default 0)nilSpawn particle effect
play_sound(sound, x, y, z, volume?, pitch?)string (Sound), num, num, num, float (default 1), float (default 1)nilPlay sound
strike_lightning(x, y, z)num, num, numnilStrike lightning
get_time()intWorld time in ticks
set_time(ticks)longnilSet world time
get_nearby_entities(x, y, z, radius)num, num, num, numtableArray of entity tables
get_nearby_players(x, y, z, radius)num, num, num, numtableArray of player entity tables
spawn_entity(type, x, y, z)string (EntityType), num, num, numentitySpawn vanilla entity
raycast(fx, fy, fz, dx, dy, dz, max?)num, num, num, num, num, num, num (default 50)tableReturns hit_entity, hit_location, hit_block fields
spawn_firework(x, y, z, colors, type?, power?)num, num, num, table, string (FireworkEffect.Type, default BALL), int (default 1)nilSpawn firework

context.boss ELITEMOBS

Boss entity table for EliteMobs Lua power scripts. Inherits all Living Entity methods. Properties refresh via dedicated getters.

Properties

FieldTypeDescription
namestringBoss display name
uuidstringElite entity UUID
healthdoubleCurrent health (snapshot)
maximum_healthdoubleMax health (snapshot)
current_locationlocationBoss position (snapshot)
levelintBoss level
damager_countintNumber of players who damaged this boss
is_in_combatboolBoss is in combat
existsboolBoss entity exists

Methods

MethodArgsReturnsDescription
get_health()doubleCurrent health (live)
get_maximum_health()doubleMax health (live)
get_location()locationCurrent position (live)
restore_health(amount)doublenilHeal the boss
despawn()nilRemove boss entity
get_damager_count()intLive damager count
add_tag(tag, ticks?)string, int (default 0)nilAdd tag, auto-remove after ticks if set
remove_tag(tag)stringnilRemove tag
has_tag(tag)stringboolCheck tag
reset_custom_name()nilReset name to config default
play_sound_at_self(sound, volume?, pitch?)string (Sound), float, floatnilPlay sound at boss
spawn_particle_at_self(particle, count?)string (Particle), int (default 1)nilSpawn particle at boss
play_model_animation(name)stringnilPlay FMM model animation (requires FMM model)
navigate_to_location(location, speed?, force?, timeout?)location, double (default 1), bool (default false), int (default 0)nilPathfind to location
send_message(text, range?)string, double (default 20)nilSend message to nearby players. Supports color codes
get_nearby_players(range)doubletableArray of player tables within range
get_target_player()player or nilCurrent mob target if it's a player
get_nearby_players_in_zone(zone)zone tabletablePlayers inside the zone shape
get_ender_dragon_phase()string or nilEnderDragon.Phase name
set_ender_dragon_phase(phase)string (EnderDragon.Phase)nilSet ender dragon phase
summon_reinforcement(file, zone?, level?)string, zone or nil, int (default 0)entity or nilSpawn reinforcement boss
summon_projectile(type, origin, dest, speed?, options?)string (EntityType), location, location, double (default 1), tableentitySpawn tracked projectile

summon_projectile options

OptionTypeDefaultDescription
custom_damagenumberOverride projectile damage
detonation_powerstringExplosive power level
yieldnumberFireball yield
incendiarybooltrueFireball sets fire
gravityboolEnable gravity
glowingboolfalseSet glowing
invulnerableboolfalseSet invulnerable
durationint0Auto-remove after ticks
spawn_at_originboolfalseSpawn at origin instead of launching from boss
direction_onlyboolfalseSet direction without velocity (fireballs)
trackbooltrueRegister as elite projectile
on_landfunctionCallback when projectile lands: function(location, entity)
max_ticksint6000Max ticks before forced landing callback

Zone/Particle Methods

MethodArgsReturnsDescription
spawn_particles_in_zone(zone, particle, ...)zone, particle spec, coverage (default 1.0)nilFill zone with particles
spawn_particles_in_zone_border(zone, particle, ...)zone, particle spec, coverage (default 1.0)nilOutline zone with particles
get_particles_from_self_toward_zone(zone, particle, speed?)zone, string, double (default 0.1)tableDirectional particles from boss to zone
get_particles_toward_self(zone, particle, speed?)zone, string, double (default 0.1)tableDirectional particles from zone to boss
spawn_particles_with_vector(particles)tablenilSpawn directional particle array

Special Power Support

MethodArgsReturnsDescription
start_tracking_fireball_system(speed?)double (default 0.5)nilStart tracking fireball AI
handle_spirit_walk_damage(cause)string (DamageCause)nilHandle spirit walk damage by cause
shield_wall_is_active()boolWhether shield wall is active
initialize_shield_wall(charges?)int (default 1)nilActivate shield wall
shield_wall_absorb_damage(player, damage)entity table, doubleboolAttempt to absorb damage
deactivate_shield_wall()nilDeactivate shield wall
start_zombie_necronomicon(target, file)entity table, stringnilStart necronomicon on target

context.world (EliteMobs) ELITEMOBS

Extended world table for EliteMobs power scripts. Adds boss-specific spawning, block checks, and effects on top of the global world table.

Block Queries

MethodArgsReturnsDescription
get_block_type_at_location(loc)locationstring or nilMaterial name
get_highest_block_y_at_location(loc)locationint or nilHighest block Y
get_blast_resistance_at_location(loc)locationdoubleBlast resistance value
is_air_at_location(loc)locationboolBlock is air
is_passable_at_location(loc)locationboolBlock is passable
is_passthrough_at_location(loc)locationboolBlock is not solid
is_on_floor_at_location(loc)locationboolAir with solid block below
is_standing_on_material(loc, material)location, string (Material)boolBlock below matches material

Block Manipulation

MethodArgsReturnsDescription
set_block_at_location(loc, material, visual?)location, string (Material), bool (default false)nilPlace block. visual=true for fake block
place_temporary_block_at_location(loc, material, ticks?, visual?)location, string, int (default 0), bool (default false)nilPlace block, auto-remove after ticks

Spawning

MethodArgsReturnsDescription
spawn_boss_at_location(file, loc?, level?)string, location (default boss loc), int (default boss level)entity or nilSpawn custom boss
spawn_custom_boss_at_location(file, loc, options?)string, location, tableentity or nilSpawn boss with options (level, silent, add_as_reinforcement, velocity)
spawn_entity_at_location(type, loc, options?)string (EntityType), location, tableentitySpawn vanilla entity with options (velocity, duration, effect, on_land)
spawn_falling_block_at_location(loc, material, options?)location, string (Material), tableentitySpawn falling block (drop_item, hurt_entities, velocity, on_land)
spawn_reinforcement_at_location(file, loc, level?, velocity?)string, location, int (default 0), vectorentity or nilSpawn reinforcement tied to boss
spawn_fireworks_at_location(loc, config)location, tableentity or nilSpawn firework
spawn_splash_potion_at_location(loc, config)location, tableentity or nilSpawn splash potion

Effects and Utility

MethodArgsReturnsDescription
play_sound_at_location(loc, sound, volume?, pitch?)location, string (Sound), float (default 1), float (default 1)nilPlay sound
spawn_particle_at_location(loc, particle, count?)location, string (Particle) or table, int (default 1)nilSpawn particles
strike_lightning_at_location(loc)locationnilStrike lightning (bypasses EM protection)
run_empowered_lightning_task_at_location(loc)locationnilEmpowered lightning effect
generate_fake_explosion(locations, center?)table of locations, locationnilVisual explosion without damage
spawn_fake_gold_nugget_at_location(loc, velocity, gravity?)location, vector, bool (default false)fake projectileSpawn visual gold nugget projectile
run_fake_gold_nugget_damage(projectiles)tablenilRun damage check on fake projectiles
set_world_time(time) or (loc, time)long, or location + longnilSet world time
set_world_weather(weather, duration?) or (loc, weather, duration?)string (CLEAR, RAIN, THUNDER), int (default 6000)nilSet weather
run_console_command(command)stringnilExecute console command
generate_player_loot(level?)int (default 1)nilGenerate loot for damagers
drop_bonus_coins(multiplier?)double (default 2)nilDrop bonus coins at boss

context.settings (EliteMobs)

MethodArgsReturnsDescription
warning_visual_effects_enabled()boolWhether warning VFX are enabled in config

context.item FMM

Accessed in FMM item scripts. Resolves the specific scripted item from the player's equipped slots via PDC tag.

Properties

FieldTypeDescription
idstringItem's script identifier

Methods

MethodArgsReturnsDescription
material()stringMaterial name
get_amount()intStack size
set_amount(n)intnilSet stack size
consume(n?)int (default 1)nilDecrement amount by n, remove if zero
get_uses()intPDC-stored use counter
set_uses(n)intnilSet PDC use counter
get_durability()table or nilReturns current and max fields, or nil if no durability bar
get_durability_percentage()number or nil0.0–1.0 remaining fraction, or nil
use_durability(amount, can_break?)int, bool (default false)nilReduce durability by flat amount. When false, clamps to 1 remaining
use_durability_percentage(fraction, can_break?)number, bool (default false)nilReduce durability by fraction of max (0.0–1.0)
get_name()string or nilDisplay name
set_name(s)stringnilSet display name. Supports color codes
get_lore()tableArray of lore strings
set_lore(table)tablenilSet lore from array of strings

context.prop FMM

Accessed in FMM prop scripts. Inherits all Entity fields from the backing armor stand.

Properties

FieldTypeDescription
model_idstringBlueprint model name
current_locationlocationProp's current position

Methods

MethodArgsReturnsDescription
play_animation(name, blend?, loop?)string, bool (default true), bool (default true)boolPlay named animation
stop_animation()nilStop all current animations
hurt_visual()nilRed tint flash, no damage
pickup()nilRemove prop and drop placement item
has_mount_points()boolWhether prop has mount point bones
mount(player)entity tableboolMount player onto first available seat
dismount(player)entity tableboolDismount player
get_passengers()tableArray of entity tables for mounted players
spawn_elitemobs_boss(file, x, y, z)string, num, num, numentity or nilSpawn EliteMobs boss (requires EliteMobs)
open_inventory(player, title, rows?)entity table, string, int (default 3)boolOpen persistent chest inventory (1–6 rows). Title supports color codes
place_book(player)entity tableboolStore player's held written book on prop
read_book(player)entity tableboolOpen stored book for reading
take_book(player)entity tableboolReturn stored book to player
has_book()boolWhether a book is stored
drop_inventory()boolDrop all stored items and clear
drop_book()boolDrop stored book and clear
is_viewing_inventory(player)entity tableboolWhether player has this prop's inventory open
set_persistent_data(key, value)string, stringboolStore string in prop's PDC
get_persistent_data(key)stringstring or nilRetrieve string from prop's PDC

Color Codes

All methods marked as supporting color codes use Magmacore's ChatColorConverter. These formats can be mixed freely in any string:

Legacy codes

Use & followed by a color/format character:

CodeColorCodeFormat
&0Black&lBold
&1Dark Blue&mStrikethrough
&2Dark Green&nUnderline
&3Dark Aqua&oItalic
&4Dark Red&rReset
&5Dark Purple
&6Gold
&7Gray
&8Dark Gray
&9Blue
&aGreen
&bAqua
&cRed
&dLight Purple
&eYellow
&fWhite

Hex colors

Exact RGB color using 6-digit hex:

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

Gradients

Smoothly interpolate between two or more colors across the text:

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

The short form g works identically to gradient. You can chain as many color stops as you want.

Rainbow

Cycle through the full hue spectrum. Optional saturation (0–100):

<rainbow>Full rainbow text</rainbow>
<r:50>Pastel rainbow (50% saturation)</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

Any table with a uuid field. Player and entity tables from context work directly:

context.player                              -- valid entity table
context.world:get_nearby_entities(x,y,z,r) -- returns array of entity tables