Skip to content

Commit

Permalink
Added new Custom mode to NoFov (CCBlueX#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ell1ott authored Nov 19, 2023
1 parent 9f1a317 commit 3ac0d40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
@Mixin(AbstractClientPlayerEntity.class)
public abstract class MixinAbstractClientPlayerEntity {

@Inject(method = "getFovMultiplier", cancellable = true, at = @At("HEAD"))
@Inject(method = "getFovMultiplier", cancellable = true, at = @At("RETURN"))
private void injectFovMultiplier(CallbackInfoReturnable<Float> cir) {
if (ModuleNoFov.INSTANCE.getEnabled())
cir.setReturnValue(ModuleNoFov.INSTANCE.getFov());
cir.setReturnValue(ModuleNoFov.INSTANCE.getFov(cir.getReturnValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.render

import net.ccbluex.liquidbounce.config.Choice
import net.ccbluex.liquidbounce.config.ChoiceConfigurable
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module

Expand All @@ -28,5 +30,29 @@ import net.ccbluex.liquidbounce.features.module.Module
*/

object ModuleNoFov : Module("NoFOV", Category.RENDER) {
val fov by float("FOV", 1f, 0f..1.5f)
val mode = choices("Mode", ConstantFov, arrayOf(ConstantFov, Custom))

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


object ConstantFov : FovMode("Constant") {
private val fov by float("FOV", 1f, 0f..1.5f)
override fun getFov(orig: Float) = 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
return newFov.coerceIn(limit)
}
}

abstract class FovMode(name: String) : Choice(name) {
override val parent: ChoiceConfigurable
get() = mode
open fun getFov(orig: Float) = orig
}
}

0 comments on commit 3ac0d40

Please sign in to comment.