stackotter / delta-client

An open source Minecraft Java Edition client built for speed.
https://deltaclient.app
GNU General Public License v3.0
322 stars 33 forks source link

Implement FOV effects (e.g. sprinting) #127

Closed stackotter closed 1 year ago

stackotter commented 1 year ago

Fixing this issue will give you a basic understanding of Delta Client's rendering system and entity component system (used for handling entities, physics, etc).

When sprinting, the player's FOV should increase like it would in vanilla. Here's how vanilla calculates the FOV multiplier (but rearranged and pseudocode-ised to stop copyright stuff):

var multiplier = 1

if flying {
   multiplier *= 1.1
}

// baseMovementSpeed is the movement speed without modifiers applied
multiplier *= (movementSpeed / baseMovementSpeed + 1) / 2
if baseMovementSpeed == 0 {
   multiplier = 1
}

// There is also some stuff about what to do when pulling a bow, but
// you can't use a bow in Delta Client yet so I've cut that out

The code that needs modifying is in RenderCoordinator where the fov of the camera is set (permalink to that code in the current latest commit to main)

stackotter commented 1 year ago

I think I've managed to replicate vanilla's interpolation exactly 👌