Skip to content

Preserve Items on Death

JackFred2 edited this page Jan 10, 2024 · 10 revisions

The primary feature of the mod, Lenient Death allows you to preserve specific items on death. You can think of it as a filtered /gamerule keepInventory.

Images

A GIF showing a player dying and keeping their armour and tools, but not ores

Per-Player

This feature can be used on a Per-Player basis, with either the users able to opt in/out or it being controlled on the server-side (by admins or a permission). For more information, see it's specific page.

Evaluation Order

When deciding if an item should be preserved, the following order of evaluation will be used:

  1. NBT Key Checking
  2. Always Dropped Filters
  3. Always Preserved Filters
  4. Item Type Checking
  5. Randomizer

If none of the above give a decision, the item will default to being dropped.

You can use a utility command to see if an item will be preserved.

Configuration

$.preserveItemsOnDeath.enabled

Whether as a whole, items should be preserved on death based on certain criteria.

  • Options:
    • yes - Enabled for everyone.
    • per_player - Enabled on a Per-Player basis.
    • no - Disabled for everyone.
  • Default: yes
  • Commands:
    • /ld config preserveItemsOnDeath enabled - Check if item preservation is enabled.
    • /ld config preserveItemsOnDeath enabled <yes|per_player|no> - Change if item preservation is enabled.

NBT Key Checking

Items can be checked for a given NBT tag to see if it should be preserved. This can be used to ad-hoc your own Soulbound mechanic. Note that Lenient Death won't add this tag to items for you, they'll have to be added by another method.

To give yourself an example item that is preserved with the default key:

  • /give @s minecraft:diamond_block{Soulbound: 1b}

$.preserveItemsOnDeath.nbt.enabled

Whether items should be checked for a given NBT tag for preservation.

  • Options: true, false
  • Default: false
  • Commands:
    • /ld config preserveItemsOnDeath nbt enabled - Check if NBT checking is enabled.
    • /ld config preserveItemsOnDeath nbt enabled <true|false> - Change if NBT checking is enabled.

$.preserveItemsOnDeath.nbt.nbtKey

Which NBT boolean key should be checked.

  • Options: A single-word NBT key.
  • Default: Soulbound
  • Commands:
    • /ld config preserveItemsOnDeath nbt nbtKey - Check the current NBT key.
    • /ld config preserveItemsOnDeath nbt nbtKey NeverDropped - Change the checked NBT key to 'NeverDropped'.

Always Dropped Filters

This section allows you to specifically define items and / or item tags that will always be dropped, regardless of following settings. Note that any IDs/Item Tags that aren't recognized will be ignored, and a warning logged to the console.

$.preserveItemsOnDeath.alwaysDropped.items

What item IDs should always be dropped, regardless of following settings?

  • Options: A list of item IDs.
  • Default: []
  • Commands:
    • /ld config preserveItemsOnDeath alwaysDropped items - Check the current always-dropped item IDs.
    • /ld config preserveItemsOnDeath alwaysDropped items add <id> - Add an item ID to the always dropped list.
    • /ld config preserveItemsOnDeath alwaysDropped items remove <id> - Remove an item ID from the always dropped list.

$.preserveItemsOnDeath.alwaysDropped.tags

What item tag IDs should always be dropped, regardless of following settings?

  • Options: A list of item tag IDs.
  • Default: []
  • Commands:
    • /ld config preserveItemsOnDeath alwaysDropped tags - Check the current always-dropped item tag IDs.
    • /ld config preserveItemsOnDeath alwaysDropped tags add <id> - Add an item tag ID to the always dropped list.
    • /ld config preserveItemsOnDeath alwaysDropped tags remove <id> - Remove an item tag ID from the always dropped list.

Always Preserved Filters

This section allows you to specifically define items and / or item tags that will always be preserved, regardless of following settings. Note that any IDs/Item Tags that aren't recognized will be ignored, and a warning logged to the console.

By default, the item tag lenientdeath:safe will be preserved, allowing you or other mods to use a datapack to configure the mod.

$.preserveItemsOnDeath.alwaysPreserved.items

What item IDs should always be preserved, regardless of following settings?

  • Options: A list of item IDs.
  • Default: []
  • Commands:
    • /ld config preserveItemsOnDeath alwaysPreserved items - Check the current always-preserved item IDs.
    • /ld config preserveItemsOnDeath alwaysPreserved items add <id> - Add an item ID to the always preserved list.
    • /ld config preserveItemsOnDeath alwaysPreserved items remove <id> - Remove an item ID from the always preserved list.

$.preserveItemsOnDeath.alwaysPreserved.tags

