Posted August 30, 201312 yr Hi, I'm trying to add some cool additional functionality to a vanilla enchantment when applied to an item it normally could not be put on. My goal is to allow the user to place Silk Touch on any sword using an enchanted book and an anvil, similar to shears. I then want to modify the loot of any mob killed by a sword with this enchantment. I have poked around a little bit and found the canApply(ItemStack par1ItemStack) function in EnchantmentUntouching. Adding this to the end of the ternary operator allows silk touch to be placed on a diamond sword in addition to a shear. public boolean canApply(ItemStack par1ItemStack) { return par1ItemStack.getItem().itemID == Item.shears.itemID ? true : par1ItemStack.getItem().itemID == Item.swordDiamond.itemID ? true : super.canApply(par1ItemStack); } I have also found getSilkTouchModifier(EntityLiving par0EntityLiving) in EnchantmentHelper that is used to determine whether or not the item in the player's hand has silk touch. I'd rather not modify a base class though. Is there a way to override silk touch to add in some additional functionality? P.S. Is there some way to nicely format code on this forum? I did not see any option to when making this post.
August 30, 201312 yr Huh ? Put a sword in an anvil with a silk touch book. Vanilla works. As for modifying mob loot, use LivingDropsEvent.
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.