Why won't my nether portal bring me back where I left?
On our minecraft server, I've built a Nether portal in my basement. Which connected two-way (tested) to a location in the Nether.
This nether portal took me to an area in the nether which was a small cave.
I dug upwards and surfaced close to a Nether Fortress. After clearing the fortress of Blaze spawners, I decided to 'move in'. So I went back to the portal, dismantled it, and reactivated in in a location in the Fortress.
The fortress would be within the same 128m radius I would assume as it's really close to the original place. Literally some steps to the surface, then a ladder up the nearest Nether Fortress bridge support.
Now, taking this portal back to my original doesn't work, I spawn deep underground in an Abandoned Mine Shaft.
I read somewhere that my Nether portal has found a 'better match' and this could be remedied by disabling the 'wrong' portal in the mine shaft.
However, upon multiple attempts, a new nether portal is dynamically created in the same area. See screenie for example. You'll see two 'stacked' portals on the left (from my different attempts at disabling) and then the current active one on the right.
My question is, how can I make sure these portals go to the correct place. Is it a matter of returning the portal to it's original location or am I stuck for returning to the basement?
What happens if you walk through your first overworld portal? Of if you reconstruct it? As far as I know, it should connect to that new portal.
After warping back to my house, I took the first portal, which successfully linked to my now moved nether fortress portal, then this portal goes to the abandoned mineshaft. It's like a three way portal, but none of them return me to the house.
This is how it works:
Every time you enter a portal, the game looks for an exit portal inside +/-128 blocks square (y is irrelevant). If you enter a portal at
x=100, y=60, z=200in the overworld, this corresponds to
x=12, y=60, z=25in the Nether. The game scans a square from
(x=140, z=153), for all y values from 0 to 128. The closest portal in that space is where you appear. If there is no portal in that area, one will be created in a suitable place. Since there is a chance the
x=12, y=60, z=25will be obstructed, the game will search for an open space in that +/-128 blocks square. If such space is found nearby, all will be good, the new portal will lead back to the same one in the overworld.
Note that the game will only scan within the map height. That means that if you place a portal above the nether ceiling, it won't be found, and the game will create a new one for you.
However, sometimes the game will put the Nether portal far from the starting point, if it can't find other suitable place. Let's say it puts the Nether portal at
x=80, y=60, z=110(this is still in the +/-128 bounding box). When you enter that portal the game will search the corresponding space in the overworld: starting from
x=640, z=880, it will search the +/-128 blocks - from
x=768, z=1008. As you may notice, the original overworld portal is well outside this box. So the game will create a new portal in the overworld. This is what is happening in your world.
To fix that, write down the coordinates of the portal in the overworld (use F3 to get them) and divide them by 8. Enter the Nether, go to the calculated coordinates and create a portal from the Nether. You don't have to be exact, as long as you are within 16 blocks from the calculated coordinates (you need to match only x and z, y is irrelevant). Then the game should find the original overworld portal. Or: Move the overworld portal using the above logic.
In described situation, there is no way to make the two portals lead to each other without moving either of them. I'd move the nether portal and if the new position is outside of the fortress, I'd build a short safe walkway to the fortress.
Here is a crude drawing of the process:
Thanks man, I didn't realise that the ratio was 8:1 - I've moved the Nether portal closer to it's original position and now it diverts to the correct place on both journeys!
Really cool explanation. This is jank, though. Would it really be that hard to make a portal "remember" its corresponding portal? Like, that would just take making it a tile entity (which it probably already is, since it teleports the player) and adding one single reference! EDIT: Just to make it clear, I'm 100% cool with the answer. I just complain about Mojang's janky coding, since doing it properly really wouldn't be that much harder.
@EgorHans: I'm not sure why you consider this janky - it's a perfectly reasonable design decision that the computation will be done each time a player uses a portal, rather than a single time with a portal remembering. Binding portals permanently would create user interface pain when dealing with many-to-one portals, or when trying to relocate portals. The current method is 100% deterministic given the current state of the world at any time, which means it's much easier to debug than something whose state is determined by the order of events in the past.