I am making a mod and I've made a staff that teleports you to the block you are looking at when you right click. The teleportation works but it teleports me further than where I aim. Here is my code:
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
int distance = 15;
//moveEntity(x, y, z)
par3EntityPlayer.moveEntity(-distance*Math.sin(Math.toRadians(par3EntityPlayer.rotationYawHead))*Math.cos(Math.toRadians(par3EntityPlayer.rotationPitch)) ,-distance*Math.sin(Math.toRadians(par3EntityPlayer.rotationPitch)) , distance*Math.cos(Math.toRadians(par3EntityPlayer.rotationYawHead))*Math.cos(Math.toRadians(par3EntityPlayer.rotationPitch)));
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
Anyone know a fix? Thanks