Skip to content

For Mod Developers

Drehverschluss edited this page Nov 26, 2026 · 3 revisions

For mod developers

The bridge is built so that more mana mods can be added without changing its core. Every mana mod is an adapter with the same interface. The core never touches a class of another mod; it talks to adapters and to RunelessRPG's public API only.

Experimental. The interface below is marked @ApiStatus.Experimental and may still change before version 1.0. In this version the list of adapters is fixed inside the bridge; there is no way yet to register an adapter from another mod. If you would like to connect your mana mod, please open a feature request.

The shared pool itself runs through RunelessRPG's API for other mana systems (replaceable ManaStorage, debt account, canAfford / spend for other spells, getManaBonus, Spell Mana Leech predicates, display factor). It is documented in the RunelessRPG wiki → API and events → Other mana systems. A mod can also use that API directly, without this bridge.

The bridge 0.2.0 needs RunelessRPG 0.4.1 or newer: 0.4.1 added the methods for Overcharge on spells of other mods to RunelessApi (getOverchargeCostFactor, getCostMultiplierWithOvercharge, getOverchargeBonus(Player), getOverchargeDamageFactor, overchargeAffectsHealing, overchargeAffectsSummons, getOverchargeSnapshot and setOverchargeSnapshot), see RunelessRPG wiki → Overcharge for other spells.

The interface ManaAdapter

Package com.drehverschluss.runelessrpg_bridge.api. All amounts are in the adapter's own mana units; the core converts them with the factor "1 own mana = factor RunelessRPG mana".

