You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== set_peffect ==
[[../objects/ms.lang.CastException|ms.lang.CastException]]
[[../objects/ms.lang.RangeException|ms.lang.RangeException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Copy Code
The output might be:
Copy Code
The output might be:
Copy Code
The output might be:
Adds one, or modifies an existing, potion effect on a mob. The potionEffect can be SLOWNESS, INVISIBILITY, SLOW_FALLING, BAD_OMEN, WEAKNESS, DOLPHINS_GRACE, INSTANT_DAMAGE, MINING_FATIGUE, TRIAL_OMEN, SPEED, WITHER, LUCK, FIRE_RESISTANCE, WIND_CHARGED, WATER_BREATHING, GLOWING, OOZING, ABSORPTION, HUNGER, BAD_LUCK, HERO_OF_THE_VILLAGE, REGENERATION, INFESTED, WEAVING, STRENGTH, BLINDNESS, LEVITATION, CONDUIT_POWER, RAID_OMEN, JUMP_BOOST, POISON, NAUSEA, RESISTANCE, HEALTH_BOOST, DARKNESS, NIGHT_VISION, INSTANT_HEALTH, HASTE, or SATURATION. It also accepts an integer corresponding to the effect id listed on the Minecraft wiki. Strength is an integer representing the power level of the effect, starting at 0. Seconds defaults to 30.0. To remove an effect, set the seconds to 0. If seconds is greater than 107374182 a RangeException is thrown. Negative seconds makes the effect infinite. (or max in versions prior to 1.19.4) Ambient takes a boolean of whether the particles should be more transparent. Particles takes a boolean of whether the particles should be visible at all. Icon argument takes a boolean of whether the effect icon should be displayed. The function returns whether or not the effect was modified.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| set_peffect
|-
! scope="row" | Returns
| boolean
|-
! scope="row" | Usages
| player, potionEffect, [strength], [seconds], [ambient], [particles], [icon]
|-
! scope="row" | Throws
| [[../objects/com.commandhelper.PlayerOfflineException|com.commandhelper.PlayerOfflineException]][[../objects/ms.lang.CastException|ms.lang.CastException]]
[[../objects/ms.lang.RangeException|ms.lang.RangeException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Yes
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
set_peffect(player, potionEffect, [strength], [seconds], [ambient], [particles], [icon])=== Examples === ====Example 1==== Give player Notch nausea for 30 seconds Given the following code:
set_peffect('Notch', 'NAUSEA')

1 {{function|set_peffect}}('Notch', 'NAUSEA')
The player will experience a wobbly screen.====Example 2==== Make player ArenaPlayer unable to jump for 10 minutes Given the following code:
set_peffect('ArenaPlayer', 'JUMP_BOOST', -16, 600)

1 {{function|set_peffect}}('ArenaPlayer', 'JUMP_BOOST', -16, 600)
From the player's perspective, they will not even leave the ground.====Example 3==== Remove poison from yourself Given the following code:
set_peffect(player(), 'POISON', 1, 0)

1 {{function|set_peffect}}({{function|player}}(), 'POISON', 1, 0)
You are now unpoisoned. Note, it does not matter what you set strength to here.
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)