Posted June 26, 20196 yr Hi All, I'm looking for some guidance. I have custom tools that are picking up inappropriate enchantments in a vanilla enchant table (e.g. Sword that gets Feather Falling II) Here is what my sword class looks like: package com.kwpugh.gobber2.items.tools; import java.util.List; import com.kwpugh.gobber2.lists.ItemList; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; public class ItemCustomSword extends SwordItem { public ItemCustomSword(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { if (!worldIn.isRemote) { playerIn.addPotionEffect(new EffectInstance(Effects.STRENGTH, (int) 2400, (int) 2)); } return new ActionResult<ItemStack>(ActionResultType.PASS, playerIn.getHeldItem(handIn)); } @Override public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return true; } @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return true; } @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return repair.getItem() == ItemList.gobber2_ingot; } @Override public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flag) { super.addInformation(stack, world, list, flag); list.add(new StringTextComponent("Right-click for extra strength")); } } I didn't see anything in the vanilla SwordItem class that would control this behavior. Could I get some guidance on how to control this. P.S. My custom armor exhibits the same behavior. Regards.
June 26, 20196 yr 1 hour ago, kwpugh said: @Override public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return true; } @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return true; } Don’t these make it so that any enchantment can always be applied to your sword? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
June 26, 20196 yr Author I misunderstood what that method was doing. Removing that methods fixes the problem. Thank you.
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.