Fabric API

Fabric API

106M Downloads

Enchantment API

Technici4n opened this issue · 5 comments

commented

We need some features related to enchantments. This issue exists to collect them all in the same place, to ensure a cohesive design. If you have more suggestions please add a comment.

Creating new enchantments

We need control over which items can be enchanted in an anvil (override isAcceptableItem) and in an enchantment table (problematic, involves EnchantmentTarget).

Adding items to existing enchantments

Sometimes the enchantment does not allow an item. The item should be able to override this check.

Intrinsically enchanted items

Some items should behave as if they were enchanted for gameplay reasons, for example an electric tool with a mode to enable silk touch. Using the vanilla enchantment system is problematic as it can cause xp dupe glitched with the grindstone, among other things.

Misc hooks

  • Only damageable items can be enchanted using books in an anvil. This is a problem for some mods that want some non-damageable items to be enchantable (e.g. AE2 annihilation planes).
commented

EnchantmentTarget is а really big pain. Maybe replace it with tags?

commented

#1102 was actually not bad. I like the idea of using events because they allow you to edit the list of items for an existing enchantment

commented

Any progress with Intrinsically enchanted items?

commented

this api is mostly OBE. in 1.21+ you can supply a prefilled DataComponentTypes.ENCHANTMENT component in the item settings

commented

this api is mostly OBE. in 1.21+ you can supply a prefilled DataComponentTypes.ENCHANTMENT component in the item settings

You mean stack.getDefaultComponents().get(DataComponentTypes.ENCHANTMENTS)? That is enough for many cases, but it would be better if there is an API to allow ComponentChanges to modify intrinsic enchantments (stack-aware).