Skip to content

Commit

Permalink
Don't reset client pocket state when changing level
Browse files Browse the repository at this point in the history
As part of the multi-loader work, we unified some of our event listening
code (0908acb). This incorrectly caused
client pocket computer state to be reset when the player changes
dimension, rather than when the player (dis)connects.

The server code isn't aware of this behaviour, and so does not resend
pocket computer state when the player moves level. We could change this,
but just fixing when we clear the pocket computer state is a much nicer
fix!

Fixes #2004
  • Loading branch information
SquidDev committed Oct 31, 2024
1 parent 5d47372 commit 064ff31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static void onRenderTick() {
public static void onWorldUnload() {
MonitorRenderState.destroyAll();
SpeakerManager.reset();
}

public static void onDisconnect() {
ClientPocketComputers.reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MinecraftMixin {
@SuppressWarnings("unused")
private void clearLevel(Screen screen, CallbackInfo ci) {
ClientHooks.onWorldUnload();
ClientHooks.onDisconnect();
}

@Inject(method = "setLevel", at = @At("HEAD"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public static void onWorldUnload(LevelEvent.Unload event) {
if (event.getLevel().isClientSide()) ClientHooks.onWorldUnload();
}

@SubscribeEvent
public static void onDisconnect(ClientPlayerNetworkEvent.LoggingOut event) {
ClientHooks.onDisconnect();
}

@SubscribeEvent
public static void drawHighlight(RenderHighlightEvent.Block event) {
Expand Down

0 comments on commit 064ff31

Please sign in to comment.