
LifeSteal
LifeSteal
A server-side Fabric mod that implements the life-stealing mechanics inspired by popular LifeSteal SMP servers.
Important Update Information for Version 2.0.0
Version 2.0.0 contains numerous changes compared to v1.2.0, resulting in significant modifications to the configuration file (mainly new features were added).
If you want to disable automatic player banning when health reaches zero, please check the punishment
section in the configuration, as this setting has been moved.
Required Dependencies
This mod requires BFAPI (Brad's Fabric API) to function.
Commands
The mod adds a special command for managing and viewing players' lost health. The basic command structure is as follows:
/alias
[get [uuid/name]]/[set [uuid/name] value]
This allows server administrators to adjust player health without needing to restart the server.
Configuration Settings
The configuration file is located at lifesteal.json
in the config directory.
{
"comment-maxHealth": "The maximum total health that can be gained. If the value is less than 0, the limit is ignored",
"maxHealth": -1.0,
"comment-minHealth": "The minimum total health a player can have. When this value is reached, the player cannot be used to gain hearts",
"minHealth": 0.0,
"comment-healthToLooseOnDeath": "The amount of health lost when a player dies",
"healthToLooseOnDeath": 2.0,
"comment-looseHealthOnlyOnPlayerRelatedDeath": "Determines whether a player loses health only from deaths caused by other players. If true, only from players",
"looseHealthOnlyOnPlayerRelatedDeath": false,
"punishment": {
"banWhenHealthReachesZero": true,
"banReason": {
"text": "You have been banned due to reaching zero health level!"
}
},
"comment-notEnoughHeartsMessage": "The message displayed when killing a player who doesn't have enough hearts to steal",
"notEnoughHeartsMessage": {
"text": "The player didn't have any hearts that could be stolen"
},
"command": {
"comment-enableCommands": "Whether commands should be registered",
"enableCommands": true,
"comment-aliases": "The aliases under which the command will be registered",
"aliases": [
"lifesteal",
"ls"
],
"comment-permission": "The permission required to modify a player's health. If you don't have a permission database, the level can be set to the required operator level",
"permission": {
"node": "lifesteal.modify",
"level": "op_3"
},
"comment-successMessage": "The text sent to the player when successfully modifying another player's health",
"successMessage": {
"color": "green",
"text": "Done!"
},
"comment-successMessageFile": "The text sent to the player when setting another player's health while they are offline (data is saved for application upon login)",
"successMessageFile": {
"color": "green",
"text": "Done! (saved to file)"
},
"comment-broadcastToOps": "Whether all operators should be notified when a player's health is modified",
"broadcastToOps": true
},
"recipe": {
"comment-allowCraftingOfHealth": "Whether the default recipe should be registered if a custom recipe is not found under lifesteal:health",
"allowCraftingOfHealth": true,
"comment-registerRequirements": "Do not disable this unless there are conflicting errors. Other mods' recipes may depend on this",
"registerRequirements": true,
"comment-registerResults": "Do not disable this unless there are conflicting errors. Other mods' recipes may depend on this",
"registerResults": true
},
"marks": {
"comment-enableMarks": "Whether marks should be tracked. This is necessary for health items",
"enableMarks": true,
"comment-marks": "The list of marks that will be tracked. When removing/modifying any of them, ensure you update the crafting recipe mark",
"marks": [
"lifesteal",
"health"
],
"comment-limiter": "The maximum number of times a player can consume health before being blocked. If value <1, the limit is ignored",
"limiter": -1,
"output": {
"comment-markOutputSuccess": "Sent to an entity upon successful consumption of a marked item",
"markOutputSuccess": {
"text": "You consumed some health"
},
"comment-markOutputFailed": "Sent to an entity upon failed consumption of a marked item due to exceeding the limit",
"markOutputFailed": {
"color": "red",
"text": "You have already consumed enough health"
},
"comment-broadcastToOpsMarks": "Whether operators should be notified when a player consumes a marked item",
"broadcastToOps": true
}
}
}
API Integration
The mod provides a simple LifeStealable
interface for use as an API.
LifeStealable
allows other mods to get and modify players' lost health, and also implement this functionality for custom entities so they can be used to gain health upon death.
Any LifeStealable
implementation should always call setLostHealth
whenever health changes.
BFAPI Additions
Marks
LifeSteal adds a customizable set of marks (default: lifesteal
and health
) that can be applied to items.
When a marked item is used, the player receives an appropriate message:
If the player has exceeded the health consumption limit, markOutputFailed
is sent; otherwise, markOutputSuccess
is sent.
Recipes
LifeSteal adds several new requirements and results for custom recipes.
Requirements
Three new recipe requirements have been added:
Requirement ID | Description | Expected Type |
---|---|---|
losthealth> | Checks that the crafter has lost at least the specified amount of health | Integer |
losthealth< | Checks that the crafter has lost less than the specified amount of health | Integer |
losthealth= | Checks that the crafter has lost exactly the specified amount of health | Integer |
These requirements can be used to lock recipes at specific health levels. For example, losthealth<
with value -2
will only allow crafting by those who have gained an additional heart.
Results
Three new recipe results have been added:
Result ID | Description | Expected Type |
---|---|---|
gainhealth | Gives the player the specified amount of health | Integer |
loosehealth | Takes the specified amount of health from the player | Integer |
sethealth | Sets the player's lost health to the specified value | Integer |