Posted October 5, 20231 yr I'm using Mixins to modify some enchants and where it can be applied to. To do this, I'm changing the canApply field, which works, just not for the enchantment table even tho it says it does. I've also tried modifying canEnchantAtEnchantingTable, but that didn't seem to work (almost exactly the same code as the code beneath) Here is the code: @Mixin(Enchantment.class) public class EnchantmentMixin { @Inject(at = @At("HEAD"), method = "canEnchant", cancellable = true) private void Power(ItemStack itemToEnchant, CallbackInfoReturnable<Boolean> info) { if (itemToEnchant.getItem() instanceof CrossbowItem) { Enchantment e = (Enchantment) ((Object)this); if (e instanceof ArrowDamageEnchantment) { info.setReturnValue(true); } } } Does anyone have a good explanation for this or a way to fix it? Edited October 6, 20231 yr by tobywig
October 5, 20231 yr Override boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) in your item class. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 6, 20231 yr Author I don't think you understand what I'm trying to do here. I would like to make the Power enchantment show up in the enchanting table for the crossbow, but to my disappointment, canEnchant does not affect this, but only the anvil, commands (/enchant) etc. I am not making a new item so I would not be able to override canEnchantAtEnchantingTable. I'm using Mixins to attempt to change this. edit: Fixed it. Due to canEnchantAtEnchantingTable being a method added by forge with no mapping, it needed remap=false. Edited October 6, 20231 yr by tobywig
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.