Attribute Modifier - Apply (Section) — SkBee

Addon: SkBee · Category: Section · Since: 3.5.9

Syntax

apply [transient] attribute modifier to %itemtypes/livingentities%

Description

Apply an attribute modifier to an item or living entity. See [**McWiki Component**](https://minecraft.wiki/w/Data_component_format#attribute_modifiers) and [**McWiki Modifiers**](https://minecraft.wiki/w/Attribute#Modifiers) for further details.

`transient` = Non-persisent attribute modifier (LivingEntities only, not Items), will not save to the entity's NBT (Requires PaperMC).

**Entries/Sections**: - `attribute` = The attribute this modifier is to act upon. - `slot` = EquipmentSlotGroup the item must be in for the modifier to take effect (optional, default = any). - `id` = The NamespacedKey to identify this modifier. - `amount` = Amount of change from the modifier. - `operation` = The operation to decide how to modify.

Examples

#Apply Attribute Modifiers to Items
set {_i} to a stick
apply attribute modifier to {_i}:
	attribute: scale
	id: "minecraft:my_hand_scale"
	slot: mainhand_slot_group
	amount: 2
	operation: add_number
apply attribute modifier to {_i}:
	attribute: scale
	id: "minecraft:my_hand_scale_off"
	slot: offhand_slot_group
	amount: -0.9
	operation: add_number
give player 1 of {_i}
#Apply Attribute Modifiers to LivingEntities
apply transient attribute modifier to player:
	id: "my_mods:mining"
	attribute: player mining efficiency
	amount: 50
	operation: add_number
apply transient attribute modifier to player:
	id: "my_mods:scale"
	attribute: scale
	amount: -0.5
	operation: add_number

View source