Posted May 30, 201510 yr I am trying to make an item that contains tools and copies the texture and attributes of a selected contained tool. Everything works perfectly so far, except when a sword is selected, right clicking doesn't block. Here is the relevant method in my class: @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(!world.isRemote){ if (player.isSneaking()){ if(itemStack.stackTagCompound==null){ this.onCreated(itemStack, world, player); } int active=itemStack.stackTagCompound.getInteger("active"); active=(active+1)%contained.length; itemStack.stackTagCompound.setInteger("active",active); } else { getActiveItem(itemStack).onItemRightClick(getActiveStack(itemStack), world, player); } } return itemStack; } getActiveItem returns the Item of the active contained ItemStack. Using print statements, I have determined that "getActiveItem(itemStack).onItemRightClick(getActiveStack(itemStack), world, player);" is called but the active items onItemRightClick is not. Does anyone know why this is?
May 31, 201510 yr I do know that the blocking animation is determined by Item.getUseAction(), and doesn't have anything to do with Item.onItemRightClick(). Perhaps it has something to do with that? With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver
May 31, 201510 yr Author I think you are right, but I think that onUseItem is called after onItemRightClick is. I used a modified ItemSword class with print statements. Blocking is supposed to call onItemRightClick, onUseItem, and itemMaxUseDuration, but only calls itemMaxUseDuration of the contained Item. Right clicking with a hoe selected tills dirt with the proper animation, but that is because right clicking a block calls onItemUse.
June 1, 201510 yr Author Never mind, found a solution. I moved "getActiveItem(itemStack).onItemRightClick(itemStack, world, player);" outside of "if(!world.isRemote)". I didn't do enough testing to figure out why this works, just that it does.
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.