apply Effect
Apply a status effect to a player, players, or entities.
mobs.applyEffect(Effect.Speed, mobs.target(NEAREST_PLAYER), 10, 1)
A status effect is a condition you can give to yourself, other players, or entites. Status effects can either help or harm a player or entity. The effect is applied to the target for some number of seconds.
The amount the effect can be increased by giving an amplifier value to multiply the effect. Amplifier amounts are also thought of as strength levels. An amplifier of 0
is Level I strength, 1
is Level II strength, and so on. An amplifier value is between 0
and 127
.
Parameters
- effect: the effect to apply to the target, such as
Effect.Speed
orEffect.Hunger
. - target: the player, players, or entities to apply the effect to:
NearestPlayer
,LocalPlayer
,RandomPlayer
,AllPlayers
,AllEntities
orMyAgent
. - duration: the number of secconds the effect is applied for.
- amplifier: a number which is the amount to multiply the effect by,
0
-127
.
Example
Give a random player in the game a status effect of Hunger
at Level IV strength.
mobs.applyEffect(Effect.Hunger, mobs.target(RANDOM_PLAYER), 10, 3)