Skip to content

SlimeeyYt/UniversalTotem

Repository files navigation

Universal Totem

Universal Totem is a Fabric mod for Minecraft 1.21.1 that makes any item held in the player's main hand behave like a Totem of Undying when the player would otherwise die.

What it does

When a player takes fatal damage:

  • Vanilla Totem of Undying still has priority if one is present in either hand.
  • If no real totem activates, the mod checks the player's main hand.
  • If the main-hand stack is not empty, the player is saved.
  • Exactly one item is consumed from the held stack.
  • The vanilla-style death protection effects are applied:
    • Health set to 1 HP
    • Regeneration II
    • Absorption
    • Fire Resistance
    • Burning is cleared
  • Vanilla totem particles and sound are triggered.
  • The floating activation animation shows the actual consumed item, not a totem.

Ignored cases

The custom mechanic does not activate for:

  • Empty main hand
  • Creative mode players
  • Spectator mode players
  • Damage sources that also bypass vanilla Totem of Undying protection

Project layout

  • src/main/java/com/slimeeystudios/universaltotem/UniversalTotemMod.java – common mod initializer
  • src/main/java/com/slimeeystudios/universaltotem/UniversalTotemClient.java – client packet registration
  • src/main/java/com/slimeeystudios/universaltotem/mixin/LivingEntityMixin.java – death protection logic
  • src/main/java/com/slimeeystudios/universaltotem/network/ – custom animation payload handling
  • src/main/resources/fabric.mod.json – Fabric metadata
  • src/main/resources/universaltotem.mixins.json – mixin config

Build

Use a Java 21+ Gradle environment.

gradle build

Run a development client

gradle runClient

Notes

The mod is implemented with a mixin into vanilla death-protector logic so that a real Totem of Undying always activates first. A small custom S2C packet then replaces the floating totem item with the exact consumed stack on the saved player's client.