FabricMC / fabric

Essential hooks for modding with Fabric.
Apache License 2.0
2.34k stars 413 forks source link

Enchantment API #3080

Open Technici4n opened 1 year ago

Technici4n commented 1 year ago

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

maityyy commented 1 year ago

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

maityyy commented 1 year ago

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

Phoupraw commented 2 months ago

Any progress with Intrinsically enchanted items?

Linguardium commented 2 months ago

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

Phoupraw commented 2 months ago

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).