PrivateconstructorStaticgetIdentifier of the enchantment. For example, "minecraft:flame".
If available, returns an EnchantmentType object that represents the specified enchantment.
This function can't be called in early-execution mode.
import { EnchantmentTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:getsharpnessenchantment` in chat to inspect the sharpness enchantment.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:getsharpnessenchantment" || !(sourceEntity instanceof Player)) return;
const enchantmentType = EnchantmentTypes.get("minecraft:sharpness");
if (!enchantmentType) return;
sourceEntity.sendMessage(`Found enchantment: ${enchantmentType.id} (max level ${enchantmentType.maxLevel})`);
});
StaticgetThis function can't be called in early-execution mode.
import { EnchantmentTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:listenchantments` in chat to list registered enchantment IDs.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:listenchantments" || !(sourceEntity instanceof Player)) return;
const enchantmentIds = EnchantmentTypes.getAll().map((enchantmentType) => enchantmentType.id);
sourceEntity.sendMessage(`Enchantments (${enchantmentIds.length}): ${enchantmentIds.slice(0, 10).join(", ")}`);
});
Contains a catalog of Minecraft Enchantment Types that are available in this world.
Source