Mental effects
Point-based resistance, source-aware charm control and hallucination feedback.
Mental disruption uses one server landing roll and entity-owned control state. Charm and Hallucination share resistance and duration policy, while separate client controllers handle steering and screen distortion.
What it does
internal.mental is an internal implementation, not a public facade. MentalStatusEffect identifies effects that use the mental contest and the CC duration category. Player-facing rules are in attributes and effects and the effect catalogue.
| Parameter | Value |
|---|---|
| Mental Resistance / Mental Interference | Default 0; registered range -10000–10000; ordinary design range 0–100 points. |
| Charm base intensity | 70 |
| Hallucination base intensity | 65 |
| Intensity per amplifier | 15 |
| Landing chance | clamp((intensity + interference - resistance) / 100, 0, 1) |
Points never use the combat ratio normaliser. Missing attribute instances fall back to the registered default. No caster means 0 interference. A projectile resolves its living owner; an unrelated nearby player never becomes the caster. Team and barrier protection precede the roll, and tenacity shortens successful control afterwards. Mental effects do not also roll Debuff Accuracy.
Runtime model
State and control
MentalStateMixin adds the attributes to the standard living-attribute builder and attaches MentalControlState to each living entity. Successful Charm application records the caster UUID only when the incoming amplifier is at least the previous active amplifier. Rejected or weaker hidden applications cannot steal ownership. Source-free application still dazes.
MentalEffects.interrupt stops item use, requests Spell Engine cast cancellation and stops running goal/target tasks and conflicting brain tasks. Action gates cover attacks, swings, item use, cast attempts and spell delivery. Hallucination participates in the same AI-disabled path as Stagger. Charm replaces MobEntity.tickNewAi orchestration while retaining the entity’s navigation, move, look and jump controllers; it does not clone or replace the brain.
| Charm amplifier | Mob control | Player control |
|---|---|---|
0 | Drop target, stop navigation and occasionally look around. | Hold movement input. |
1 | Approach the living caster, without acquiring combat targets. | Steer towards the caster; hold within 2.5 blocks. |
2+ | Follow and defend the caster, using shared allegiance filters and the existing charm command system. | Same approach control. |
| Caster missing/dead/unloaded | Daze until a valid caster resolves or the effect ends. | Hold input. |
Protection can select a recent attacker within 100 ticks (5 seconds), plus hostile targeting threats recognised by CharmedThreatTargeting. Target refresh runs every 10 ticks (0.5 seconds). RangedAttackMob uses its native ranged method with a 30-tick (1.5-second) interval within 12 blocks; other attack-capable mobs use native melee with a 20-tick (1-second) interval. Sight and target validity still gate attacks. This common control path supports goal and brain AI; custom attacks implemented outside that path require their own integration tests.
Removing the effect releases movement and targeting state. Natural goal/brain scheduling resumes without reconstructing the brain. A world lookup resolves the UUID; there is no global map retaining unloaded entities.
Persistence and feedback
| Field | Type | Default | What it does |
|---|---|---|---|
MentalCharmCaster | UUID int array | Absent | Living-entity NBT caster identity; runtime goal, cooldown and packet state are rebuilt. Cleared when Charm is absent. |
MentalSourcePacket sends only the resolved caster entity ID to the affected player when that ID or dimension changes. The client releases its dedicated MENTAL locomotion claim on expiry, death, spectator mode, world change and disconnect. Dialogue and cinematic claims retain higher priority. Hallucination holds input; Charm approach turns by at most 6 degrees per tick and uses 0.65 movement input.
MentalDistortionController composites shaders/post/mental_distortion.json through Satin. Hallucination uses violet/cyan ripple and split vision; Charm adds rose peripheral bloom and inward focus. Intensity changes by at most 0.1 per tick. The animation clock starts from zero when a disruption begins, advances only with unpaused ticks and wraps every 600 ticks (30 seconds); every timed motion completes whole cycles in that loop, so a long disruption repeats without a seam. World/player replacement clears sampled state, disconnect releases framebuffers on the client thread and Iris shadow passes are skipped. Colour-only compositing preserves scene depth. The shader lives under assets/isekaiexpansion/shaders/program/mental_distortion.fsh; the effect icons are textures/mob_effect/hallucination.png and textures/mob_effect/charm.png.
Contracts
Apply effects on the server with target.addStatusEffect(instance, caster) to retain source identity. Do not substitute the nearest player or directly mutate the active-effect map. The normal landing roll can reject an otherwise valid application, including at exactly 0 chance. The built-in attributes are not immunities: sufficiently high interference can overcome resistance beyond 100.
The client shader communicates disruption; server action and AI gates own gameplay. The shared mob controller uses native navigation and generic ranged/melee capability. It cannot promise that another mod’s custom tick loop or boss-specific attack animation obeys those hooks without testing that implementation.
Extending it
Register a MentalStatusEffect with an explicit nonnegative finite base intensity, localisation and an effect icon. Keep a new behaviour’s runtime state on the affected entity and clear its movement/target claims when it ends. Add source-aware tests and both locale references when introducing another mental effect; hallucination and charm behaviour dispatch currently uses their registered identities.
Dungeon authoring can scale these attributes through mob_difficulty. Lucid Mind adds temporary resistance, while Mirror Malice attempts Hallucination through the same application path. Their data and balance are documented in dungeon data.
Verifying
Run compileJava and the focused gameplay checks. In a client/server test world, compare chances at zero, fractional, negative and attributes beyond 100; test no caster, projectiles, weaker refreshes and same-team rejection. Save/reload a charmed mob and disconnect/rejoin the caster.
Test a zombie, skeleton, piglin and a brain-driven custom NPC at every strength, including recent-attacker defence, unreachable paths and effect expiry. Verify that the caster and party are never selected. Check a player while casting, using items, moving, falling, opening dialogue, dying and changing dimensions. Inspect the shader with and without Iris, while paused and after resource reload; this document does not certify those in-game checks as completed.