Skip to content
Sleys edited this page Jul 29, 2026 · 5 revisions

Developer API

This page is aimed at mod/addon developers building on top of SLM: Elements. It documents the public, stable API classes intended for external use.

These classes are final with private constructors — they're pure static utility APIs, safe to call from anywhere (items, entities, event handlers, other mods).

Contents


ElementAPI

ElementAPI is the main entry point for reading and writing elemental state on an ItemStack. Elemental state is stored via data components (ElementsRegistryDataComponents).

Applying elements

Method Description
applyElement(ItemStack, ElementsType) Infuses the stack with an element permanently.
applyTemporaryElement(ItemStack, ElementsType, int ticks) Infuses the stack with an element that expires after ticks.
applyAndConsumeElement(ItemStack, ElementsType) Infuses the stack with an element flagged to be consumed on use (single application).

Querying elements

Method Description
getElement(ItemStack) Returns Optional<ElementsType> — the currently applied element, if any.
hasAnyElement(ItemStack) true if the stack has any element applied.
hasNotAnyElement(ItemStack) Inverse of hasAnyElement.
hasElement(ItemStack, ElementsType) true if the stack has that specific element.
hasNotElement(ItemStack, ElementsType) Inverse of hasElement.
isTemporaryElement(ItemStack) true if the stack's element is time-limited and still active.
getElementTicks(ItemStack) Remaining ticks for a temporary element (0 if none).
isConsumeElement(ItemStack) true if the stack's element is flagged as consumable.

Removing elements

Method Description
removeElement(ItemStack) Clears the elemental value entirely.
removeTimedElement(ItemStack) Clears the elemental value and its tick-duration component.
removeConsumerElement(ItemStack) Clears the elemental value and its consumer-flag component.

Example

// Infuse a sword with Ignis for 200 ticks
ElementAPI.applyTemporaryElement(sword, ElementsType.IGNIS, 200);

// Check before applying combat logic
if (ElementAPI.hasElement(sword, ElementsType.IGNIS)) {
    // trigger Ignis-specific behavior
}

// Read the element defensively
ElementAPI.getElement(sword).ifPresent(element -> {
    // do something with the current element
});

InternalCooldownDealerAPI

Controls whether the ICD system (see Combat Mechanics) is active for a given LivingEntity.

Method Description
enable(LivingEntity) Enables ICD for this entity.
disable(LivingEntity) Disables ICD for this entity. No metadata or elements will be transferred upon impact.
isEnabled(LivingEntity) true if ICD is currently active for this entity.
isDisabled(LivingEntity) Inverse of isEnabled.

Example

// Disable the transfer of elements; we will only use the pipeline's damage functions.
InternalCooldownDealerAPI.disable(player);

// Later, check state before applying custom logic
if (InternalCooldownDealerAPI.isDisabled(player)) {
    // special condition, we will allow the player to transfer elements on impact
}

See also: Combat Mechanics · Elements

Clone this wiki locally