What item tag IDs should always be preserved, regardless of following settings?

  • Options: A list of item tag IDs.
  • Default: ["lenientdeath:safe"]
  • Commands:
    • /ld config preserveItemsOnDeath alwaysPreserved tags - Check the current always-preserved item tag IDs.
    • /ld config preserveItemsOnDeath alwaysPreserved tags add <id> - Add an item tag ID to the always preserved list.
    • /ld config preserveItemsOnDeath alwaysPreserved tags remove <id> - Remove an item tag ID from the always preserved list.

Trinkets

Version: 1.0.8+

Lenient Death contains some options for specifically handling Trinkets from the Trinkets library.

$.preserveItemsOnDeath.trinkets.overrideDestroyRule

Some Trinkets have a rule to destroy themselves upon death instead of the standard dropping; Lenient Death can override this. Note that this may break some game balance.

  • Options: true, false
  • Default: false
  • Commands:
    • /ld config preserveItemsOnDeath trinkets overrideDestroyRule - Check if trinket destruction is overridden.
    • /ld config preserveItemsOnDeath trinkets overrideDestroyRule <true|false> - Change if trinket destruction is overridden.

By Item Type

If the above options haven't decided on a strategy, then the item's type will be looked at. This mostly uses code-based definitions, meaning it will have better mod compatibility.

$.preserveItemsOnDeath.byItemType.enabled

Whether item types should be looked at for preservation purposes.

  • Options: true, false
  • Default: true
  • Commands:
    • /ld config preserveItemsOnDeath byItemType enabled - Check if item type checking is enabled.
    • /ld config preserveItemsOnDeath byItemType enabled <true|false> - Change if item type checking is enabled.

$.preserveItemsOnDeath.byItemType.<type>

How this given item type should be handled. If an item is part of multiple types, then the first from the following order will be used: drop > preserve > ignore.

The description for each of the following options are:

  • Options:
    • drop - Always drop items of this type.
    • preserve - Always preserve items of this type.
    • ignore - Delegate to further rules.
  • Commands:
    • /ld config preserveItemsOnDeath byItemType <type> - Check the given type's preservation rule.
    • /ld config preserveItemsOnDeath byItemType <type> <drop|preserve|ignore> - Change the given type's preservation rule.
Types
  • helmets
    • Armour that can be worn on a player's head slot
    • Examples: Turtle Helmet, Diamond Helmet
    • Default Rule: preserve
  • chestplates
    • Armour that can be worn on a player's chest slot
    • Examples: Golden Chestplate, Chainmail Chestplate
    • Default Rule: preserve
  • elytras
    • Items that function as an Elytra
    • Examples: Elytra
    • Default Rule: preserve
  • leggings
    • Armour that can be worn on a player's leg slot
    • Examples: Iron Leggings, Leather Tunic
    • Default Rule: preserve
  • boots
    • Armour that can be worn on a player's feet slot
    • Examples: Netherite Boots, Iron Boots
    • Default Rule: preserve
  • shields
    • Items that function as shields
    • Examples: Shield
    • Default Rule: preserve
  • otherEquippables
    • Other items that can be 'equipped', but are not in the above categories
    • Examples: Skull Blocks
    • Default Rule: ignore
  • trinkets
    • Items registered with the Trinkets library. For more options, see $.preserveItemsOnDeath.trinkets above.
    • Version: 1.0.8+
    • Examples: none in Vanilla; Totem of Undying if Charm of Undying is installed
    • Default Rule: preserve
  • swords
    • Sword-type melee weapons
    • Examples: Wooden Sword, Diamond Sword
    • Default Rule: preserve
  • tridents
    • Trident-type melee weapons
    • Examples: Trident
    • Default Rule: preserve
  • bows
    • Bow-type ranged weapons
    • Examples: Bow
    • Default Rule: preserve
  • crossbows
    • Crossbow-type ranged weapons
    • Examples: Crossbow
    • Default Rule: preserve
  • otherProjectileLaunchers
    • Other ranged weapon types
    • Examples: None in vanilla Minecraft
    • Default Rule: preserve
  • pickaxes
    • Pickaxe-type tools
    • Examples: Iron Pickaxe, Netherite Pickaxe
    • Default Rule: preserve
  • shovels
    • Shovel-type tools
    • Examples: Golden Shovel, Wooden Shovel
    • Default Rule: preserve
  • axes
    • Axe-type tools
    • Examples: Diamond Axe, Stone Axe
    • Default Rule: preserve
  • hoes
    • Hoe-type tools
    • Examples: Golden Hoe, Diamond Hoe
    • Default Rule: preserve
  • otherDiggingItems
    • Digging items that don't fall into the above categories
    • Examples: None in vanilla Minecraft
    • Default Rule: preserve
  • otherTools
    • Other tools that have a unique animation but are not in the above categories
    • Examples: Spyglass, Brush, Goat Horn
    • Default Rule: preserve
  • buckets
    • Buckets, empty or containing something
    • Examples: Bucket, Bucket of Water, Axolotl Bucket
    • Default Rule: preserve
  • food
    • Edible Food items
    • Examples: Cooked Steak, Mushroom Stew, Rotten Flesh
    • Default Rule: preserve
  • potion
    • Potion-type items
    • Examples: Water Bottle, Potion of Healing, Splash Potion of Harming
    • Default Rule: preserve
  • shulkerBoxes
    • Shulker Boxes, with or without dyes. Note that items within shulker boxes aren't checked, so this may be used to cheese other settings.
    • Examples: Shulker Box, Red Shulker Box
    • Default Rule: ignore

