Magic NPCs: Compatibility & NPC Mods
On this page (8)
Magic NPCs is designed around strict soft-dependency isolation: every integration loads only when its host mod is installed, never bundles third-party jars or assets, and combines safety rules across all applicable adapters (most restrictive wins).
Iron’s Spells ‘n Spellbooks and add-ons
- Supported Iron’s range:
[1.20.1-3.15.0, 1.20.1-3.17.0). - Built-in spell manifest: Covers 111 verified Iron’s spells checked against
1.20.1-3.16.4(SpellManifest.VERIFIED_AGAINST), reconciled against the live registry on server startup. - Iron’s add-on spells: Start as
UNVERIFIED(refused safely without spending mana) until declared via a datapack spell manifest (data/<ns>/spell_manifests/*.json), config override (spells.capabilityOverrides), namespace trust (spells.trustedNamespaces), orspells.allowUnverifiedSpells = true. See Iron’s add-ons guide.
Compiled NPC integrations
Villager Recruits (recruits 1.15.0+)
- Adapter priority:
100(RecruitsAdapter). - Diplomacy and targeting: Routes target and ally checks through
AbstractRecruitEntity.shouldAttack(...), protecting owners and non-hostile fellow recruits. - Command state respect: Recruits set to passive/flee (
state == 3) never cast attack spells, though they may still use self-healingsupportspells. - Progression scaling: Max mana scales by
1 + getXpLevel() * recruits.manaPerLevel; spell level scales above the loadout floor viabalance.rankLevelPerRank/rankLevelMaxBonus. - Movement policies (when
"native_attack": "suppress"):- Moving to a position or holding formation (
getShouldMovePos(),isInFormation,holdFormation) →PINNED(casts from place). - Holding position (
getShouldHoldPos()) →ANCHOREDwith a4.0-block leash aroundgetHoldPos(). - Following owner (
getShouldFollow()/isFollowing()) →ANCHOREDwith a12.0-block leash around the owner.
- Moving to a position or holding formation (
- Shipped loadouts:
recruit,bowman,crossbowman,captain(toggled under[builtinLoadouts]). - Safety guarantee: Turning
recruits.enabled = falsestops recruits from casting, while owner and ally protection stays active.
Easy NPC (easy_npc 7.11.0 – <8.0)
Magic NPCs compiles against Easy NPC: Core (easy_npc); the separate easy_npc_config_ui module is optional. Both compat.easynpc (in magicnpcs-common.toml) and easynpc.enabled (in magicnpcs-server.toml) default false so hand-authored Easy NPCs never start casting unexpectedly.
- Owner and faction safety: Protects the Easy NPC’s owner, same-owner
OwnableEntitysiblings (even while offline), and same-faction entities (wheneasynpc.respectFactions = trueandFactionHandler.isHostile(...)isfalse). Owner/faction safety stays active even wheneasynpc.enabled = false. - Pause and navigation: Paused NPCs (
EasyNPCPauseHandler.isPaused) cannot cast either attack or support spells. Undernative_attack: suppress,isImmovable()maps toPINNED, andhasHomePosition()maps toANCHORED(6.0-block leash around home). - Level scaling: Uses Easy NPC progression level (
0–60) witheasynpc.manaPerLevel(default0.02) and global rank spell-level scaling. - Entity variant IDs: Easy NPC registers separate types (
easy_npc:humanoid,easy_npc:humanoid_slim,easy_npc:villager,easy_npc:orc,easy_npc:skeleton, etc. — see Loadout examples for the full list). - Custom action (
CUSTOM):magicnpcs:cast <spell_id> [level] [self|target](for examplemagicnpcs:cast irons_spellbooks:heal 2 self; bare spell IDs default toirons_spellbooks:). Unqualified casts aim at the NPC’s combat target or fall back to the triggering player (never an ally), and refuse safely if no valid target exists. - Dialog conditions:
magicnpcs:has_school(optional school ID incustomData),magicnpcs:can_cast(goal present and not paused/blocked), andmagicnpcs:has_mana(requires at leastvaluemana, default1). - Custom objective:
magicnpcs:cast_spell(controlled byeasynpc.useObjective), attaching the reconciled casting goal at the objective’s priority while keepinghasTravelObjective() = false.
CustomNPCs (GBPort Unofficial 1.20.1.20260711)
Magic NPCs reaches CustomNPCs through a version-gated reflective bridge (CustomNpcsCompat). Only exact builds listed in CustomNpcsCompat.SUPPORTED_VERSIONS (1.20.1.20260711) activate; other builds report PRESENT_UNSUPPORTED in /magicnpcs config and leave CustomNPCs unmanaged across loadouts, schools, Tome, commands, and casts.
- Opt-in defaults:
compat.customnpcs = falseinmagicnpcs-common.toml(gatescustomnpcs:*loadouts) andschools.customnpcs.enabled = falseinmagicnpcs-server.toml, whilecustomnpcs.bridgeEnabled = trueandcustomnpcs.scriptGlobalEnabled = truecontrol the bridge itself. - Authored configuration respect:
- Factions & ownership: Never attacks its owner, same-faction NPCs, or players with
playerStatus == 1(friendly) whencustomnpcs.respectFactions = true. - Retaliation AI: NPCs whose retaliate mode is not
fight(0) never cast attack spells. - Dialog pause: Casting pauses and active casts cancel when a dialog opens (
customnpcs.pauseDuringDialog = true). - Blocked jobs & roles:
customnpcs.blockedJobs(default["puppet", "builder"]) andcustomnpcs.blockedRoles(default[]) bar matching NPCs from casting. - Movement mapping:
stationary(0),path(2), and escort roles (follower,companion) map toPINNED;wander(1) maps toANCHOREDaround home usinggetWanderingRange(). - AI-rebuild repair: When
customnpcs.repairAfterAiRebuild = true, Magic NPCs queues a reconcile whenever CustomNPCs rebuilds an NPC’s goal selectors so injected goals and suppression wrappers are preserved. - Inventory sync: Held equipment from loadouts/focuses is applied through CustomNPCs’ own inventory API so held items are not overwritten on tick.
- Factions & ownership: Never attacks its owner, same-faction NPCs, or players with
npc_traitsloadout conditions: Loadouts targetingcustomnpcs:customnpccan match authored traits underconditions.npc_traits(all_of,any_of,none_of) using these trait namespaces:customnpcs:role/<name>(none,trader,follower,bank,transporter,postman,companion,dialog)customnpcs:job/<name>(none,bard,healer,guard,item_giver,follower,spawner,conversation,chunk_loader,puppet,builder,farmer)customnpcs:retaliate/<mode>(fight,panic,avoid,none)customnpcs:moving/<mode>(stationary,wander,path)customnpcs:navigation/<type>(ground,flying,swimming)customnpcs:faction/<id>(numeric faction ID)
- Script bridge:
- Triggers (
customnpcs.scriptTriggerId, default8800): Fires oncast_pre,cast_started,cast_completed,cast_cancelled,cast_failed, andschool_changedwith arguments(npc, "magicnpcs:v1", signalName, spell, level, target, source, reason, old_school, new_school, mode). - Veto handshake (
cast_pre): Write1or"1"tonpc.getTempdata().set("magicnpcs.cancel.v1", 1)insidecast_preto cancel the cast before mana/cooldown are charged. - Script global (
MagicNPCs): Read methodsisCaster(npc),getSchool(npc),getLoadout(npc),getMana(npc),getMaxMana(npc),canCast(npc, spell, level),why(npc)and mutation methods (whenscriptMutationsEnabled = true)setSchool(npc, school),clearSchool(npc),returnToAuto(npc),setCastingSuspended(npc, suspended),cast(npc, spell, level, target). Every call returns aResult(getCode(),getMessage(),getValue(),isOk()) with numericResultCodevalues (0OK..16UNSUPPORTED_NPC_BUILD). - Stored-data mailbox: Write
magicnpcs.request.v1.op, optionalmagicnpcs.request.v1.seq, andmagicnpcs.request.v1.arg.<school|spell|level|target|suspended>tonpc.getStoreddata()and readmagicnpcs.result.v1.code,.message,.value,.seqon the next update tick. - Example NPC loadout ships disabled at
data/magicnpcs/spellcasters/customnpcs_example.jsoninside the mod JAR.
- Triggers (
Generic adapters and config-gated NPC mods
These vanilla-based adapters run with zero mod dependencies whenever enabled:
OwnableTeamAdapter(targeting.protectOwners = true) — Protects owners (by UUID even when offline), same-ownerOwnableEntitysiblings, and shared scoreboard teams (covers Human Companions and tamed-based followers).RaidAllyAdapter(targeting.protectRaidAllies = true) — Prevents raiders in the same activeRaidfrom hitting each other with attack spells.SittingPetAdapter(targeting.sittingPetsMayCast = false) — Prevents sittingTamableAnimalcompanions from casting attack or support spells.
Config-gated [compat] mods (Guard Villagers, MCA Reborn, MineColonies, Human Companions, More Villagers, VillagersPlus) enable datapack loadouts for their entity IDs when toggled true in config/magicnpcs-common.toml. See Loadout examples for templates and caveats.
Modded mobs and common conflicts
- Attribute caps (
[MANA_CLAMPED]): Mods or vanilla attribute caps limitingirons_spellbooks:max_manacan clamp highmax_manavalues; install AttributeFix or adjust caps in Apothic Attributes if needed. - Brain-driven mobs (
[BRAIN_AI],[GOAL_NOT_EVALUATED]): Mobs driven purely by Minecraft’sBrainor custom tick loops without runningGoalSelector(such as some SmartBrainLib / Occultism or custom boss entities) may never tick injected goals. Run/magicnpcs why <targets>to checkgoal heartbeatand goal lists. - Unrecognized native attack goals: If
"native_attack": "suppress"leaves a modded ranged/melee attack running,/magicnpcs why <targets>listscandidate attack goals not matched. Add the reported class name togeneral.suppressibleAttackGoalsor add a regex togeneral.attackGoalNamePatterns.
Client/server sync and mod removal
- Server-authoritative: All casting decisions, cooldowns, mana, targeting, and telegraphs run on the server.
magicnpcs-server.tomlsyncs automatically to clients on login; telegraphs broadcast vanilla particles and sounds to nearby clients. - Removing Magic NPCs: Loadouts and spells live in datapacks and Forge entity
ForgeData/scoreboard tags (magicnpcs.school,magicnpcs.telegraph). Removing Magic NPCs drops all injected AI goals on next load without breaking world saves (existing School Tome items become missing items on removal).