Method Default Purpose
String modId() – Mod ID of the mana mod; also the name of its config section
String displayName() modId() Name for config comments, logs and the status command
double baseMaxMana(Player) – Base max mana in own units (Iron's: 100, Ars: its baseMax, 100); the automatic factor is RunelessRPG's base ÷ this value
void defineConfig(ModConfigSpec.Builder) nothing Own options in its section; the core adds enabled, manaFactor, applyManaCost and the three bridge… switches first
void defineClientConfig(ModConfigSpec.Builder) nothing Own client options in [display] of the client config, created for every known adapter (Ars: forwardInsufficientFlash)
void init(IEventBus, AdapterStatus) nothing Register listeners (mod construction)
void initClient(IEventBus, AdapterStatus) nothing Client part, during client setup
List<String> requiredClasses() empty Classes the self test needs
String mixinConfig() null The adapter's mixin config; the self test checks that every mixin was applied and every injector found its target
List<ResourceLocation> hudLayers() empty HUD layers of the mod's mana bar, for manaDisplay
boolean isCastingItem(ItemStack) false Casting items of the mod, for the "contextual" visibility of other bars
List<ConflictCheck> conflicts() empty Other bridges at the same pool, each with a check whether its mana function is on
boolean canLead() false Whether the mod can lead the pool (manaSystem)
ManaStorage createStorage() null The storage for RunelessRPG's API while the mod leads
boolean spellsPaidByOtherBridge() false (since 0.2.0) Server side: whether another bridge pays this mod's spells itself right now (Ars 'n Spells). The server sends it to the clients, which then show the costs without mana_cost and overcharge of the bridge and no overcharge line
LeadInfo leadInfo(Player) null (since 0.2.0) What the mod's pool brings while it leads, read from the mod's real config: LeadInfo(baseMaxMana, regenPerSecond, regenPercentPerSecond) in own units (Iron's: 100, 0, 2; Ars: 100, 5, 0). Shown in the question at the first start, in the chat line and in the tooltips of the manaSystem button. null: only the base max mana is shown
BridgeBonus readBonus(Player) none The mod's own bonuses above its base values, by operation, without the bridge's own modifiers; the core filters them with the three bridge… switches
BridgeBonus readExtraBonus(Player) none Bonuses with switches of the adapter itself, not filtered by the core (Ars: progress with bridgeProgression, the familiars' reserve with applyFamiliarReserve)
void applyBonus(Player, BridgeBonus) nothing The other mods' bonuses while this mod leads; BridgeBonus.NONE removes them

AdapterStatus tells the hooks at any time whether the adapter is connected (isConnected), leads (isLeading) or follows (isActive), on both sides (on a client as the server sent it). Since 0.2.0 isOffInChain() is true on the server while the adapter is off only because another adapter runs in a chain with the bridge that blocks this one (Ars 'n Spells on ars_primary: the Ars adapter runs, the Iron's adapter is off); then the mod's own regeneration would still flow into the shared pool through the other bridge, so the adapter may turn it off anyway, as the Iron's adapter does. BridgeBonus is a record with flat, base-percent and total values for max mana and regeneration and a reserve (the bound share of the max mana, 0 … 1; the old constructor with six values stays). The leading mod gets the reserve as its own modifier runelessrpg_bridge:bridge_max_reserve (× (1 − reserve) on the total). ConflictCheck is a record of another bridge's mod ID, a check whether its mana function is on (isActive) and a check whether it works in a chain with this adapter (chained; then the adapter stays on; the constructor with two values and ConflictCheck.always(modId) stay).

Added for Ars

Ars as the second adapter needed four additions to the interface: readExtraBonus, defineClientConfig, the field BridgeBonus.reserve and the field ConflictCheck.chained. All four have defaults (or the old constructors), so an adapter that does not need them does not have to know them.

Added in 0.2.0

  • ManaAdapter.leadInfo(Player) and the record api/LeadInfo (see the table above), so the question and the config screen can show real numbers for every mod that can lead.
  • AdapterStatus.isOffInChain() (see above).
  • ManaAdapter.spellsPaidByOtherBridge() (see the table above).
  • Overcharge for an adapter's spells goes through core/Overcharge, which uses no class of another mod. It is in core, not in the api package: the bridge's own adapters use it, and it may change more freely. Costs need nothing extra, because every cost of an adapter already goes through Pool.costMultiplier (with applyManaCost and applyOvercharge of the adapter). For the effect an adapter raises the hits of its own spell damage events with Overcharge.bonus(player, modId) and reports them with Overcharge.handled(source), and it registers three small interfaces:
Interface Registered with Answers
Overcharge.SpawnSource addSpawnSource For an entity that joins the world during a paid cast: its Mark(multiplier, kind) (the snapshot), or null
Overcharge.HitSource addHitSource For a hit that belongs to a paid cast running right now but does not go through the mod's own damage event (an Ars explosion, other damage sources during an Iron's cast): the multiplier, or NaN if the adapter does not know the hit
Overcharge.KindSource addKindSource For an entity of the mod: Kind.ZONE for zones and summons (bonus only with overchargeAffectsSummons), Kind.DIRECT for projectiles and similar, or null

The snapshot is RunelessRPG's own (setOverchargeSnapshot) plus an entity tag of the bridge (runelessrpg_bridge.overcharge_zone or runelessrpg_bridge.overcharge_direct), so the bridge only reads snapshots it set itself and never raises a Spell Engine summon twice. Healing goes through Overcharge.pendingHeal(target, multiplier) and NeoForge's LivingHealEvent. Examples: IronsOvercharge and ArsOvercharge in the two adapter packages.

How an adapter is built

Every adapter has two parts:

  • The description (IronsAdapter for Iron's, ArsAdapter for Ars): mod ID, config section, other bridges, bar layers. It uses no class of the mod and is created for every known mod, also while the mod is missing, so its config section stays in the file.
  • The hooks: mixins, listeners, the storage, everything with classes of the mod. They are only reached from methods the core calls while the mod is loaded.

Further rules both adapters follow:

  • An own package adapter/<modid>/ and an own mixin config, listed in the mod file with requiredMods = ["<modid>"], so Mixin does not even load it without the mod. A mixin plugin applies the mixins only while the mod is loaded.
  • Only @Inject, @WrapOperation and @ModifyReturnValue, every injector with require = 0. No @Overwrite, no @Redirect.
  • Self test: if a required class is missing or a mixin was not applied, only this adapter turns off, with exactly one warning; the game always starts.
  • Only real players: no mobs, no fake players.
  • Every hook checks the AdapterStatus first; "follows" hooks (redirect the mod's own mana, own regeneration and respawn rule off) and "connected" hooks (costs, leech, displays) are separate, because the state can change at runtime.
  • Costs of the mod's spells go through the core (Pool): effective cost with Mana Cost, the same check on client and server, payment through RunelessApi.spend with the debt rules.

The sources of both adapters are complete examples:

  • adapter/irons_spellbooks: a mod with a mana field (MagicData), cost hooks in the spell base class, a percent regeneration attribute and entity tags for leech.
  • adapter/ars_nouveau: a mod with a mana capability, costs checked and paid at the caster, attributes with the base value 0 and one collecting modifier, progress and a reserve through readExtraBonus, changes of addons in calculation events, leech by the glyphs of the spell and a client option of its own.

Adding a mod to the core takes one line in core/Adapters; everything else lives in the adapter's own package.

Clone this wiki locally