Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/effect: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
Line 4: Line 4:
* 2 {{only|java|short=1}}
* 2 {{only|java|short=1}}
* 1 {{only|bedrock|short=1}}
* 1 {{only|bedrock|short=1}}
|others=Cheat only{{only|bedrock|short=1}}
|others=[[Minecraft:Cheat]] only{{only|bedrock|short=1}}
}}
}}


Adds or removes the status effects of players and other entities.
Adds or removes the [[Minecraft:status effect]]s of [[Minecraft:players]] and other [[Minecraft:entities]].


== 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.
: {{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.
: {{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.
: {{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.
: {{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>}}
{{argument|targets|entity|player: target|CommandSelector<Actor>}}
: Specifies the target(s). {{MC/In|java}}, if not specified, defaults to the player who executes the command.
: Specifies the target(s). {{IN|java}}, if not specified, defaults to the player who executes the command.
: {{MC/Arg desc|je=entity|amount=multiple|type=entities|be=actor}}
: {{arg desc|je=entity|amount=multiple|type=entities|be=actor}}


{{MC/Argument|effect|resource|effect: Effect|enum}}
{{argument|effect|resource|effect: Effect|enum}}
: Specifies the effect to be added or removed.
: Specifies the [[Minecraft:effect]] to be added or removed.
: {{MC/Arg desc|je=resource|registry=minecraft:mob_effect|be=enum}}
: {{arg desc|je=resource|registry=minecraft:mob_effect|be=enum}}


{{MC/Argument|seconds|integer|seconds: int|int}}
{{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.
: {{arg desc|be=int|je=integer|min=0|max=1000000}} {{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}}
{{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).
: {{arg desc|be=int|je=integer}} And it must be between 0 and 255 (inclusive).


{{MC/Argument|hideParticles|bool|hideParticles: Boolean|enum}}
{{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 [[Minecraft:particle]]s 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}}
: {{arg desc|je=bool|be=bool}}


== Result ==
== Result ==
Line 74: Line 74:


== Output ==
== Output ==
{{MC/Output table}}
{{Output table}}
{{MC/Output table|edition=je|On fail|0|0|0}}
{{Output table|edition=je|On fail|0|0|0}}
{{MC/Output table|On success|1|1|the number of entities that are given or revoked effect(s).}}
{{Output table|On success|1|1|the number of entities that are given or revoked effect(s).}}
{{MC/Output table|edition=be|On fail|0}}
{{Output table|edition=be|On fail|0}}
{{MC/Output table|On success|the number of entities that are given or revoked effect(s).}}
{{Output table|On success|the number of entities that are given or revoked effect(s).}}
{{MC/Output table}}
{{Output table}}


== Examples ==
== Examples ==
Line 87: Line 87:
![[Minecraft:Bedrock Edition]]
![[Minecraft:Bedrock Edition]]
|-
|-
|To grant a Resistance V effect to the current entity for 1 million seconds, hiding particles:
|To grant a [[Minecraft:Resistance]] V effect to the current entity for 1 million seconds, hiding particles:
|<code>effect give @s minecraft:resistance 1000000 4 true</code>
|<code>effect give @s minecraft:resistance 1000000 4 true</code>
|<code>effect @s resistance 1000000 4 true</code>
|<code>effect @s resistance 1000000 4 true</code>
|-
|-
|To grant a Speed II effect to the nearest player for 60 seconds:
|To grant a [[Minecraft:Speed]] II effect to the nearest player for 60 seconds:
|<code>effect give @p minecraft:speed 60 1</code>
|<code>effect give @p minecraft:speed 60 1</code>
|<code>effect @p speed 60 1</code>
|<code>effect @p speed 60 1</code>
Line 99: Line 99:
|<code>effect @p speed 60 2</code>
|<code>effect @p speed 60 2</code>
|-
|-
|To clear any Haste effects from all players:
|To clear any [[Minecraft:Haste]] effects from all players:
|<code>effect clear @a minecraft:haste</code>
|<code>effect clear @a minecraft:haste</code>
|<code>effect @a haste 0</code>
|<code>effect @a haste 0</code>
Line 111: Line 111:
=== ''Java Edition'' ===
=== ''Java Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.5|dev=13w09b|Added {{MC/Cmd|effect|link=none}}.}}
|{{HistoryLine||1.5|dev=13w09b|Added {{cmd|effect|link=none}}.}}
|{{HistoryLine||1.6.1|dev=pre|Added {{MC/Cd|clear}} argument to {{MC/Cmd|effect|link=none}}.}}
|{{HistoryLine||1.6.1|dev=pre|Added {{cd|clear}} argument to {{cmd|effect|link=none}}.}}
|{{HistoryLine||1.8|dev=14w06a|Added {{MC/Cd|hideParticles}} argument to {{MC/Cmd|effect|link=none}}}}
|{{HistoryLine||1.8|dev=14w06a|Added {{cd|hideParticles}} argument to {{cmd|effect|link=none}}}}
|{{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.13|dev=17w45a|Syntax of the /effect command has been split into {{cmd|effect give <entity> <effect>}} and {{cmd|effect clear <entity> <effect>}}.}}
|{{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|dev=19w41a|The {{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|{{MC/Cd|<effect>}} now accepts a [[Minecraft:argument types|<code>resource</code> argument]], instead of <code>mob_effect</code>.}}
|{{HistoryLine||1.19.3|dev=22w42a|{{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 {{MC/Cd|infinite}} mode to give an effect with infinite duration.}}
|{{HistoryLine||1.19.4|dev=23w05a|Added {{cd|infinite}} mode to give an effect with infinite duration.}}
}}
}}


=== ''Bedrock Edition'' ===
=== ''Bedrock Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|Pocket}}
|{{HistoryLine|Pocket}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{MC/Cmd|effect|link=none}}.}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{cmd|effect|link=none}}.}}
|{{HistoryLine|||dev=alpha 1.0.5.3|The <code>amplifier</code> on {{MC/Cmd|effect|link=none}} can no longer have negative values.}}
|{{HistoryLine|||dev=alpha 1.0.5.3|The <code>amplifier</code> on {{cmd|effect|link=none}} can no longer have negative values.}}
|{{MC/HistoryLine|Bedrock}}
|{{HistoryLine|Bedrock}}
|{{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||?|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||1.16.200|dev=beta 1.16.200.52|Duration is now capped at 1,000,000 seconds .}}
|{{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: {{MC/Cmd|effect <player: target> <effect: Effect> infinite [amplifier: int] [hideParticles: Boolean]|link=none}}.
|{{HistoryLine||1.21.40|dev=Preview 1.21.40.20|Added infinite duration option to the command: {{cmd|effect <player: target> <effect: Effect> infinite [amplifier: int] [hideParticles: Boolean]|link=none}}.
|Added specific effect removal option to the command: {{MC/Cmd|effect <player: target> clear [effect: Effect]|link=none}}.}}
|Added specific effect removal option to the command: {{cmd|effect <player: target> clear [effect: Effect]|link=none}}.}}
}}
}}


