PrivateconstructorStaticgetThe identifier for the effect.
Effect type for the given identifier or undefined if the effect does not exist.
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()}`);
});
StaticgetA list of 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(", ")}`);
});
Represents a type of effect - like poison - that can be applied to an entity.
Source