Mod interacts strangely with vanilla clients and non-traditional enchantments
MagicJinn opened this issue · 3 comments
Hello! I'm reporting 2 issues at the same time, because they could be solved by the same fix!
- When combining an item in an anvil on a vanilla client, while this mod is installed on the server, the cost displayed will be incorrect. This even blocks enchantments that the vanilla client assumes to be above 39.
- When applying a non-traditional enchantment to an item (Fire Aspect on a mace, enabled by a mod) the original cost is used, not the mods cost, while still applying the cost reduction calculation. Let me elaborate: Adding Fire Aspect 2 to a fully enchanted mace displays 60+ levels, but combining it, it removed 30 levels from my player (120 > 90). It seems it's taking the 60 levels, but in XP's worth, not levels worth, meaning it's cheaper but still too expensive. This happens even when the mod is installed on both client and server.
Solution: Removing or resetting Prior Use Penalty (repair_cost).
I am unsure how the mod currently works, but it is already possible to reset Prior Use Penalty in vanilla minecraft (for items in containers or dropped on the ground). Doing this for this mod would remove the weird discrepancies that exist in problem 2, and completely fix problem 1, making the mod completely serverside with no clientside mod requirement, correctly displaying level costs for everyone.
When combining an item in an anvil on a vanilla client, while this mod is installed on the server, the cost displayed will be incorrect.
Depends on what you consider "the cost".
The cost it shows is the amount of levels the server requires you to have, aka the level requirement.
The cost you pay in the end is the level requirement converted into an XP cost, meaning you actually pay less than the shown amount of levels.
There was talks about showing the actual level cost, maybe even the XP cost, but that requires changing or potentially even removing the level requirement and/or more client-side modifications to show both, neither of which I'm fond of.
Note that the shown cost does not change whether you install the mod client-side or not, only the "Too Expensive" message does.
This even blocks enchantments that the vanilla client assumes to be above 39.
It does not.
As long as you have the required amound of levels - which you can't see when it says "Too Expensive", but is still a finite number - you can apply the enchantment, aka the enchanted item will be in the output slot for you to take.
The "Too Expensive" message is a purely visual client-side phenomenon that can only be removed by installing the mod client-side. (As said in the mod description)
When applying a non-traditional enchantment to an item (Fire Aspect on a mace, enabled by a mod) the original cost is used, not the mods cost, while still applying the cost reduction calculation. Let me elaborate: Adding Fire Aspect 2 to a fully enchanted mace displays 60+ levels, but combining it, it removed 30 levels from my player (120 > 90). It seems it's taking the 60 levels, but in XP's worth, not levels worth, meaning it's cheaper but still too expensive.
I'm already confused. Fire Aspect is a vanilla enchantment for the mace, what mod are you using here?
I tried reproducing your issue but everything is working as expected:
I made a mace with all enchantments expect Fire Aspect and repaired it a few times so the repair cost went up (to 63, 255 being the maximum reached after 2 more repairs) and set my level to 120 afterwards:

/data get entity @s SelectedItem:

The level cost seems to match your described cost:

After applying the enchantment, I'm left with 107 levels:

Checking the math (using the wiki formulas), this appears to be correct:
You reach player level 120 at 47520 XP. Actually, I had roughly 120.5 levels, which would be ~48000 XP.
The level cost/requirement of 67 is worth 11533 XP.
That leaves 48000 - 11533 = 36467 XP, which brings the level down to 107 and a bit.
Your values don't match the expected ones at all, you shouldn't have been left with only 90 level.
Either you got the numbers wrong or there may be a mod conflict of some sort.
What Minecraft and Tax Free Levels version are you running and what mods do you have installed?
Solution: Removing or resetting Prior Use Penalty (repair_cost).
I am unsure how the mod currently works, but it is already possible to reset Prior Use Penalty in vanilla minecraft (for items in containers or dropped on the ground). Doing this for this mod would remove the weird discrepancies that exist in problem 2, and completely fix problem 1, making the mod completely serverside with no clientside mod requirement, correctly displaying level costs for everyone.
Again, that is not the issue. It's not an issue of client vs server, but level requirement vs actual cost.
The repair cost adds to the level requirement just like all the enchantments and levels thereof do.
The only thing the client does is a simple check: if level cost > 39 show "Too Expensive"
Other than that, the mod is fully server-only, vanilla-client compatible.
I seem to have misunderstood what exactly your mod does, apologies. I mistakenly assumed that the mod removed the Prior Use Penalty because, at first, it appeared to do so (as the reduced cost often matched what it would be without the penalty). Additionally, naming Fire Aspect as an example was a poor choice on my part, as it’s a vanilla enchantment. The mod I was using allows you to add enchantments like Looting, and I incorrectly assumed it also enabled Fire Aspect, which was already available in vanilla.
While using the anvil, I noticed that the cost initially seemed very low but suddenly spiked dramatically. I now realize I must not have been paying close attention. Thanks a lot for the technical explanation!
The reason I suggested resetting repair_cost was because it would in some ways solve the error that shows when trying to combine a "Too Expensive" item on a vanilla client, but I now understand that's not what this mod is for.
The mod I was using allows you to add enchantments like Looting, and I incorrectly assumed it also enabled Fire Aspect, which was already available in vanilla.
That sounds familiar, is that mod called Axes Are Weapons by any chance?
Because that's another mod of mine! 😄
While using the anvil, I noticed that the cost initially seemed very low but suddenly spiked dramatically.
Yeah, that's the inherent issue with prior work / repair_cost, it adds up extremely quickly.
Minecraft's whole enchanting / level system can be considered fundamentally broken because of it (and many, many other reasons).
There's ways to minimize the impact of prior work, which are exponentially better than the naiive way of applying book after book onto the same item.
If you don't know about that, I once wrote a long comment explaining it (see the second half of it), which also includes a link to gnembon video maybe explaining it a bit better.
There's also tons of mods trying to improve the situation, e.g. by removing prior work completely or capping the enchantment cost at 39 and you can absolutely use those mod on top of Tax Free Levels if you so wish.
This mod on the other hand if more of a quality of life mod, basically letting you use your mob farm more efficiently, since no XP goes to waste to Minecraft's bizarre leveling and enchanting system.
