Minecraft:Commands/effect: Difference between revisions
More actions
Remove broken links to missing pages |
Fix template calls: add MC/ prefix |
||
| Line 10: | Line 10: | ||
== Usage == | == Usage == | ||
: {{ | : {{MC/In|java}}, if a target already has a status effect with the same id, a new effect only with a longer duration or a higher amplifier can be added. | ||
:* If the new effect has a higher amplifier and a shorter duration, the original effect is hidden. | :* If the new effect has a higher amplifier and a shorter duration, the original effect is hidden. | ||
:* If the new effect has a lower amplifier and a longer duration, the new effect is hidden. | :* If the new effect has a lower amplifier and a longer duration, the new effect is hidden. | ||
| Line 17: | Line 17: | ||
: Only if the active effect is changed does the command succeed, no matter whether the hidden effects are changed or not. | : Only if the active effect is changed does the command succeed, no matter whether the hidden effects are changed or not. | ||
: {{ | : {{MC/In|bedrock}}, if a target already has the status effect, a new status effect with the same amplifier overrides the old duration if it is longer, but a new status effect with a higher amplifier overrides any previous effect. | ||
: {{ | : {{MC/In|bedrock}}, no matter whether the new effect can override the original effect, "hideParticles" value is always applied. | ||
: {{ | : {{MC/In|bedrock}}, if the player uses an NBT editor to get negative levels of effects, the level of the effect jumps to 255 instead. | ||
== Syntax == | == Syntax == | ||
| Line 39: | Line 39: | ||
== Arguments == | == Arguments == | ||
{{ | {{MC/Argument|targets|entity|player: target|CommandSelector<Actor>}} | ||
: Specifies the target(s). {{ | : Specifies the target(s). {{MC/In|java}}, if not specified, defaults to the player who executes the command. | ||
: {{ | : {{MC/Arg desc|je=entity|amount=multiple|type=entities|be=actor}} | ||
{{ | {{MC/Argument|effect|resource|effect: Effect|enum}} | ||
: Specifies the effect to be added or removed. | : Specifies the effect to be added or removed. | ||
: {{ | : {{MC/Arg desc|je=resource|registry=minecraft:mob_effect|be=enum}} | ||
{{ | {{MC/Argument|seconds|integer|seconds: int|int}} | ||
: Specifies the effect's duration in seconds (or in gameticks for <code>instant_damage</code>, <code>instant_health</code>, and <code>saturation</code>). If not specified, defaults to 30 seconds (or 1 gameticks for <code>instant_damage</code>, <code>instant_health</code>, and <code>saturation</code>). | : Specifies the effect's duration in seconds (or in gameticks for <code>instant_damage</code>, <code>instant_health</code>, and <code>saturation</code>). If not specified, defaults to 30 seconds (or 1 gameticks for <code>instant_damage</code>, <code>instant_health</code>, and <code>saturation</code>). | ||
: {{ | : {{MC/Arg desc|be=int|je=integer|min=0|max=1000000}} {{MC/In|bedrock}}, it must be between 0 and 2147483647 (inclusive), and values higher than 1000000 are treated as 1000000. | ||
{{ | {{MC/Argument|amplifier|integer|amplifier: int|int}} | ||
: Specifies the number of additional levels to add to the effect. If not specified, defaults to 0. Note that the first tier of a status effect (e.g. Regeneration I) is 0, so the second tier, for example Regeneration II, would be specified by an amplifier level of 1. | : Specifies the number of additional levels to add to the effect. If not specified, defaults to 0. Note that the first tier of a status effect (e.g. Regeneration I) is 0, so the second tier, for example Regeneration II, would be specified by an amplifier level of 1. | ||
: {{ | : {{MC/Arg desc|be=int|je=integer}} And it must be between 0 and 255 (inclusive). | ||
{{ | {{MC/Argument|hideParticles|bool|hideParticles: Boolean|enum}} | ||
: Specifies whether the particles and the HUD indicator{{only|java}} of the status effect should be hidden. If not specified, defaults to <code>false</code>. | : Specifies whether the particles and the HUD indicator{{only|java}} of the status effect should be hidden. If not specified, defaults to <code>false</code>. | ||
: {{ | : {{MC/Arg desc|je=bool|be=bool}} | ||
== Result == | == Result == | ||
| Line 74: | Line 74: | ||
== Output == | == Output == | ||
{{Output table}} | {{MC/Output table}} | ||
{{Output table|edition=je|On fail|0|0|0}} | {{MC/Output table|edition=je|On fail|0|0|0}} | ||
{{Output table|On success|1|1|the number of entities that are given or revoked effect(s).}} | {{MC/Output table|On success|1|1|the number of entities that are given or revoked effect(s).}} | ||
{{Output table|edition=be|On fail|0}} | {{MC/Output table|edition=be|On fail|0}} | ||
{{Output table|On success|the number of entities that are given or revoked effect(s).}} | {{MC/Output table|On success|the number of entities that are given or revoked effect(s).}} | ||
{{Output table}} | {{MC/Output table}} | ||
== Examples == | == Examples == | ||
| Line 111: | Line 111: | ||
=== ''Java Edition'' === | === ''Java Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{MC/HistoryLine|java}} | ||
|{{HistoryLine||1.5|dev=13w09b|Added {{ | |{{HistoryLine||1.5|dev=13w09b|Added {{MC/Cmd|effect|link=none}}.}} | ||
|{{HistoryLine||1.6.1|dev=pre|Added {{ | |{{HistoryLine||1.6.1|dev=pre|Added {{MC/Cd|clear}} argument to {{MC/Cmd|effect|link=none}}.}} | ||
|{{HistoryLine||1.8|dev=14w06a|Added {{ | |{{HistoryLine||1.8|dev=14w06a|Added {{MC/Cd|hideParticles}} argument to {{MC/Cmd|effect|link=none}}}} | ||
|{{HistoryLine||1.13|dev=17w45a|Syntax of the /effect command has been split into {{ | |{{HistoryLine||1.13|dev=17w45a|Syntax of the /effect command has been split into {{MC/Cmd|effect give <entity> <effect>}} and {{MC/Cmd|effect clear <entity> <effect>}}.}} | ||
|{{HistoryLine||1.15|dev=19w41a|The {{ | |{{HistoryLine||1.15|dev=19w41a|The {{MC/Cmd|effect clear}} command now defaults to the executor if no target argument is given.}} | ||
|{{HistoryLine||1.15.2|dev=Pre-Release 1|When a stronger effect overwrites a weaker effect, the weaker effect is now hidden.<ref>{{bug|MC-1541||Beacon effect removes potion effect of the same type|Fixed}}</ref>}} | |{{HistoryLine||1.15.2|dev=Pre-Release 1|When a stronger effect overwrites a weaker effect, the weaker effect is now hidden.<ref>{{bug|MC-1541||Beacon effect removes potion effect of the same type|Fixed}}</ref>}} | ||
|{{HistoryLine||1.19.3|dev=22w42a|{{ | |{{HistoryLine||1.19.3|dev=22w42a|{{MC/Cd|<effect>}} now accepts a [[Minecraft:argument types|<code>resource</code> argument]], instead of <code>mob_effect</code>.}} | ||
|{{HistoryLine||1.19.4|dev=23w05a|Added {{ | |{{HistoryLine||1.19.4|dev=23w05a|Added {{MC/Cd|infinite}} mode to give an effect with infinite duration.}} | ||
}} | }} | ||
=== ''Bedrock Edition'' === | === ''Bedrock Edition'' === | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|Pocket}} | |{{MC/HistoryLine|Pocket}} | ||
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{ | |{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{MC/Cmd|effect|link=none}}.}} | ||
|{{HistoryLine|||dev=alpha 1.0.5.3|The <code>amplifier</code> on {{ | |{{HistoryLine|||dev=alpha 1.0.5.3|The <code>amplifier</code> on {{MC/Cmd|effect|link=none}} can no longer have negative values.}} | ||
|{{HistoryLine|Bedrock}} | |{{MC/HistoryLine|Bedrock}} | ||
|{{HistoryLine||?|Max value for <code><seconds></code> argument was changed to 32 bit integer limit, although gives effect only at <code>2040109465</code> or below.}} | |{{MC/HistoryLine||?|Max value for <code><seconds></code> argument was changed to 32 bit integer limit, although gives effect only at <code>2040109465</code> or below.}} | ||
|{{HistoryLine||1.16.200|dev=beta 1.16.200.52|Duration is now capped at 1,000,000 seconds .}} | |{{MC/HistoryLine||1.16.200|dev=beta 1.16.200.52|Duration is now capped at 1,000,000 seconds .}} | ||
|{{HistoryLine||1.21.40|dev=Preview 1.21.40.20|Added infinite duration option to the command: {{ | |{{HistoryLine||1.21.40|dev=Preview 1.21.40.20|Added infinite duration option to the command: {{MC/Cmd|effect <player: target> <effect: Effect> infinite [amplifier: int] [hideParticles: Boolean]|link=none}}. | ||
|Added specific effect removal option to the command: {{ | |Added specific effect removal option to the command: {{MC/Cmd|effect <player: target> clear [effect: Effect]|link=none}}.}} | ||
}} | }} | ||
== References == | == References == | ||
{{ | {{MC/Reflist}} | ||
== External links == | == External links == | ||
| Line 142: | Line 142: | ||
== Navigation == | == Navigation == | ||
{{Navbox commands}} | {{MC/Navbox commands}} | ||
de:Befehl/effect | de:Befehl/effect | ||
Latest revision as of 20:09, 9 April 2026
Adds or removes the status effects of players and other entities.
Usage
- in Template:Editions, if a target already has a status effect with the same id, a new effect only with a longer duration or a higher amplifier can be added.
- If the new effect has a higher amplifier and a shorter duration, the original effect is hidden.
- If the new effect has a lower amplifier and a longer duration, the new effect is hidden.
- If their "hideParticles" values are different, the active effect's value is set to the specified value.
- Otherwise, the original active effect is replaced by the new effect, without changing hidden effects.
- Only if the active effect is changed does the command succeed, no matter whether the hidden effects are changed or not.
- in Template:Editions, if a target already has the status effect, a new status effect with the same amplifier overrides the old duration if it is longer, but a new status effect with a higher amplifier overrides any previous effect.
- in Template:Editions, no matter whether the new effect can override the original effect, "hideParticles" value is always applied.
- in Template:Editions, if the player uses an NBT editor to get negative levels of effects, the level of the effect jumps to 255 instead.
Syntax
- Java Edition
effect clear [<targets>] [<effect>]- Removes all effects or an effect.
effect give <targets> <effect> [<seconds>] [<amplifier>] [<hideParticles>]- Gives an effect.
effect give <targets> <effect> infinite [<amplifier>] [<hideParticles>]- Gives an effect with infinite duration, which displays as
∞in the GUI.
- Gives an effect with infinite duration, which displays as
- Bedrock Edition
effect <player: target> <effect: Effect> [seconds: int] [amplifier: int] [hideParticles: Boolean]- Gives or removes an effect.
effect <player: target> <effect: Effect> infinite [amplifier: int] [hideParticles: Boolean]- Gives an effect with infinite duration, which displays as
∞in the GUI.
- Gives an effect with infinite duration, which displays as
effect <player: target> clear [effect: Effect]- Removes all effects or an effect.
Arguments
Template:El: <targets>: entity
Template:El: player: target: CommandSelector<Actor>
- Specifies the target(s). in Template:Editions, if not specified, defaults to the player who executes the command.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|entity}}{{#vardefine:be-arg|entity}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Template:El: <effect>: resource
Template:El: effect: Effect: enum
- Specifies the effect to be added or removed.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|resource}}{{#vardefine:be-arg|{{#var:je-arg}}}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Template:El: <seconds>: integer
Template:El: seconds: int: int
- Specifies the effect's duration in seconds (or in gameticks for
instant_damage,instant_health, andsaturation). If not specified, defaults to 30 seconds (or 1 gameticks forinstant_damage,instant_health, andsaturation). - {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|integer}}{{#vardefine:be-arg|integer}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}} in Template:Editions, it must be between 0 and 2147483647 (inclusive), and values higher than 1000000 are treated as 1000000.
Template:El: <amplifier>: integer
Template:El: amplifier: int: int
- Specifies the number of additional levels to add to the effect. If not specified, defaults to 0. Note that the first tier of a status effect (e.g. Regeneration I) is 0, so the second tier, for example Regeneration II, would be specified by an amplifier level of 1.
- {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|integer}}{{#vardefine:be-arg|integer}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}} And it must be between 0 and 255 (inclusive).
Template:El: <hideParticles>: bool
Template:El: hideParticles: Boolean: enum
- Specifies whether the particles and the HUD indicatorTemplate:Only of the status effect should be hidden. If not specified, defaults to
false. - {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|bool}}{{#vardefine:be-arg|bool}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|0}}{{#vardefine:output3-{{#var:output-table-lines}}|0}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|je}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On success}}{{#vardefine:output1-{{#var:output-table-lines}}|1}}{{#vardefine:output2-{{#var:output-table-lines}}|1}}{{#vardefine:output3-{{#var:output-table-lines}}|the number of entities that are given or revoked effect(s).}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|Expression error: Unrecognized punctuation character "{".}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|N/A}}{{#vardefine:output3-{{#var:output-table-lines}}|N/A}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|be}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}} {{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On success}}{{#vardefine:output1-{{#var:output-table-lines}}|the number of entities that are given or revoked effect(s).}}{{#vardefine:output2-{{#var:output-table-lines}}|N/A}}{{#vardefine:output3-{{#var:output-table-lines}}|N/A}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|Expression error: Unrecognized punctuation character "{".}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
Examples
| Minecraft:Java Edition | Minecraft:Bedrock Edition | |
|---|---|---|
| To grant a Resistance V effect to the current entity for 1 million seconds, hiding particles: | effect give @s minecraft:resistance 1000000 4 true
|
effect @s resistance 1000000 4 true
|
| To grant a Speed II effect to the nearest player for 60 seconds: | effect give @p minecraft:speed 60 1
|
effect @p speed 60 1
|
| To grant a Speed III effect to the nearest player for 60 seconds: | effect give @p minecraft:speed 60 2
|
effect @p speed 60 2
|
| To clear any Haste effects from all players: | effect clear @a minecraft:haste
|
effect @a haste 0
|
| To clear all effects from all Minecraft:zombies: | effect clear @e[type=zombie]
|
effect @e[type=zombie] clear
|
History
Java Edition
Bedrock Edition
References
<references group="">
</references>
External links
de:Befehl/effect es:Comandos/effect ja:コマンド/effect ko:명령어/effect pt:Comandos/effect ru:Команды консоли/effect uk:Команди консолі/effect zh:命令/effect