When creating a custom enchantment, the object for anvil cost accepts a 0.
Unsurprisingly it defaults to a base cost of 1 in-game. However, if the enchantment is trying to be applied at a higher level, the anvil cost multiplies the generated default cost by the enchantment level, instead of defaulting to 1. This results in a level 5 enchantment, with anvil cost 0, actually costing 5 levels on the anvil.
Either the anvil cost object in enchantment jsons need to have a minimum expected value of 1 to better communicate this (and throw an error in the console if not); or more ideally, the anvil should calculate the cost of applying the enchantment, including the multiplying by enchantment level, and only default to 1 if the final calculated value is less than 1 (nicknaming adding 1 level cost regardless of operation should still occur regardless).
Steps to Reproduce:
Generate a world with the datapack included in a comment (contains an enchantment with anvil cost 0, applicable to a stick).
Grab a stick item and an enchanted book with the anvil cost 0 enchantment at level 1, and observe the 1 level cost when placed properly on an anvil.
Now replace the enchanted book with a book with the same enchantment but at a higher level of 2-5, and observe the level cost of it on the anvil.
Expected Results:
The anvil cost would default to 1 for higher enchantment levels (with attempting to add a nickname increasing it to 2).
Observed Results:
The anvil cost increases to higher than 1, scaling with the level of the applying enchantment. So the anvil cost 0 enchantment at level 2 is an anvil cost of 2, level 3 is an anvil cost of 3, and so on.
Attachments
Comments 2
Hi there!
I'm currently reviewing older, unconfirmed reports to help keep the bug tracker up to date. I’ll temporarily resolve this as Awaiting Response for now.
Please let me know if this issue is still happening for you in Minecraft 1.21.6. If you reply, the ticket will automatically reopen and I’ll be happy to take another look.
Forgot to attach the example datapack to the report, but here it is.