I know, but it spawns the lightning on top of the player... What I'm trying to do is get it to spawn in front of the player, no matter where they are looking.
Here you go. This should do what you want. Just change the 'lightningDistance' double variable to whatever distance you want the lightning bolt to be from the player.
Minecraft has a handy little class called Vec3D which calculates the distance or location of one point relative to another point. In this case, the player.getLookVec() method returns the point that is 1 meter away from the players face in the direction that the player is looking. It's xCoord, yCoord, and zCoord aren't actually coordinates on the map, they're how far on each axis the new point is from the player's look. So if you multiply them by, let's say, five, you'll get a point that is five blocks away from the player's look in the direction he's looking.
Hope this helps, tell me if you have any problems.
Here you go. This should do what you want. Just change the 'lightningDistance' double variable to whatever distance you want the lightning bolt to be from the player.
Minecraft has a handy little class called Vec3D which calculates the distance or location of one point relative to another point. In this case, the player.getLookVec() method returns the point that is 1 meter away from the players face in the direction that the player is looking. It's xCoord, yCoord, and zCoord aren't actually coordinates on the map, they're how far on each axis the new point is from the player's look. So if you multiply them by, let's say, five, you'll get a point that is five blocks away from the player's look in the direction he's looking.
Hope this helps, tell me if you have any problems.
Thanks in advance for helping.
Art by me: MrPancakeWolfie@DeviantArt
Minecraft has a handy little class called Vec3D which calculates the distance or location of one point relative to another point. In this case, the player.getLookVec() method returns the point that is 1 meter away from the players face in the direction that the player is looking. It's xCoord, yCoord, and zCoord aren't actually coordinates on the map, they're how far on each axis the new point is from the player's look. So if you multiply them by, let's say, five, you'll get a point that is five blocks away from the player's look in the direction he's looking.
Hope this helps, tell me if you have any problems.