Skip to content

API reference Obsidian.API.Loot

EnchantmentDefinition class

The part of a vanilla enchantment definition that decides where it can be applied and at which level, used to enchant generated loot. The vanilla enchantments are in EnchantmentsRegistry.

public sealed class EnchantmentDefinition

In Obsidian.API.

Constructors

public EnchantmentDefinition();

Properties

AnvilCost

public int AnvilCost { get; init; }

The levels an anvil charges for each level of the enchantment it adds (vanilla's anvil_cost).

ExclusiveSet

public ImmutableArray<int> ExclusiveSet { get; init; }

Ids of the enchantments this one can't be combined with.

Id

public required int Id { get; init; }

Index in vanilla's enchantment registry, which is sorted by id. This is the id Enchantment.Id holds.

Identifier

public required string Identifier { get; init; }

Registry id, e.g. minecraft:sharpness.

MaxCost

public required EnchantmentCost MaxCost { get; init; }

The highest enchanting power that gives each level.

public required int MaxLevel { get; init; }

MinCost

public required EnchantmentCost MinCost { get; init; }

The lowest enchanting power that gives each level.

public int MinLevel { get; }

PrimaryItems

public ItemSet PrimaryItems { get; init; }

Items enchanting (tables and loot enchanted with levels) offers the enchantment for; all supported items when null.

SupportedItems

public required ItemSet SupportedItems { get; init; }

Items the enchantment can be applied to.

Weight

public required int Weight { get; init; }

Relative chance of being picked by EnchantmentHelper.SelectEnchantments.

Methods

AreCompatible(EnchantmentDefinition, EnchantmentDefinition)

public static bool AreCompatible(EnchantmentDefinition first, EnchantmentDefinition second);

Whether two different enchantments may be on the same item.

CanEnchant(ItemStack)

public bool CanEnchant(ItemStack stack);

Whether the enchantment can be applied to the stack's item.

public bool IsPrimaryItem(ItemStack stack);

On this page