== References ==
== References ==
{{MC/Reflist}}
{{reflist}}


== External links ==
== External links ==
Line 142: Line 142:


== Navigation ==
== Navigation ==
{{MC/Navbox commands}}
{{Navbox commands}}


de:Befehl/effect
[[Minecraft:de:Befehl/effect]]
es:Comandos/effect
[[Minecraft:es:Comandos/effect]]
ja:コマンド/effect
[[Minecraft:fr:Commandes/effect]]
ko:명령어/effect
[[Minecraft:ja:コマンド/effect]]
pt:Comandos/effect
[[Minecraft:ko:명령어/effect]]
ru:Команды консоли/effect
[[Minecraft:pt:Comandos/effect]]
uk:Команди консолі/effect
[[Minecraft:ru:Команды консоли/effect]]
zh:命令/effect
[[Minecraft:uk:Команди консолі/effect]]
[[Minecraft:zh:命令/effect]]

Latest revision as of 11:04, 8 May 2026

Template:Infobox command

Adds or removes the Minecraft:status effects of Minecraft:players and other Minecraft:entities.

Usage

Template:IN, 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.
Template:IN, 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.
Template:IN, no matter whether the new effect can override the original effect, "hideParticles" value is always applied.
Template:IN, 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.
  • 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.
effect <player: target> clear [effect: Effect]
Removes all effects or an effect.

Arguments

Template:Argument

Specifies the target(s). Template:IN, if not specified, defaults to the player who executes the command.
Template:Arg desc

Template:Argument

Specifies the Minecraft:effect to be added or removed.
Template:Arg desc

Template:Argument

Specifies the effect's duration in seconds (or in gameticks for instant_damage, instant_health, and saturation). If not specified, defaults to 30 seconds (or 1 gameticks for instant_damage, instant_health, and saturation).
Template:Arg desc Template:IN, it must be between 0 and 2147483647 (inclusive), and values higher than 1000000 are treated as 1000000.

Template:Argument

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.
Template:Arg desc And it must be between 0 and 255 (inclusive).

Template:Argument

Specifies whether the Minecraft:particles and the HUD indicatorTemplate:Only of the status effect should be hidden. If not specified, defaults to false.
Template:Arg desc

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

Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table

Examples

Minecraft:Java Edition Minecraft:Bedrock Edition
To grant a Minecraft: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 Minecraft: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 Minecraft: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

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

References

Template:Reflist

External links

Navigation

Template:Navbox commands

Minecraft:de:Befehl/effect Minecraft:es:Comandos/effect Minecraft:fr:Commandes/effect Minecraft:ja:コマンド/effect Minecraft:ko:명령어/effect Minecraft:pt:Comandos/effect Minecraft:ru:Команды консоли/effect Minecraft:uk:Команди консолі/effect Minecraft:zh:命令/effect