Randomizer

If no other option has decided to drop or preserve an item, then whether it is preserved can by decided by random chance. Note that the specified chance does not guarantee a set amount of preserved items, only the average percentage. Stacks will be evaluated as a whole, and will not be split.

$.preserveItemsOnDeath.randomizer.enabled

Whether items have a random chance to be preserved, if otherwise undecided for.

  • Options: true, false
  • Default: false
  • Commands:
    • /ld config preserveItemsOnDeath randomizer enabled - Check if random preservation is enabled.
    • /ld config preserveItemsOnDeath randomizer enabled <true|false> - Change if random preservation is enabled.

$.preserveItemsOnDeath.randomizer.preservedPercentage

The percentage chance that a given item will be preserved.

  • Options: [0, 100] as a percentage
  • Default: 25
  • Commands:
    • /ld config preserveItemsOnDeath randomizer preservedPercentage - Check the current preservation chance.
    • /ld config preserveItemsOnDeath randomizer preservedPercentage <newChance> - Change the preservation chance.

$.preserveItemsOnDeath.randomizer.splitStacks

Since: 1.1.1

Whether to treat stacks of items as a single entity, or to roll for each individual item in the stack.

  • Options: true, false
  • Default: true
  • Commands:
    • /ld config preserveItemsOnDeath randomizer splitStacks - Check whether stacks are split during randomization.
    • /ld config preserveItemsOnDeath randomizer splitStacks <true|false> - Change whether stacks are split during randomization.

Randomizer Luck

The randomizer can be affected by a player's luck attribute. The full formula for the preservation chance is as follows:

luck = player.getLuck() # Luck attribute value
chance = preservedPercentage * (1 + (luck * luckMultiplierFactor)) + (luck * luckAdditiveFactor)

To disable luck-based chances, set both factors to 0. It is recommended to only use one factor at a time.

To give yourself some items to test this feature, use the following commands:

/give @s iron_helmet{AttributeModifiers:[{AttributeName:"generic.luck", Name:"generic.luck", Slot: "head", Amount:1.0, Operation:0, UUID:[I; 4000, -3458, 43241, 6246]}]} 1
/give @s iron_chestplate{AttributeModifiers:[{AttributeName:"generic.luck", Name:"generic.luck", Slot: "chest", Amount:2.0, Operation:0, UUID:[I; 4000, -3458, 43241, 541243]}]} 1
/give @s iron_leggings{AttributeModifiers:[{AttributeName:"generic.luck", Name:"generic.luck", Slot: "legs", Amount:0.5, Operation:0, UUID:[I; 4000, -3458, 43241, -3245]}]} 1
/give @s iron_boots{AttributeModifiers:[{AttributeName:"generic.luck", Name:"generic.luck", Slot: "feet", Amount:-1.0, Operation:0, UUID:[I; 4000, -3458, 43241, -543782]}]} 1

$.preserveItemsOnDeath.randomizer.luckAdditiveFactor

How much a player's luck attribute should add to the presevation chance. This is applied after the multiplier factor.

  • Options: [0, 200], treated as a percentage
  • Default: 20
  • Commands:
    • /ld config preserveItemsOnDeath randomizer luckAdditiveFactor - Check the current luck additive factor.
    • /ld config preserveItemsOnDeath randomizer luckAdditiveFactor <newFactor> - Change the luck additive factor.

$.preserveItemsOnDeath.randomizer.luckMultiplierFactor

How much a player's luck attribute should multiply the preservation chance. This is applied beforethe additive factor.

  • Options: [0, 10]
  • Default: 0
  • Commands:
    • /ld config preserveItemsOnDeath randomizer luckMultiplierFactor - Check the current luck multiplier factor.
    • /ld config preserveItemsOnDeath randomizer luckMultiplierFactor <newFactor> - Change the luck multiplier factor.