Requirements

Requirements

Requirements are a cruical part of defining how and when an ability or item property activates. They allow you to set conditions that must be met for the ability or property to function.

Requirement Contexts

Contexts define the situations in which requirements are evaluated.

Parameters:

Parameter NameDescription
this_entityThe entity in context. For example in post_attack this is the entity that was hit, in piglin_safe this is the piglin
itemsThe list of all items that granted the property. (Mostly unused)
originThe origin in context. For example in hit_block this is the position of the block that was hit, in tick this is the position of the wearer
damage_sourceThe damage source, useful for filtering by damage type.
direct_attacking_entityThe direct entity that caused the damage. For example the arrow shot from a bow.
attacking_entityThe entity that caused the damage. For example the player that shot the arrow.
toolThe tool in context. For example in hit_block this is the item used to hit the block, in item_damage its the item that is about to lose durability
block_stateThe state of the block that was hit.

For Abilities

Context NameApplicable ToProvides Parameters
trim_entitytick, second, projectile_tick, piglin_safethis_entity, items, origin
trim_damageincoming_damage, damage_immunity, damage, armour_effectiveness, post_attackthis_entity, items, origin, damage_source, direct_attacking_entity, attacking_entity, tool
trim_equipmentitem_damage, equipped, experience_gained, trade_costthis_entity, items, origin, tool
hit_block_with_held_itemhit_blockthis_entity, items, origin, block_state, tool

For Item Properties

Context NameApplicable ToProvides Parameters
trim_item_damagedamage_immunitythis_entity, origin, damage_source, direct_attacking_entity, attacking_entity, tool

Structure

{
"<ability_component>": [
{
"ability": {...},
"requirements": {
"type": "<requirement_type>",
// Requirement specific fields here
}
}
],
}

Examples:

Example 1: Damage Immunity to Lightning Damage

{
"bettertrims:damage_immunity": [
{
"ability": {},
"requirements": {
"condition": "minecraft:damage_source_properties",
"predicate": {
"tags": [
{
"expected": true,
"id": "minecraft:is_lightning"
},
{
"expected": false,
"id": "minecraft:bypasses_invulnerability"
}
]
}
}
}
]
}

Example 2: Invisible When Still

{
"bettertrims:equipped": [
{
"ability": {
"type": "bettertrims:toggle_mob_effect",
"effect": "minecraft:invisibility",
"amplifier": 0,
"visible": false
},
"requirements": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"movement": {
"speed": {
"max": 0.1
}
}
}
}
}
]
}

Example 3: Extra Damage During Day in Sunlit Dimensions

{
"bettertrims:damage": [
{
"ability": {
"type": "bettertrims:add",
"value": {
"type": "bettertrims:liner",
"base": 2.0,
"per_count_above_first": 1.0
}
},
"requirements": {
"condition": "minecraft:all_of",
"terms": [
{
"condition": "minecraft:time_check",
"period": 24000,
"value": {
"max": 13000.0
}
},
{
"condition": "bettertrims:dimension_check",
"dimensions": "#bettertrims:has_sun"
}
]
}
}
]
}