Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow exact fov values in no-fov #3924

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public abstract class MixinAbstractClientPlayerEntity {
@ModifyReturnValue(method = "getFovMultiplier", at = @At("RETURN"))
private float injectFovMultiplier(float original) {
if (ModuleNoFov.INSTANCE.getEnabled()) {
return ModuleNoFov.INSTANCE.getFov(original);
return ModuleNoFov.INSTANCE.getFovMultiplier(original);
}

return original;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,13 @@ private void hookShowFloatingItem(ItemStack floatingItem, CallbackInfo ci) {
}
}

@ModifyExpressionValue(method = "getFov", at = @At(value = "INVOKE", target = "Ljava/lang/Integer;intValue()I", remap = false))
private int hookGetFov(int original) {
if (ModuleNoFov.INSTANCE.getEnabled()) {
return ModuleNoFov.INSTANCE.getFov(original);
}

return original;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,48 @@ import net.ccbluex.liquidbounce.features.module.Module
*
* Changes FOV value.
*/

object ModuleNoFov : Module("NoFOV", Category.RENDER) {

val mode = choices("Mode", ConstantFov, arrayOf(ConstantFov, Custom))

fun getFov(orig: Float) = (mode.activeChoice as FovMode).getFov(orig)
fun getFovMultiplier(original: Float) = mode.activeChoice.getFovMultiplier(original)

fun getFov(original: Int) = mode.activeChoice.getFov(original)

object ConstantFov : FovMode("Constant") {
private val fov by float("FOV", 1f, 0f..1.5f)
override fun getFov(orig: Float) = fov

private val fov by int("FOV", 90, 1..179)

override fun getFovMultiplier(original: Float) = 1f

override fun getFov(original: Int): Int {
return fov
}

}

object Custom : FovMode("Custom") {

private val baseFov by float("BaseFOV", 1f, 0f..1.5f)
private val limit by floatRange("Limit", 0f..1.5f, 0f..1.5f)
private val multiplier by float("Multiplier", 1f, 0.1f..1.5f)
override fun getFov(orig: Float): Float {
val newFov = (orig - 1) * multiplier + baseFov

override fun getFovMultiplier(original: Float): Float {
val newFov = (original - 1) * multiplier + baseFov
return newFov.coerceIn(limit)
}

}

abstract class FovMode(name: String) : Choice(name) {

override val parent: ChoiceConfigurable<*>
get() = mode
open fun getFov(orig: Float) = orig

abstract fun getFovMultiplier(original: Float): Float

open fun getFov(original: Int) = original

}

}
Loading