Topic category: Help with Minecraft modding (Java Edition)
I tried to make a station that would give swords an extra level of sharpness that would cost durability on that item so if you had sharpness 2 you would now have sharpness 3 and for example 100 - 200 less durability it depends on the sword but I have made the procedure and when I finished I couldn't use it because it needed certain dependencies and in my opinion it looked very messy. so I just didn't try because I didn't want to be damned to the bottomless pits of figuring out how to fix it without any knowledge what so ever. Here is a few pictures of the horrid creature...
Photo Link since i cant get the photos to work : https://photos.app.goo.gl/JcBr7qEYp2ns1j8e7\\
Anyone have a better way of doing this? or one that might work? or even how to make this procedure work?
Yes, instead of doing a lot of if checks for level of enchantment you can simply just apply sharpness enchantment with level of protection enchantment + 1
thanks i didn't even think of that
It appears the new problem is it instead of upgrading sharpness 1 to sharpness 2 it just gives it another enchant of sharpness 2 so it has both and then because of that it stops going up in sharpness levels just giving me infinite sharpness 2 enchants all seperate.
Could you send an example of what you're talking about?
Here's what I did:
First, I checked if the item in slot 0 was a sword, and checked if the item in slot 1 was quartz. Then, I checked if the sword had sharpness 4 or lower and had over 50 durability left. If those conditions were met, then I stored the level of sharpness + 1 as a variable. Then, I removed 1 quartz from slot 1 and removed the sharpness from the sword in slot 0. Finally, I enchanted the sword in slot 0 with the sharpness level of the variable, and dealt 50 damage to the sword.
This can probably be adapted to your situation. The main part is storing the sharpness level plus one as a variable, removing the sharpness, and then adding the sharpness enchantment with the sharpness level in the variable.
Procedure: