mojira.dev
MC-3

Player facing changes when passing through nether portals in certain cases

When passing through a nether portal either to or from the nether, the player's facing direction is not preserved. It always turns the player 180°.

This is important to those of us who have very carefully oriented our portals for fast travel.

Linked issues

Attachments

Comments 92

I think that would be bad because, the way it is now, if you place your portal against your wall, you don't have to turn around when you're coming out. I think this is better then if the rotation is the same.

Steve Blanding

I'm not sure from his comment if Joshua understood what the bug is or not so just to be absolutely sure that I'm being clear: If you enter a nether portal facing WEST, you should come out the other end facing WEST; if you enter facing EAST, you should come out facing EAST; and so on. That is the way it behaved in the past. In 1.4.1 pre, if I enter a portal facing WEST, I may come out facing NORTH. I haven't worked out all the contributing factors but it seems to behave differently in different circumstances.

Mojang has stated that they changed it to work like portals in the Portal game. So your relative rotation and not the absolute rotation is preserved. For example if your overworld portal is facing north and your nether portal is facing east, going in the overworld portal facing north should probably change your rotation to east.

Steve Blanding

Well if that was their intention then it's still a bug because it doesn't work that way either.

The fact is, this used to work properly, there was no good reason to change it, and now it's broken.

It seems to be inconsistent dependent on whether you are headed to the Nether, or to the Overworld.

I have a portal in Overworld which I head South into. When arriving in the Nether I am still heading South.
When in the Nether, I head North into the same portal, I'm now facing South when trying to exit the portal in the Overworld.

I'll summarise this with (❌ indicates error):
Overworld South -> Nether South
Nether North -> Overworld South ❌

Testing the same portal but facing different orientations gives me:
Overworld North -> Nether North
Nether South -> Overworld North ❌

Overworld East -> Nether East
Nether East -> Overworld West ❌

Overworld West -> Nether West
Nether West -> Overworld East ❌

My two portals are up against walls so I can only enter them from one direction. The directions above are the ones I was facing, not the direction I was moving.

Combined with https://mojang.atlassian.net/browse/MC-180 this can get quite confusing especially if the portal animation has completely obscured your view and you're left blindly trying to get out of the portal.

82 more comments
Patrick Rannou

How IMHO it should be fixed:

At moment of teleportation:

  • Memorize player coordinates and full orientation.

  • For BOTH entrance and exit portals:

– Determine portal shape, making a list of all Portal blocks for both portals, aka 'the lists'.

One list for the entrance portal, one list for the destination portal.

– Determine portal's orientation (EW or NS?)

– Determine the portal's "primary direction" as follow:
— Determine what are the portal sides A and B that will be checked:
If orientation is EW: then A is East and B is West; while if orientation is NS = then A is North and B is South.
— For each of the portal's portal blocks in 'the list', check the blocks on side A and on side B, sum up how many are "air" blocks in A_count and B_count.
— Determine which if the portal's sides is the "main" side:
> If A_count > B_count, then main side is side A
> If A_count <= B_count, then main side is side B
(thus, in case of a tie, the south-West rule applies: West wins over East, and South wins over North).

  • From this primary side, you can then determine which half is the "leftward" side and which half is the "rightward" side.

  • We now know what are the "primary" sides for both the entrance and the destination portals:
    DELTAANGLE = entrance portal's main side's angle + 180 degrees + destination portal's main side's angle

  • On teleportation, Player's XZ body orientation, horizontal viewing angle, and horizontal movement direction, are all be adjusted by DELTAANGLE,
    then modulo 360 degrees on each of the 3 values.

IN OTHER WORDS:

If player enter some portal by the side with the least obstacles (no matter portal shape and size), he will also exit by the destination portal's by the side that also has the least obstacles. If player enters portal by side with more obstacles, then same thing he exits on side with more obstacles.

Also, if you enter by strafing or walking backwards, then you also exit by strafing or walking backwards. Relative angle is preserved.

THEN:

  • Now, while we parsed 'the lists', we also took note of which coordinates indicate the topmost, bottommost, leftwardmost and rightwardmost blocks.
    Basically, getting the "width" and height" of both portals and they start/stop coordinates along width and height.

  • We reduce width and height values by player model's width and height (respectively).

  • Using start/stop coordinates we find the "center" of entrance and destination portals.

  • With the above data, we can now determine, in terms of percentage, where the player was (right before teleportation) relative to entrance portal.

  • We can then compute where he should reappear in the destination portal, using start/stop, percentage, and center and width (adjusted for player model size).

For example, if you enter a 2 high by 10 wide portal while floating with your head and left side both touching the top left corner of the portal, then you would exit a 10 high by 2 wide destination portal also with your head and body touching to the top left corner. If you enter on the ground with your body at the midpoint between rightmost location and center, you are also exiting at the midpoint between where your body would be at center and rightmost possible positions.

  • If the output destination makes player hitbox hit some blocks other than portal blocks, his reappearance location is simply pushed so that he is inside the portal and if that still doesn't work, simply shunted straight to a valid spot (to take into account really weird portal shapes)

IN OTHER WORDS:

Players always exits in a location that makes the most sense as if the portal was really like some kind of doorway.

That algorithm should cover all situational cases pretty neatly and would be very intuitive to use too.

This issue came back. It seems to always turn you 180° now.

This isn't fixed, as Fabian said the portals now turn you 180° (enter portal facing east, and you'll come out the other side facing west)

Consider reopening - 1.14 seems to have regressed. Portals in my world which worked "correctly" in 1.13.2 and prior now exhibit different player facing behavior.

@unknown, please see MC-105207.

Steve Blanding

Nathan Adams

Confirmed

Minecraft 1.4.1, Minecraft 1.4.4, Minecraft 1.4.7, Snapshot 13w01b, Snapshot 13w04a, ..., Minecraft 14w30c, Minecraft 14w32a, Minecraft 14w32b, Minecraft 1.8-pre3, Minecraft 1.8

Minecraft 1.8.1-pre1

Retrieved