The Paper implementation of the Minecraft server allows you to configure 2 new settings:
portal-search-radius (128): The maximum range the server will use to look for an existing nether portal. If it can’t find one in that range, it will generate a new one.
portal-create-radius (16): The maximum range the server will try to create a portal around when generating a new portal
I like to lower the search radius a bit, because sometimes it can cause a bit of lag as it has to check
But it also has the downside that player's portals need to be alligned perfectly or else they'll start linking incorrectly.
What isn't clear in this description though is the synnergy between these 2 settings: the
portal-search-radius should be
portal-create-radius, and that's because of the Overworld/Nether coordinate conversion.
I accidentally lowered the
portal-search-radius to 64, but kept the
portal-create-radius at 16. So what happens then?
Well, 1 block in the Nether is 8 blocks in the overworld. Let's say we depart from coordinate 80,80. So when you go from the Overworld to the Nether, it will look in the Nether for a portal 64 blocks around 10,10.
Because there isn't one, it will create it at maximum 26,26 in the Nether.
When you take that portal back to the Overworld, it will look for a portal there around 208,208. But because we've limited the search radius to 64, it won't look for a portal in the Overworld any lower than 144,144.
This is a problem, because the original portal was at 80,80. So now it will actually create a new portal there, and these 3 portals will forever be out-of-sync.
Each time you go from the Overworld to the Nether, you'll go to the correct portal there. But when you come back up, you'll go to this third portal.
In order to prevent this, you just have to make sure the
portal-search-radius is at least 8 times as large as