Skip to content

canEnchant() ignores exlusive_set #13628

@PetziPotato

Description

@PetziPotato

Expected behavior

The Enchantment method canEnchant() should take into account the enchantment's exclusive_set. For example, calling the method on Blast Protection with a piece of armor that already has Fire Protection should return false.

In this example, the Iron Leggings should only get Fire Protection.

ItemStack armorItem = new ItemStack(Material.IRON_LEGGINGS);
armorItem.addEnchantment(Enchantment.FIRE_PROTECTION, 1);
if (Enchantment.BLAST_PROTECTION.canEnchantItem(armorItem)) {
    armorItem.addEnchantment(Enchantment.BLAST_PROTECTION, 1);
}

Observed/Actual behavior

canEnchant() allows true in the example, which means we get Iron Leggings with both Fire Protection and Blast Protection.

Steps/models to reproduce

Test example provided, run a Paper server with the plugin and the datapack, holding a Dirt block triggers the example code.

TestExclusiveEnchantments.zip

Plugin and Datapack List

See "Steps to reproduce"

Paper version

1.21.11

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions