mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Added a hideous bodge in NMS enchantment code
This commit is contained in:
parent
250607ecb2
commit
0047df4eb6
@ -27,6 +27,30 @@ class VanillaEcoEnchantsEnchantment(
|
||||
get() = EcoEnchants[id]
|
||||
|
||||
override fun canEnchant(stack: ItemStack): Boolean {
|
||||
/*
|
||||
|
||||
This is the mother of all jank solutions.
|
||||
|
||||
Because I want the EcoEnchants anvil code to handle all custom enchantment logic,
|
||||
I need to prevent the NMS anvil code from processing the EcoEnchants enchantments.
|
||||
|
||||
However, there's no API method that I can use to do this - **however**,
|
||||
this method is called once in the NMS anvil code, and if it returns false then
|
||||
the anvil will not allow this enchantment to be applied to the item.
|
||||
|
||||
So, I can check if the calling method is the anvil merge method, and if it is,
|
||||
I can return false.
|
||||
|
||||
*/
|
||||
|
||||
val caller = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).callerClass
|
||||
|
||||
if (caller.name == AnvilMenu::class.java.name) {
|
||||
return false
|
||||
}
|
||||
|
||||
// End disgusting bodge
|
||||
|
||||
val item = CraftItemStack.asCraftMirror(stack)
|
||||
return enchant?.canEnchantItem(item) ?: false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user