Skip to content
This repository was archived by the owner on Aug 9, 2026. It is now read-only.

[feat] Damage items on item preservation - #18

Open
krjan02 wants to merge 3 commits into
JackFred2:1.21.2from
krjan02:1.21.2-itemdamage
Open

[feat] Damage items on item preservation#18
krjan02 wants to merge 3 commits into
JackFred2:1.21.2from
krjan02:1.21.2-itemdamage

Conversation

@krjan02

@krjan02 krjan02 commented Dec 13, 2024

Copy link
Copy Markdown

Summary
These additions allow for more nuanced control over item preservation and damage upon player death, providing configurable options for server administrators. If you need further details or have any questions, feel free to ask!

Key Additions:

Additions in onlyDropIfNotSafe Method:

  • The method is modified to include a configuration check for preserving items on death and applying item damage.
  • Introduced a new check that applies damage to items if the itemdamage configuration is enabled.

Configuration Class:

  • Added a new ItemDamage configuration class with several customizable options for item damage mechanics upon death.

Item Damage Logic:
Introduced a new ItemDamage class that contains the logic for applying damage to items when a player dies. The class ItemDamage implements the logic for applying damage to items upon player death. The logic includes:

  • Checking if the item is damageable.
  • Determining if the item will take damage based on a percentage chance.
  • Applying randomization to the damage percentage if enabled.
  • Calculating the new damage value and ensuring it doesn't exceed specified thresholds.
  • Removing the item from the player's inventory if it is completely destroyed (if minimumItemHealth = 0)

Configurable Options

  1. enabled: Whether item damage on death is enabled.
  2. percentage: The likelihood that an item will take damage upon death.
  3. baseDamagePercentage: The base percentage of damage an item should always receive upon death.
  4. minimumItemHealth: The minimum damage value to be maintained for a player's items upon death.
  5. percentageRandomness: Whether randomness in the damage percentage is enabled.
  6. randomizedPercentageMin: The minimum damage percentage when randomness is enabled.
  7. randomizedPercentageMax: The maximum damage percentage when randomness is enabled.

The Wiki needs to be updated after this pull request.

@krjan02 krjan02 mentioned this pull request Dec 13, 2024
@JackFred2 JackFred2 self-assigned this Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants