Jump to content

AxeItem enchantments won't modify even though swordItem does (TieredItem)


Recommended Posts

Posted

I'm using mixins to modify enchantments. In this case, its the sharpness enchantment.

I would like sharpness to not be applicable to the sword and axe by injecting canEnchant

here is my code:

    @Inject(at = @At("HEAD"), method = "canEnchant", cancellable = true)
    private void Sharpness(ItemStack itemToEnchant, CallbackInfoReturnable<Boolean> info) {
        if (itemToEnchant.getItem() instanceof TieredItem) {
            Enchantment e = (Enchantment) ((Object)this);
            if (e instanceof DamageEnchantment) {
                info.setReturnValue(false);
            }
        }
    }

This code works flawlessly for any type of sword, but axes refuse to get changed, even when changing TieredItem to AxeItem.

I would love to know a fix to this.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.