This guide describes the public API in the current source version 0.7.2. Use the dependency guidance below and check that the mod is loaded when integrating conditionally.

FFInjury — Modding API

Use this guide when integrating another mod with FFInjury (ffinjury).

Minecraft1.21.1
LoaderNeoForge 21.1.x
Mod IDffinjury
API packagecom.fyxe.ffinjury.api
Source version0.7.2

Dependency (optional):

[[dependencies.yourmod]]
    modId="ffinjury"
    type="optional"
    versionRange="[0.6.0,)"
    ordering="NONE"
    side="BOTH"

Use ModList.get().isLoaded("ffinjury") or an optional compile-only dependency before calling API classes.


Core concepts


Registering custom injuries

Prefer a datapack file so names, icons, effects, and damage weights exist on both sides:

data/mymod/ffinjury/injuries/fracture.json

Id becomes mymod:fracture. See README.md for the full JSON schema.

Code fallback (overridden by datapack JSON with the same id):

import com.fyxe.ffinjury.api.InjuryAPI;

InjuryAPI.registerInjury("mymod:fracture", "Bone Fracture", "minecraft:bone");

All injuries share general.defaultMaxTier. Per-injury max tiers are gone.


Queries

import com.fyxe.ffinjury.api.InjuryAPI;
import com.fyxe.ffinjury.injury.InjuryType;
import net.minecraft.world.entity.player.Player;

boolean any = InjuryAPI.hasAnyInjury(player);
int count = InjuryAPI.getInjuryCount(player);
int hurtLevel = InjuryAPI.getHurtLevel(player);          // max tier, 0 if none
InjuryType type = InjuryAPI.getInjuryType("bleeding").orElse(null);
boolean has = InjuryAPI.hasInjury(player, type);
int tier = InjuryAPI.getTier(player, type);
boolean treated = InjuryAPI.isTreated(player, type);
boolean healing = InjuryAPI.isHealing(player, type);
boolean adrenaline = InjuryAPI.isAdrenalineActive(player);
long expireTick = InjuryAPI.getAdrenalineExpireTick(player);
Optional<ActiveInjury> ai = InjuryAPI.getActiveInjury(player, type);

List<ActiveInjury> list = InjuryAPI.getInjuries(player); // unmodifiable
Collection<InjuryType> allTypes = InjuryAPI.getRegisteredInjuryTypes();

boolean suppressed = InjuryAPI.isGameplaySuppressed(player);
boolean hurtOn = InjuryAPI.isHurtLevelEnabled();
double regenMul = InjuryAPI.getHurtLevelRegenMultiplier(player); // 1.0 if feature off

Config mirrors:

boolean creative = InjuryAPI.areInjuriesEnabledInCreative();
int maxActive = InjuryAPI.getMaxActiveInjuries();
int maxTier = InjuryAPI.getDefaultMaxTier();

Built-in convenience constants still exist: InjuryType.BLEEDING, InjuryType.BURN, etc.


Mutations (server only)

InjuryAPI.setInjuryTier(player, type, 2);           // 0 removes
int newTier = InjuryAPI.addOrIncreaseInjury(player, type);
InjuryAPI.reduceInjury(player, type, 1);
int healed = InjuryAPI.healTiers(player, 2);
InjuryAPI.treatInjury(player, type, 60);            // treat 60s + start heal timer
InjuryAPI.clearAllInjuries(player);
InjuryAPI.grantAdrenaline(player, 20 * 15);

All mutations refresh potion effects, attribute modifiers, sync the client HUD, and fire the relevant API events.

Raising a tier via setInjuryTier / addOrIncreaseInjury clears that injury's treated and heal timers.


Events (NeoForge bus)

Listen with @SubscribeEvent on NeoForge.EVENT_BUS.

EventCancellableWhen
InjurySelectEventYesAfter damage-table selection, before apply. Can change type.
InjuryAppliedEventNoAfter an injury is added or tier increased.
InjuryHealedEventNoWhen tiers are reduced (sleep, apple, bandage heal, API, tick heal).
InjuryTreatedEventNoWhen a bandage or InjuryAPI.treatInjury starts treatment. getTreatmentItem() may be empty for API calls.
AdrenalineGrantedEventYesBefore adrenaline is applied; can adjust duration.

Package: com.fyxe.ffinjury.api.event.

Example:

@SubscribeEvent
public void onSelect(InjurySelectEvent e) {
    if (e.getInjuryType().getId().equals("bleeding")) {
        e.setCanceled(true); // block bleeding from this hit
    }
}

Injury types

Resolve by id: InjuryType.fromId("bleeding") or InjuryType.of("bleeding") (fallback handle).

Default IDDisplay
twisted_ankleTwisted Ankle
ankle_fractureAnkle Fracture
broken_legBroken Leg
bruised_ribsBruised Ribs
broken_ribsBroken Ribs
concussionConcussion
bleedingBleeding
burnBurn

InjuryType live-resolves display name, description, icon, effects, and attributes from the current datapack definition.


ActiveInjury

ActiveInjury ai = ...;
InjuryType type = ai.getType();
int tier = ai.getTier();
boolean treated = ai.isTreated(currentGameTick);
boolean healing = ai.isHealing();
long treatedUntil = ai.getTreatedUntilTick();
long healAt = ai.getHealAtTick();

Do not call setTier / timer setters from other mods unless you also refresh status and sync. Prefer InjuryAPI.


Hurt level (datapack)

Path: data/<namespace>/ffinjury/hurt_levels/<id>.json

{
  "min_hurt_level": 2,
  "stop_regen": false,
  "regen_multiplier": 0.5,
  "effects": [
    { "effect": "minecraft:slowness", "amplifier": 0 }
  ],
  "attributes": [
    { "attribute": "minecraft:generic.movement_speed", "amount": -0.05, "operation": "add_multiplied_total" }
  ]
}

Matching rules (hurt >= min_hurt_level) combine: lowest regen multiplier wins, any stop_regen stops regen, effects/attributes stack. Feature toggle: hurt_level.enabled (default false).


Attribute modifiers

Operations: add_value, add_multiplied_base, add_multiplied_total.

Applied by InjuryStatusApplier and suppressed by adrenaline / treatment / creative gameplay suppression.


Notes for integrators