#ChangeDimensionPacket

1 messages Β· Page 1 of 1 (latest)

spring cloak
#

This is a problem I couldn't solve a few years ago. I tried moving the player dimension with ChangeDimensionPacket to the nether to display a loading screen. Then after a while, I returned it to the Overworld, which caused chunks to not load, input not working, and so on.

spring cloak
#

solve after 3 years

summer dove
spring cloak
#

I need to make sure this works in waterdog first as it involves games packet then make it a public plugin

spring cloak
#
  1. Command execution β€” validates dimension name, parses duration (default
    3s), checks player isn't already in a loading cycle. Gets originalDim = 0
    (overworld) and targetDim = 1 (nether). Rejects if same-dimension.
#
  1. Phase 1 β€” Trigger loading screen β€” calls sendChangeDimension(player, 1)
    which sends ChangeDimensionPacket(DimensionType.NETHER, player.position).
    This is a direct protocol packet β€” the player's server-side level never
    changes. The client sees the nether loading screen (purple/red particle
    animation) and clears all chunks from memory. The client starts requesting
    nether chunks from the server, but the server is still in the overworld and
    doesn't respond with nether chunks β€” the loading screen persists.
#
  1. Wait duration seconds β€” client sits on the nether loading screen, unable
    to finish loading because no nether chunks arrive.
#
  1. Phase 2 β€” Switch back β€” sendChangeDimension(player, 0) sends
    ChangeDimensionPacket(DimensionType.OVERWORLD, player.position). The client
    resets its internal dimension state to overworld and starts requesting
    overworld chunks.
#
  1. Wait 2 ticks (~100ms) β€” gives the client time to process the second
    ChangeDimensionPacket internally.
#
  1. Phase 3 β€” Dismiss + chunk refresh β€” three packets fire in sequence
#

6A. PlayerActionPacket(CHANGE_DIMENSION_ACK) β€” tells the client "your
dimension switch is acknowledged, you can proceed to exit the loading
screen". Since we never called switchLevel() or setDimension() on the
server, PNX doesn't send this automatically β€” we send it manually.

#

6B. PlayStatusPacket(PLAYER_SPAWN) β€” tells the client "the player has
spawned". The loading screen dismisses. The client now shows overworld
terrain... but there's nothing visible yet because all chunks were cleared
in step 2

#

6C. Chunk forcing β€” player.refreshChunkRender() internally sets view
distance to 1 β†’ 32 β†’ original. Each change triggers the client to
re-negotiate its view radius and request chunks. Then
NetworkChunkPublisherUpdatePacket tells the client exactly where its
rendering center is, which directly triggers chunk requests for positions
around the player. The server's PlayerChunkManager responds by sending the
queued chunks, and the overworld terrain renders.