This is an extremely simple plugin with no commands or permissions that uses bytecode manipulation through ByteBuddy to modify the Minecraft Server source code to unnerf the infinity and mending enchantments!
- Native Minecraft Version:
- Tested Minecraft Versions:
- PseudoResonance (WolfLeader116)
I was developing this for my own server as part of another plugin with more various features, however I thought people may find this useful, so I quickly threw together a standalone plugin only containing this feature.
I have tested this plugin on 1.11 to 1.15, and it has worked on all versions. If something changes in the future, I will update this plugin to support that, however I doubt it will break anytime soon. Enjoy!
IMPORTANT: While the plugin will make an attempt at running on JRE Version 8, it will likely fail. Please use Java 9 and above, or JDK 8 to run this plugin, as bytecode manipulation depends on tools.jar and attach.dll/attach.so which are only present in Java 9 and above, or JDK 8.
NOTE: Because of the nature of this plugin, the server MUST restart in order for it to be removed. Using other plugins like PlugMan to remove this plugin may break things.
The way this plugin works, is it uses reflection to find the NMS class "net.minecraft.server.VERSION.EnchantmentInfiniteArrows", then uses ByteBuddy, an ASM wrapper, to do some bytecode manipulation and replace the method "a" (in 1.14.3) that takes Enchantment as an argument, and it replaces it with a call to the superclass (Enchantment)'s method.
This method is designed as a test for compatibility of two enchantments when Minecraft is determining if an enchantment is valid. For example, when putting an item in an anvil, Minecraft will iterate through the list of enchantments on one item, and check them against the enchantments on the other item by using this method. In most cases, the method simply returns true if the two enchantments are different, and false if they are the same. However, for infinity, it will also return false if the second enchantment is mending, in order to keep the two exclusive.
By removing this unique method and simply calling the superclass, infinity and mending are no longer exclusive and the enchantments can be mixed as if nothing had ever changed!
Infinity and Mending Unnerf Version 1.2.1
A very simple plugin that allows infinity and mending to be together once again!