Skip to content

Commit

Permalink
Use eye coordinates when checking if the camera is within a loaded chunk
Browse files Browse the repository at this point in the history
Fixes #2159
  • Loading branch information
jellysquid3 committed Nov 11, 2023
1 parent b90ca83 commit d9081b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.jellysquid.mods.sodium.mixin.core.gui;

import net.minecraft.client.gui.screen.DownloadingTerrainScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(DownloadingTerrainScreen.class)
public class DownloadingTerrainScreenMixin {
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getBlockPos()Lnet/minecraft/util/math/BlockPos;"))
private BlockPos redirect$getPlayerBlockPosition(ClientPlayerEntity instance) {
// Ensure the "eye" position (which the chunk rendering code is actually concerned about) is used instead of
// the "feet" position. This solves a problem where the loading screen can become stuck waiting for the chunk
// at the player's feet to load, when it is determined to not be visible due to the true location of the
// player's eyes.
return BlockPos.ofFloored(instance.getX(), instance.getEyeY(), instance.getY());
}
}
1 change: 1 addition & 0 deletions src/main/resources/sodium.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"core.checks.VertexBufferMixin",
"core.checks.VertexFormatMixin",
"core.checks.WindowFramebufferMixin",
"core.gui.DownloadingTerrainScreenMixin",
"core.model.colors.BlockColorsMixin",
"core.model.colors.ItemColorsMixin",
"core.model.quad.BakedQuadMixin",
Expand Down

0 comments on commit d9081b4

Please sign in to comment.