Note: If you just want to know what numbers to plug in where, skip to here.
So, Minecraft strongholds. These are rare underground structures that contain End portals, the only way to access the alien dimension called the End. Here, players like to build high-powered XP farms, one of the quickest ways to accumulate levels for mending gear or enchanting. It’s also the only place to get valuable items like shulkers and elytra. But getting to an End portal can be annoying, especially if, like me, you are an extremely lazy coward. Despite being tricked out in head-to-toe netherite armour with infinite arrows and a top-tier sword, I am absolutely terrified of monsters, and my entire play style is oriented around avoiding combat and danger as much as possible. And screw getting lost—I want to use safe, convenient public transportation networks as much as possible.
So it really grinds my gears when I need to use the End XP farm and find out that the End portal room is in some dark half-excavated cave in the middle of a trackless wilderness not connected to any roads or railways. I’d much rather find another stronghold, preferably one already near a settlement or road, and fix it up the way I like, with a nice safe End portal room, a well-signposted route in the Nether, etc.
There are a few different ways to find strongholds. If you know the Minecraft world’s seed, you can plug it into a tool that will calculate stronghold locations for you. However, public server seeds are generally kept secret to prevent people from doing stuff like that. The in-game method involves throwing Eyes of Ender and following where they float. You can get pretty technical with it.
But what if you don’t have Eyes of Ender? Well, as long as you know the location of one stronghold, you can use math to figure out where other ones are.
The math
Strongholds are generated equally spaced around 1536-block-wide concentric rings certain distances away from spawn (coordinates 0,0). If you draw an imaginary ring around spawn, starting 1280 blocks away and ending 2816 blocks away, there will be three strongholds evenly spaced around the ring, at varying distances but 120° apart. In the next ring, 4352–5888 blocks away, there are six strongholds spaced 60° apart. And so on.^{1}
This means that once you know the location of one stronghold, you can calculate approximately where the others in the ring are. You know roughly how many blocks away they are, and, based on how many others there are, what angle to take.
This is called a polar coordinate system, where a location is specified by its angle and distance away from the origin point.
However, in-game, Minecraft uses a Cartesian coordinate system. Your location is described with 3 numbers: X (east/west), Y (up/down), and Z (north/south), which you can see on the debug screen when you press F3. (In this case, we can ignore the up/down axis.)
Put the two together and you have a right-angled triangle! The right-angle sides are your Cartesian coordinates, with the polar path as the hypotenuse. That’s right, all it takes to convert one kind of coordinates to the other is freaking SOH CAH TOA. (Which is currently part of grade 10 math here in Ontario.)
To convert Cartesian to polar coordinates, you use the opposite and adjacent sides of the triangle to calculate the hypotenuse and angle, using the inverse tangent function (a.k.a. tan^{-1} or arctan).^{2} And to convert polar to Cartesian coordinates, you use the hypotenuse and angle to calculate the opposite and adjacent sides using the sine and cosine functions.
How to do it
You can do each calculation individually, or plug the numbers in here. (Use your Z-coordinates as y
; and make sure you’re getting the angle in degrees, not radians.)
Cartesian to polar:
r = √(x² + y²)
θ = arctan (y/x)
Polar to Cartesian:
x = r × cos θ
y = r × sin θ
- First, stand somewhere in the stronghold and press F3 to get your coordinates. (You’ll only need X and Z.)
- Convert these to polar coordinates (
r
andθ
).r
is the radius (distance from 0,0), andθ
is the angle. - Look at the spawning location diagram.
r
will tell you what ring you are in and how many strongholds are in the ring. Get the angle intervals by dividing 360 by the number of strongholds. - To get the polar coordinates of the next stronghold, add the angle interval to the value of
θ
. - Convert the polar coordinates to Cartesian coordinates. This will be the stronghold’s approximate location. However, since the value of
r
will vary slightly, you can also use the average distance by adding the minimum and maximum and dividing by 2. Or, to get a wider area, calculate two sets of coordinates using the minimum and maximum radii for that ring; the stronghold will be somewhere between. - Go find your stronghold! If it is an option, you can search the area in advance with Dynmap’s cave view or the like.
- To get the next stronghold location, repeat step 4 with the new polar coordinates.
Example
- There is a stronghold at about 230, 8870.
- The corresponding polar coordinates are r = 8873,
θ
= 88.5°. - This is in the 7424–8960-block ring, which has 10 strongholds. 360 ÷ 10 = 36; the strongholds are 36° apart.
- 88.5 + 36 = 124.5°. The approximate polar coordinates are 8873, 124.5°.
- The corresponding Cartesian coordinates are -5026, 7312. (Or, using the average distance of 8192, -4640, 6751. It will definitely be somewhere between -4205, 6118 and -5075, 7384.)
Checking the dynamic map’s cave view reveals a stronghold at around -4760, 7180!
As you can see, because there is such a wide range of possible values of r
, the end result is not very exact. But it does narrow it down considerably; you know what area to search, and can plan your journey accordingly.
Exercises for the reader
- Calculate the approximate locations of the other strongholds in the ring.
- Find a stronghold in your single-player game or on a server, and calculate the locations of the others.
- There’s an even quicker way with rings with an even number of strongholds. What is it?
- Figure out how to face the right direction using the rotation values on the debug screen.
In conclusion: I literally never thought high school math would come in handy, and yet here we are. If I’d actually paid attention in class instead of writing Star Wars fanfiction, maybe I wouldn’t have had to learn this all over again.
Many thanks to the patient people on Twitter who helped me figure out how to do this in replies to this tweet, particularly @mathematigal!
I did figure out the triangle thing on my own, though.
- The rings’ radii are sort of based on powers of 2, with 768 blocks of “padding” on either side. They are not all exactly powers of 2; I guess the devs adjusted the distances slightly to make them more evenly spaced out. ↩
- When you’re working with a coordinate system where both axes extend into negative values (like the Minecraft map), figuring out which angle to use is a bit tricky, but ignore that for now. ↩