-
Bug
-
Resolution: Unresolved
-
None
-
1.21.1, 1.21.2 Pre-Release 3, 1.21.3, 1.21.4
-
None
-
Community Consensus
-
Block states, Player
-
Important
-
Platform
Summary
Portals created in the overworld between -128 to 128 (either X or Z or both) can generate a portal that will fail to link back to itself when returning from the nether, due to the nether side portal being located on coords with opposite sign.
This issue is important because a lot of players build their bases close to spawn and have experienced the issue of going to the nether then returning to an unfamilar location which is very confusing to them. Also most nether portals are close to 0 on X or Z axis due to people building straight ice highways in the nether usually starting from 0,0. The reason this is not a duplicate of MC-149705 which is WAI, is because these portals aren't really more than 128 blocks apart so they should be able to link, but due to math issues with negative numbers, the game thinks they are too far apart (but only in the Nether --> Overworld direction.)
This is because if the overworld portal is for example, on negative coords, the portal can be generated on positive coords in the nether. This new nether portal falls within the 16 block linking radius. But when going from nether to overworld these inverted coords get multiplied by 8 pushing the distance of the original overworld portal beyond 128 blocks and forcing a new portal to spawn.
For example this is what happens in the Repo world.zip I provided:
- You enter a portal at X-84
- The game divides that by 8 which returns -10.5
- The game checks for portals in a 16 block radius
- A valid portal is found/generated at X6
- You enter a portal at X6
- The game multiplies that by 8 which returns 48
- The game checks for portals in a 128 block radius
- The original portal at X-84 is now outside that range and doesn't link
Note: The below examples is only considering 1 axis for simplicity. I'm assuming that to be the X axis. 2 values are given for nether portal position because nether portals must be at least 2 blocks wide.
Examples and trivia:
- The furthest (from 0 in the overworld) portal that works both ways is located at +/- X126,125 with the nether portal located at +/- X1,0. If you enter the portal block at X0 you will be taken back. If you take the other side of the portal (X1) you'll be taken to a new overworld portal. furthest.mp4
- On the other hand the closest (to 0 in the overworld) portal that's affected is at +/- X2, 1 with the nether portal being at +/- X16,15. Then if you take then X15 portal you'll be taken back to the same portal but the X16 portal block will spawn a new portal. closest.mp4
- Overworld portals created at coords +/- X127,128 will always work only one way with a nether portal at +/- X1,0.
- Overworld portals at +/- 129 and beyond aren't affected by this bug because no valid inverted coord exists in the nether.
Note: The nether portal can be generated naturally and still be affected by this bug. But it's random so it's easier to build the portal yourself.
Note: This can happen anywhere along the other axis. You could do the same on for example XZ -84,64000 overworld and XZ 5,8000 nether. You don't need to be at 0 like in the examples above.
Steps to reproduce: (naturally generated bugged portal)
1. Create a world with seed 4389679910601070587
2. Run these commands
- /tp -36 65 -110
- /fill -38 68 -111 -38 64 -108 minecraft:obsidian
- /fill -38 67 -110 -38 65 -109 minecraft:nether_portal[axis=z]
3. Enter the portal (go to the nether)
4. Return to the overworld using the naturally generated return portal
5. A new portal is created (if it isn't make sure you enter the nether side portal at Z 3)
Steps to reproduce 2: (using artificially made Repo world.zip )
1. Go through the overworld portal to the nether
2. Go through the portal block at XZ 5,0
3. You return to the portal you made in the overworld
4. Go back to the nether through the portal
5. Go through the portal block at XZ 6,0
6. A new portal is created
example.mp4
Observed Results
- In step 5 (or 6) a new portal is created, despite the portal being previously linked with another overworld portal
Expected Results
- You would return to the portal you first entered instead of making a new one
Suggested Fix
- If the the nether portal coords fall between X/Z -16 to 16 on some axis, do an extra calculation checking if the portal could link if the + / - sign was reversed on that axis. Remember to only do the inversion on the axis that falls in that range, because if you do both then you could for example have a portal in the nether at coords -100000, 8 link to an overworld portal at 800000, 64 which would be very bad.
- Instead of doing the above, you might be able to do abs() but I don't know how the code that calculates this works and it's possible that doing abs() would only fix it in the case of negative nether cords to positive overworld cords, not for positive nether cords and negative overworld cords.
- Yet another way would be to doube linking radius to 257 in the overworld when the nether coords are between X/Z -16 to 16
- Preventing portals from generating a portal with inverted values wouldn't be ideal, as the issue would still affect handmade portals.