Posted June 1, 20232 yr I have a weapon that extends CrossbowItem. I made its projectiles able to destroy certain blocks, but I wonder if I can make the weapon compatible with the Silk Touch enchantment--so that those destroyed blocks can drop themselves. (Of course I would have to code the logic myself after checking if the weapon has the enchantment.) How do I do this? It seems like Silk Touch is of the "DIGGER" category, and only items extending DiggerItem (aka not my weapon) are naturally compatible with that enchantment. Edited June 1, 20232 yr by LeeCrafts
June 1, 20232 yr 8 hours ago, LeeCrafts said: How do I do this? It seems like Silk Touch is of the "DIGGER" category, and only items extending DiggerItem (aka not my weapon) are naturally compatible with that enchantment. Override `Item#canApplyAtEnchantingTable` on your extended item. I will note that the enchantment has to be on whatever item the projectile hits to apply to the loot table.
June 1, 20232 yr Author Thank you! Here is my overridden method: @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return enchantment == Enchantments.SILK_TOUCH || super.canApplyAtEnchantingTable(stack, enchantment); }
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.