# What math function represents Minecraft bow angle/height?

I am working on a mod in Minecraft Forge/MCP using Java.

Aiming a bow is controlled by your head pitch and yaw rotation. Right now I have a math function that automatically looks at the target. But I simply cannot figure out how to increase the pitch (up-down rotation of your head) to look higher based on how far the target is away. This is necessary because arrows naturally fall downwards, so you have to aim higher, to account for your arrow falling over down over time. How high you aim is based on how far your target is. If you aim to high, the arrow will fly over their head, whereas if you aim to low, the arrow will hit the ground before reaching the target.

I tried the basic stuff like the following:

pitch += distanceToTarget / 4 // Distance is measured in blocks

What I am looking for is a method, that when called, will return the amount I have to add to the pitch to account for the arrow falling down. As mentioned previously, it has to be very precise or the arrow likely won't hit the target.

I don't need exact Java code for this; while that would be preferred, I only need to know the logic, which doesn't necessarily have to be in Java.

Thank you very much for the help!

P.S.: This is only for educational purposes, I'm not trying to use this to hack any servers (so please no hate, thanks! :D).

EDIT: According to this question, the Minecraft arrow travels at

About 60.5 to 60.8 blocks per second.

EDIT 2: I looked at this question shown to me by DMGregory and I looked at this Minecraft fandom page. I learned the following peice of infomation:

When fired, arrows fly in a ballistic trajectory affected by gravity and drag in air, water, and lava. The arrow's velocity is multiplied by 0.99 every tick, and it also experiences 1 m/s2 of gravity.

Arrows travel approximately 3 blocks when fired parallel to a flat plane with no charge, 15 blocks average with medium charge, and 24 blocks average with maximum charge. When fired from a fully charged bow, arrows can travel 120 blocks if fired from an optimal angle. The maximum height an arrow fired by a bow can reach is around 66 blocks.

Thanks for the help, but I still cannot figure out exactly how I can accomplish this task.

• We can find the necessary firing angle if we have both the horizontal and vertical displacements to the target and the launch speed of the arrow. If you have that you should be able to plug in existing answers to solve this. Commented Oct 15, 2021 at 21:11
• both the horizontal and vertical displacements: what do those mean? Commented Oct 15, 2021 at 21:12
• Let's say I want to aim at an apple on a tree. It's 1 m above me (vertical displacement) and 3 m ahead of me (horizontal displacement). We need these numbers separately, rather than just the straight line diagonal distance, because gravity will affect the vertical part of our motion but not the horizontal part. Commented Oct 15, 2021 at 21:15
• Ok, I understand. Let me look at the answer you linked me to Commented Oct 15, 2021 at 21:17
• Oof. Drag makes this a lot harder, unfortunately. You might need to use a piecewise approximation, or simulate the trajectory with your first guess and then refine using binary search depending on whether the simulation overshoots or undershoots. Commented Oct 15, 2021 at 21:49