Posted March 21, 20169 yr when i see the new feature allowing to hold two items at same i only could drow in the posibilityes like in the old mine and blade mod use two swords to fight, or fight sword and shield, mi mod is like 40% fireguns soo i imagine using dual pistols no matther the kind or even more get the assault rifle in one hand and wields mi drill in the other hand as a bioshock bigDady soo i spend the weaken playing around whith the 1.9 code trying to understand the changes and now how far i can get whith it and set some system outs in a custom item [/code] //############################################################################################3 public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { boolean sePudo = true; System.out.println("\n onItemRightClick(" +itemStackIn.getUnlocalizedName()+ "World="+worldIn.isRemote+ "EntityPlayer="+playerIn.getName()+ "EnumHand="+hand.name()+ ")\n"); playerIn.setActiveHand(hand); //this line is equivalent to playerIn.setItemInUse() //trigger as well onUsingTick() and onPlayerStoppedUsing() return sePudo ? new ActionResult(EnumActionResult.FAIL, itemStackIn) : new ActionResult(EnumActionResult.PASS, itemStackIn); } //############################################################################################3 public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack itemStackIn) { World worldIn = entityLiving.worldObj; if (entityLiving instanceof EntityPlayer) { EntityPlayer playerIn = (EntityPlayer) entityLiving; EnumHand hand = playerIn.getActiveHand(); ItemStack offHand = playerIn.getHeldItem(EnumHand.OFF_HAND); ItemStack mainHand = playerIn.getHeldItem(EnumHand.MAIN_HAND); System.out.println("\n onItemLeftClick(" +itemStackIn.getUnlocalizedName()+ "World="+worldIn.isRemote+ "EntityPlayer="+playerIn.getName()+ //"EnumHand="+hand.name()+ ")\n"); } return false; } if i take two of this same item "materialesSuspensionderedstone" in left and right hand and press the butons Both item respond to onItemRightClick() but only if there is not present of this line playerIn.setActiveHand(hand); in the code if playerIn.setActiveHand(hand); is present in this case like both have coz are the same only respond the rightHand item the leftHand do nothing but if i left only the item in the leftHand and nothing in the other or an item whithout playerIn.setActiveHand(hand); then the leftHand respond onEntitySwing() only works whith the rigthHand the leftHand do nothing even if its the only Item and rigthHand its empty if i wield two vainilla swords only the one in the rightHand works this is congruent whith mi little results onEntitySwing() dont work whith leftHand items and leftHand onItemRightClick() only works if the rigthHand has'not the playerIn.setActiveHand(hand) line or the same is an item that does nothing on right click like a simple stick by the nature of mi mod guns i need to implement a onItemLeftClick() wass hard on the 1.8 and gonna be harder in 1.9, i imaginate it than when you have two item on both hands and press right click it activates the rightHand onItemRightClick(), and if you press leftClick it the activates lefthand onItemRightClick() allowing to do the complex things from both items at same time like shooth two diferent guns at same time or atack whit two mellee weapons at same time or one of the one and other of the other kind #######################################333 the post get to long the question is is posibble to trigger the method onItemRightClick() from your LeftHand Item pressing and holding LeftClick ??
March 21, 20169 yr Author i new feature i found onUpdate() only works for item in the main hand, and the other side looks like you can ask for the active hand in the server side, local side returns null /** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if ( isSelected && !worldIn.isRemote ) { if (entityIn instanceof EntityLivingBase) { EntityLivingBase playerIn = (EntityLivingBase) entityIn; EnumHand ManoActiva = playerIn.getActiveHand(); System.out.println( "ManoActiva="+ManoActiva ); } } }
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.