Skip to content

Commit

Permalink
Make loading screen patch skip chunk waiting
Browse files Browse the repository at this point in the history
We do actually need to wait for some other information from the
server before closing the screen.
  • Loading branch information
Spottedleaf committed Jul 30, 2024
1 parent c77e782 commit 63f4fea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
package ca.spottedleaf.moonrise.mixin.loading_screen;

import net.minecraft.client.gui.screens.ReceivingLevelScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.client.multiplayer.LevelLoadStatusManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ReceivingLevelScreen.class)
public abstract class ReceivingLevelScreenMixin extends Screen {
@Mixin(LevelLoadStatusManager.class)
public abstract class LevelLoadStatusManagerMixin {

@Shadow
public abstract void onClose();

protected ReceivingLevelScreenMixin(Component component) {
super(component);
}
private LevelLoadStatusManager.Status status;

/**
* @reason Close the loading screen immediately
* @author Spottedleaf
*/
@Inject(
method = "tick",
method = "loadingPacketsReceived",
cancellable = true,
at = @At(
value = "HEAD"
)
)
private void immediatelyClose(final CallbackInfo ci) {
this.onClose();
ci.cancel();
if (this.status == LevelLoadStatusManager.Status.WAITING_FOR_SERVER) {
this.status = LevelLoadStatusManager.Status.LEVEL_READY;
ci.cancel();
}
}

}
6 changes: 5 additions & 1 deletion src/main/resources/moonrise.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,8 @@ accessible field net/minecraft/server/level/ChunkMap$TrackedEntity serverEntity

# ServerChunkCache$ChunkAndHolder
accessible class net/minecraft/server/level/ServerChunkCache$ChunkAndHolder
accessible method net/minecraft/server/level/ServerChunkCache$ChunkAndHolder <init> (Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ChunkHolder;)V
accessible method net/minecraft/server/level/ServerChunkCache$ChunkAndHolder <init> (Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/server/level/ChunkHolder;)V


# LevelLoadStatusManager$Status
accessible class net/minecraft/client/multiplayer/LevelLoadStatusManager$Status
2 changes: 1 addition & 1 deletion src/main/resources/moonrise.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"chunk_system.OptionsMixin",
"collisions.LiquidBlockRendererMixin",
"collisions.ParticleMixin",
"loading_screen.ReceivingLevelScreenMixin",
"loading_screen.LevelLoadStatusManagerMixin",
"render.SectionRenderDispatcherMixin",
"serverlist.ClientConnectionMixin",
"serverlist.ServerAddressResolverMixin",
Expand Down

0 comments on commit 63f4fea

Please sign in to comment.