Script API - v26.70.26
    Preparing search index...

    Class EffectTypes

    Represents a type of effect - like poison - that can be applied to an entity.

    export class EffectTypes {
    private constructor();
    static get(identifier: string): EffectType | undefined;
    static getAll(): EffectType[];
    }
    Index
    • Parameters

      • identifier: string

        The identifier for the effect.

      Returns EffectType | undefined

      Effect type for the given identifier or undefined if the effect does not exist.

      Effect type for the given identifier.

      This function can't be called in early-execution mode.

      import { EffectTypes, Player, system } from "@minecraft/server";

      // Run `/scriptevent example:getabsorptioneffect` in chat to inspect the absorption effect type.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:getabsorptioneffect" || !(sourceEntity instanceof Player)) return;

      const effectType = EffectTypes.get("minecraft:absorption");
      if (!effectType) return;

      sourceEntity.sendMessage(`Found effect type: ${effectType.getName()}`);
      });
    • Returns EffectType[]

      A list of all effects.

      Gets all effects.

      This function can't be called in early-execution mode.

      import { EffectTypes, Player, system } from "@minecraft/server";

      // Run `/scriptevent example:listeffects` in chat to list registered effect IDs.
      system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
      if (id !== "example:listeffects" || !(sourceEntity instanceof Player)) return;

      const effectNames = EffectTypes.getAll().map((effectType) => effectType.getName());
      sourceEntity.sendMessage(`Effects (${effectNames.length}): ${effectNames.slice(0, 10).join(", ")}`);
      });