Skip to content

Commit

Permalink
Move camera into sneaking pose earlier in <= 1.8
Browse files Browse the repository at this point in the history
Closes #556
  • Loading branch information
FlorianMichael committed Sep 12, 2024
1 parent b32725b commit af870ce
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import net.minecraft.client.render.Camera;
import net.minecraft.entity.Entity;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -38,9 +37,12 @@ public abstract class MixinCamera {
@Shadow
private float lastCameraY;

@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.BEFORE))
private void sneakInstantly(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
if (VisualSettings.global().sneakInstantly.isEnabled()) {
@Shadow private Entity focusedEntity;

@Inject(method = "updateEyeHeight", at = @At(value = "HEAD"), cancellable = true)
private void sneakInstantly(CallbackInfo ci) {
if (this.focusedEntity != null && VisualSettings.global().sneakInstantly.isEnabled()) {
ci.cancel();
cameraY = lastCameraY = focusedEntity.getStandingEyeHeight();
}
}
Expand Down

0 comments on commit af870ce

Please sign in to comment.