Skip to content

Fix projectile aim direction with Freecam - #3

Merged
Plattnericus merged 1 commit into
Ryhox:mainfrom
lyuwenhan:main
Jul 12, 2026
Merged

Plattnericus merged 1 commit into
Ryhox:mainfrom
lyuwenhan:main

Conversation

@lyuwenhan

Copy link
Copy Markdown
Contributor

Summary

Fixes projectile trajectory previews following the detached Freecam camera rotation instead of the real player's stored rotation.

Fixes #2

Cause

Projectile Preview used view-related methods such as:

player.getViewVector(tickDelta)
player.getViewYRot(tickDelta)
player.getViewXRot(tickDelta)

Freecam injects into LocalPlayer#getViewXRot(float) and LocalPlayer#getViewYRot(float) and returns the detached camera rotation while Freecam is active.

As a result, Projectile Preview receives the real player entity, but the view-related methods return the Freecam yaw and pitch.

Changes

  • Added a helper that derives a direction vector from the player's stored getYRot() and getXRot() values.
  • Replaced uses of getViewVector(), getViewYRot(), and getViewXRot() in projectile trajectory calculations.
  • Updated projectile start positions, crosshair aiming, pitch offsets, and trident positioning to use the real player rotation.
  • Kept the active render camera responsible only for rendering offsets.

Testing

Tested with:

  • Minecraft 26.1.2
  • Fabric
  • Projectile Preview 26.1+
  • Freecam 1.4.1-beta.1+mc26.1.2

Verified that rotating or moving the detached Freecam camera no longer changes the predicted trajectory, while normal projectile previews continue to work.

Use player rotation instead of intercepted view rotation

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes projectile trajectory previews so they use the real player’s stored yaw/pitch instead of view-derived rotations that can be overridden by Freecam, ensuring predictions remain accurate while the camera is detached.

Changes:

  • Added a helper to compute a direction vector from Player#getYRot() / Player#getXRot().
  • Replaced uses of getViewVector(), getViewYRot(), and getViewXRot() in trajectory direction/aim calculations with stored-rotation equivalents.
  • Updated start position/offset math (including trident handling and pitch-offset aiming) to align with real player rotation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

double y = -Math.sin(pitchRad);
double z = Math.cos(yawRad) * Math.cos(pitchRad);

return new Vec3(x, y, z);
@Plattnericus
Plattnericus merged commit aa4f031 into Ryhox:main Jul 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Projectile trajectory uses the freecam viewing direction instead of the player's actual throwing direction

3 participants