Charm of Undying
| Charm of Undying |
|---|
The Charm of Undying is a small NeoForge add-on mod that lets a
Totem of Undying protect the player from death while it is worn in a Curios charm slot, instead of being held in a hand. The mod adds no items, mobs, structures, biomes or recipes of its own. It changes one existing mechanic: how a totem is used against lethal damage. In Fear Nightfall it is the means of keeping a second life on the player without giving up a hand or hotbar slot.
Overview
The mod (mod id charmofundying, version 9.1.0 for Minecraft 1.21.1) extends vanilla totem behaviour. In vanilla, a totem only works when it is in the main hand or off hand. With this mod, a totem in the charm slot of the Curios inventory is checked first when the player would die, and it is consumed in place of the held totem. The mod also draws the worn totem on the player's body and plays the usual totem activation feedback.
The mod depends on the Curios API, which the pack runs as version 9.5.1. It also adds two extra Curios slot types to every player entity, described under Content below. The death-protection behaviour is part of the Death and Respawning system, and the effects it applies are Status Effects.
Content
The mod has no items of its own. Its content is limited to the following.
- Totems: the only totem supported on NeoForge is the vanilla
Totem of Undying. Two optional totems from other mods are registered in the code: the Enchanted Totem from Biome Makeover, and the Totem of Freezing and Totem of Illusion from Friends and Foes. Neither of those mods is installed in Fear Nightfall, so only the vanilla totem is active (see In Fear Nightfall below). - Curios slots: the mod adds the slot types
charm,ringandnecklaceto every player. Only thecharmslot is used by the mod's logic. The ring and necklace slots are added but do nothing on their own. - Curios tag: the Curios
charmitem tag contains the Totem of Undying, so the Curios charm slot accepts it. - Renderer: a Curios renderer draws a worn totem on the player's body at the charm slot position. The renderer is covered under Mechanics below.
The mod adds no loot, trades, enchantments, effects, advancements or sounds. It uses the vanilla totem sound and particles.
Mechanics
Death protection from the charm slot
When a living entity would die, the vanilla death-protection check runs. The mod injects into that check and looks at the entity's Curios charm slot. It takes the first stack in the slot that is a registered totem. Only the first matching totem is considered. The mod does not look at the other Curios slots.
When a charm totem is found and used:
- one item is removed from the Curios stack (unless the Totem of Infinity rule applies, see below);
- the player gains the Item Used statistic for the totem and the "used totem" advancement trigger, as with a held totem;
- the effects listed below are applied;
- all players tracking the entity see the totem's activation.
The mixin is injected before the vanilla hand scan. A totem in the charm slot is therefore used before a totem held in either hand, and the vanilla hand scan does not run when the charm totem is used.
Effects of the Totem of Undying
The effects are the same as the vanilla Totem of Undying. The mod applies them from its own code. Durations are given in ticks, at 20 ticks per second.
- health is set to 1 point;
- every active status effect is removed;
- Regeneration II for 900 ticks (45 seconds);
- Absorption II for 100 ticks (5 seconds);
- Fire Resistance I for 800 ticks (40 seconds).
Totem of Infinity
If the Totem of Infinity mod (mr_infinite_totem) is loaded, a worn totem that has the Infinity enchantment at level 1 or higher is not consumed when it saves the player. This check is only active when that mod is installed.
Feedback and rendering
The owner sees the totem activation overlay. Every other player tracking the entity sees 30 Totem of Undying particles on the entity and hears the totem-use sound. The feedback is sent by the mod's own network packet, so clients are expected to have the mod installed.
A worn totem is drawn on the body at the charm slot position, scaled to 0.35 and rotated. It follows the sneak pose. Rendering is controlled by the config options listed under Changes to vanilla below.
Progression
The mod does not gate anything. It makes a totem usable from an accessory slot, so the totem no longer needs a hand or hotbar slot. It does not make held totems obsolete: a totem in a hand is still used when the charm slot is empty.
Changes to vanilla
- Death check: the mod adds a charm-slot check to the vanilla death-protection method. When the charm totem is used, the method returns success and the hand scan is skipped.
- Totem effects: the vanilla Totem of Undying effects are re-applied by the mod's own code, with the same values as vanilla.
- Curios registration: every registered totem item receives a Curios item capability with equipping from use enabled. This allows the totem to be placed in a Curios slot by using it.
- Statistics and advancements: the Item Used statistic and the used-totem advancement trigger fire when the totem is used from the charm slot.
- Config options: four options are registered:
renderTotem(boolean, default true) turns rendering of the worn totem on or off;xOffset,yOffsetandzOffset(decimal, default 0.0, range -100 to 100) move the rendered totem on each axis.
In Fear Nightfall
- Curios: the pack runs Curios 9.5.1, which satisfies the mod's dependency. The slots are provided through Accessories and Curios.
- Optional totems: Biome Makeover, the Totem of Infinity mod and Friends and Foes are not installed in the pack. The Enchanted Totem, the Infinity rule and the Friends and Foes totems therefore have no effect. Only the vanilla Totem of Undying protects the player through the charm slot.
- Accessory overlap: the pack also runs the Accessories mod. Both add accessory slots, and the ring and necklace slots from this mod are added to every player. See Accessories and Curios for how the pack's accessory systems fit together.
- Corpses: the Corpse mod was tested with Curios and accessory slots and works without changes. A charm totem that saves the player prevents the death, so no corpse is created in that case.