Posted March 26, 201312 yr In am trying to calculate the difference between the player using an item and the entity the item is used on, however the itemInteractionForEntity method i tried using does not include a variable for EntityPlayer. How can i get a variable for the player that is using the item? Thank you!
March 26, 201312 yr Hey! maybe you can use onItemRightClick(itemStack, world, entityPlayer) instead. And inside the method body, do like this: [spoiler=CODE] float f = 1.0F; double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)f; double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par3EntityPlayer.yOffset; double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)f; MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); if (movingobjectposition == null) { return par1ItemStack; } else if (movingobjectposition.entityHit instanceof EntityLiving) { // DO STUFF HERE, Entity hit } This is using the getMovingObjectPositionFromPlayer() method which all items inherit from the Item class. I got this code by looking at how ItemBucket get's milk from EntityCow upon using the item Hope it helps ^^ If you guys dont get it.. then well ya.. try harder...
March 26, 201312 yr Author Wow! I have been searching around forever trying to find a solution. Thanks alot!
March 26, 201312 yr Sometimes a change inn perspective is all that's needed If you guys dont get it.. then well ya.. try harder...
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.