Skip to content
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 @@ -3,7 +3,6 @@
import com.lambda.event.EventFlow;
import com.lambda.event.events.WorldEvent;
import com.lambda.module.modules.render.WorldColors;
import com.lambda.util.math.ColorUtils;
import net.minecraft.block.BlockState;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -32,14 +31,20 @@ private void addEntity(Entity entity, CallbackInfo ci) {
@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomClouds()) {
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getCloudColor()));
var color = WorldColors.getCloudColor();

cir.setReturnValue(
new Vec3d(color.getRed(), color.getGreen(), color.getBlue()));
}
}

@Inject(method = "getSkyColor", at = @At("HEAD"), cancellable = true)
private void getSkyColorInject(Vec3d cameraPos, float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomSky()) {
cir.setReturnValue(ColorUtils.getVec3d(WorldColors.getSkyColor()));
var color = WorldColors.getSkyColor();

cir.setReturnValue(
new Vec3d(color.getRed(), color.getGreen(), color.getBlue()));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.lambda.core.registry

import com.lambda.util.Communication.warn
import jdk.internal.org.jline.keymap.KeyMap.key
import net.minecraft.registry.Registry
import net.minecraft.registry.RegistryKey
import net.minecraft.registry.entry.RegistryEntry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.lambda.graphics.animation

import com.lambda.Lambda.mc
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.extension.partialTicks
import kotlin.math.abs
import kotlin.reflect.KProperty
Expand All @@ -11,7 +11,7 @@ class Animation(initialValue: Double, val update: (Double) -> Double) {
private var currValue = initialValue

operator fun getValue(thisRef: Any?, property: KProperty<*>) =
lerp(prevValue, currValue, mc.partialTicks)
lerp(mc.partialTicks, prevValue, currValue)

operator fun setValue(thisRef: Any?, property: KProperty<*>, valueIn: Double) = setValue(valueIn)

Expand All @@ -38,15 +38,14 @@ class Animation(initialValue: Double, val update: (Double) -> Double) {
fun AnimationTicker.exp(target: () -> Double, speed: Double) =
exp(target, target, { speed }, { true })

@Suppress("NAME_SHADOWING")
fun AnimationTicker.exp(min: () -> Double, max: () -> Double, speed: () -> Double, flag: () -> Boolean) =
Animation(min()) {
val min = min()
val max = max()
val target = if (flag()) max else min

if (abs(target - it) < CLAMP * abs(max - min)) target
else lerp(it, target, speed())
else lerp(speed(), it, target)
}.apply(::register)

// Exponent animation never reaches target value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import com.lambda.graphics.renderer.gui.font.glyph.GlyphInfo
import com.lambda.graphics.shader.Shader
import com.lambda.module.modules.client.LambdaMoji
import com.lambda.module.modules.client.RenderSettings
import com.lambda.util.math.ColorUtils.a
import com.lambda.util.math.ColorUtils.setAlpha
import com.lambda.util.math.Vec2d
import com.lambda.util.math.a
import com.lambda.util.math.setAlpha
import java.awt.Color

class FontRenderer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.lambda.graphics.renderer.gui.rect
import com.lambda.graphics.buffer.vao.IRenderContext
import com.lambda.graphics.buffer.vao.vertex.VertexAttrib
import com.lambda.graphics.shader.Shader
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.MathUtils.toInt
import com.lambda.util.math.MathUtils.toRadian
import com.lambda.util.math.Rect
Expand Down Expand Up @@ -53,7 +53,7 @@ class OutlineRectRenderer : AbstractRectRenderer(
val min = angleRange.first.toDouble()
val max = angleRange.last.toDouble()
val p = it.toDouble() / quality
val angle = lerp(min, max, p).toRadian()
val angle = lerp(p, min, max).toRadian()

val pos = base + Vec2d(cos(angle), -sin(angle)) * round
val s = shade.toInt().toDouble()
Expand Down Expand Up @@ -91,4 +91,4 @@ class OutlineRectRenderer : AbstractRectRenderer(
companion object {
private val shader = Shader("renderer/rect_outline")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import com.lambda.module.modules.client.ClickGui
import com.lambda.module.modules.client.GuiSettings
import com.lambda.module.modules.client.GuiSettings.primaryColor
import com.lambda.util.Mouse
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.ColorUtils.setAlpha
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.MathUtils.toInt
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
import com.lambda.util.math.multAlpha
import com.lambda.util.math.setAlpha
import java.awt.Color
import kotlin.math.abs

Expand Down Expand Up @@ -64,7 +64,7 @@ abstract class WindowComponent<T : ChildComponent>(
private val animation = gui.animation

private val showAnimation by animation.exp(0.0, 1.0, 0.6, ::isOpen)
override val childShowAnimation get() = lerp(0.0, showAnimation, gui.childShowAnimation)
override val childShowAnimation get() = lerp(gui.childShowAnimation, 0.0, showAnimation)

private val actualHeight get() = height + padding * 2 * isOpen.toInt()
private var renderHeightAnimation by animation.exp({ 0.0 }, ::actualHeight, 0.6, ::isOpen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import com.lambda.module.modules.client.GuiSettings
import com.lambda.sound.LambdaSound
import com.lambda.sound.SoundManager.playSoundRandomly
import com.lambda.util.Mouse
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
import com.lambda.util.math.multAlpha
import java.awt.Color

abstract class ButtonComponent(
Expand All @@ -22,7 +22,7 @@ abstract class ButtonComponent(
abstract val size: Vec2d

abstract val text: String
protected open val textColor get() = lerp(Color.WHITE, GuiSettings.mainColor, activeAnimation).multAlpha(showAnimation)
protected open val textColor get() = lerp(activeAnimation, Color.WHITE, GuiSettings.mainColor).multAlpha(showAnimation)
protected open val centerText = false

protected abstract var activeAnimation: Double
Expand All @@ -37,15 +37,15 @@ abstract class ButtonComponent(
private var hoverRectAnimation by animation.exp({ 0.0 }, { 1.0 }, { if (renderHovered) 0.6 else 0.07 }, ::renderHovered)
protected var hoverFontAnimation by animation.exp(0.0, 1.0, 0.5, ::renderHovered)
protected var pressAnimation by animation.exp(0.0, 1.0, 0.5) { activeButton != null }
protected val interactAnimation get() = lerp(hoverRectAnimation, 1.5, pressAnimation) * 0.4
protected val interactAnimation get() = lerp(pressAnimation, hoverRectAnimation, 1.5) * 0.4
override val childShowAnimation: Double get() = owner.childShowAnimation
protected open val showAnimation get() = owner.childShowAnimation

private var lastHoveredTime = 0L
private val renderHovered get() = hovered || System.currentTimeMillis() - lastHoveredTime < 110

// Removes button shrinking if there's no space between buttons
protected val shrinkAnimation get() = lerp(0.0, interactAnimation, ClickGui.buttonStep)
protected val shrinkAnimation get() = lerp(ClickGui.buttonStep, 0.0, interactAnimation)

open fun performClickAction(e: GuiEvent.MouseClick) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import com.lambda.gui.api.component.core.list.ChildComponent
import com.lambda.gui.api.component.core.list.ChildLayer
import com.lambda.module.modules.client.ClickGui
import com.lambda.util.KeyCode
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.ColorUtils.setAlpha
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
import com.lambda.util.math.multAlpha
import com.lambda.util.math.setAlpha
import java.awt.Color
import kotlin.math.abs

Expand Down Expand Up @@ -51,19 +51,19 @@ abstract class InputBarOverlay (val renderer: RenderLayer, owner: ChildLayer.Dra
// Value text
renderer.font.apply {
val text = getText()
val scale = lerp(0.5, 1.0, 1.0 - activeAnimation)
val scale = lerp(1.0 - activeAnimation, 0.5, 1.0)
val position = Vec2d(rect.right, rect.center.y) - Vec2d(ClickGui.windowPadding + getWidth(text, scale), 0.0)
val color = Color.WHITE.setAlpha(lerp(0.0, 1.0 - activeAnimation, showAnimation))
val color = Color.WHITE.setAlpha(lerp(showAnimation, 0.0, 1.0 - activeAnimation))

build(text, position, color, scale)
}

val textStartX = rect.left + ClickGui.windowPadding + interactAnimation + hoverFontAnimation
val textColor = Color.WHITE.setAlpha(lerp(0.0, activeAnimation, showAnimation))
val textColor = Color.WHITE.setAlpha(lerp(showAnimation, 0.0, activeAnimation))

// Typing field
renderer.font.apply {
val scale = lerp(0.5, 1.0, activeAnimation) - pressAnimation * 0.08
val scale = lerp(activeAnimation, 0.5, 1.0) - pressAnimation * 0.08
val position = Vec2d(textStartX, rect.center.y)

targetOffset = getWidth(typed, scale)
Expand All @@ -72,12 +72,12 @@ abstract class InputBarOverlay (val renderer: RenderLayer, owner: ChildLayer.Dra

// Separator
renderer.filled.apply {
val shrink = lerp(rect.size.y * 0.5, 2 + abs(typeAnimation), activeAnimation)
val shrink = lerp(activeAnimation, rect.size.y * 0.5, 2 + abs(typeAnimation))

val rect = Rect(
Vec2d(0.0, rect.top + shrink),
Vec2d(1.0, rect.bottom - shrink)
) + Vec2d(lerp(rect.right, textStartX + offset + 2, activeAnimation), 0.0)
) + Vec2d(lerp(activeAnimation, rect.right, textStartX + offset + 2), 0.0)

build(rect, color = textColor.multAlpha(0.8))
}
Expand Down Expand Up @@ -125,4 +125,4 @@ abstract class InputBarOverlay (val renderer: RenderLayer, owner: ChildLayer.Dra
isActive = !isActive
if (isActive) typed = getText().filter { isCharAllowed("", it) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.lambda.graphics.animation.Animation.Companion.exp
import com.lambda.gui.api.GuiEvent
import com.lambda.gui.api.component.core.list.ChildLayer
import com.lambda.module.modules.client.ClickGui
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.Vec2d

abstract class ListButton(owner: ChildLayer.Drawable<*, *>) : ButtonComponent(owner) {
override val position get() = Vec2d(0.0, lerp(0.0, renderHeightOffset, owner.childShowAnimation))
override val position get() = Vec2d(0.0, lerp(owner.childShowAnimation, 0.0, renderHeightOffset))
override val size get() = Vec2d(FILL_PARENT, ClickGui.buttonHeight)

open val listStep get() = ClickGui.buttonStep
Expand All @@ -24,4 +24,4 @@ abstract class ListButton(owner: ChildLayer.Drawable<*, *>) : ButtonComponent(ow
}
super.onEvent(e)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.lambda.gui.api.component.core

import com.lambda.module.modules.client.ClickGui
import com.lambda.util.math.MathUtils.coerceIn
import com.lambda.util.math.coerceIn
import com.lambda.util.math.MathUtils.roundToStep
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
Expand Down Expand Up @@ -80,4 +80,4 @@ abstract class DockingRect {
CENTER(0.5),
BOTTOM(1.0)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.lambda.module.Module
import com.lambda.module.modules.client.ClickGui
import com.lambda.module.modules.client.GuiSettings
import com.lambda.module.modules.client.GuiSettings.primaryColor
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.multAlpha
import com.lambda.util.math.Vec2d
import java.awt.Color

Expand Down Expand Up @@ -75,4 +75,4 @@ object LambdaClickGui : AbstractClickGui("ClickGui", ClickGui) {
}
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import com.lambda.module.modules.client.GuiSettings
import com.lambda.sound.LambdaSound
import com.lambda.sound.SoundManager.playSoundRandomly
import com.lambda.util.Mouse
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.ColorUtils.setAlpha
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.MathUtils.toInt
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
import com.lambda.util.math.multAlpha
import com.lambda.util.math.setAlpha
import com.lambda.util.math.transform
import java.awt.Color
import kotlin.math.abs
Expand All @@ -45,7 +45,7 @@ class ModuleButton(
override val isActive get() = isOpen

private val openAnimation by animation.exp(0.0, 1.0, 0.7, ::isOpen)
override val childShowAnimation get() = lerp(0.0, openAnimation, owner.childShowAnimation)
override val childShowAnimation get() = lerp(owner.childShowAnimation, 0.0, openAnimation)

private var settingsHeight = 0.0
private var renderHeight by animation.exp(::settingsHeight, 0.6)
Expand Down Expand Up @@ -134,7 +134,7 @@ class ModuleButton(
val left = rect - Vec2d(rect.size.x, 0.0)
val right = rect + Vec2d(rect.size.x, 0.0)

val rect = lerp(left, right, activeAnimation)
val rect = lerp(activeAnimation, left, right)
.clamp(rect)
.shrink(shrinkAnimation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.lambda.graphics.animation.Animation.Companion.exp
import com.lambda.gui.api.GuiEvent
import com.lambda.gui.api.component.button.ListButton
import com.lambda.gui.api.component.core.list.ChildLayer
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp

abstract class SettingButton<V : Any, T : AbstractSetting<V>>(
val setting: T,
Expand All @@ -18,8 +18,8 @@ abstract class SettingButton<V : Any, T : AbstractSetting<V>>(
private var prevTickVisible = false

private var visibilityAnimation by animation.exp(0.0, 1.0, 0.6, ::visible)
override val showAnimation get() = lerp(0.0, super.showAnimation, visibilityAnimation)
override val renderHeightOffset get() = renderHeightAnimation + lerp(-size.y, 0.0, visibilityAnimation)
override val showAnimation get() = lerp(visibilityAnimation, 0.0, super.showAnimation)
override val renderHeightOffset get() = renderHeightAnimation + lerp(visibilityAnimation, -size.y, 0.0)
override var activeAnimation = 0.0

override fun onEvent(e: GuiEvent) {
Expand All @@ -34,4 +34,4 @@ abstract class SettingButton<V : Any, T : AbstractSetting<V>>(
}

open fun unfocus() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.lambda.gui.impl.AbstractClickGui
import com.lambda.gui.impl.clickgui.buttons.ModuleButton
import com.lambda.gui.impl.clickgui.buttons.SettingButton
import com.lambda.util.KeyCode
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.multAlpha
import com.lambda.util.extension.displayValue

class BindButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import com.lambda.module.modules.client.GuiSettings
import com.lambda.sound.LambdaSound
import com.lambda.sound.SoundManager.playSoundRandomly
import com.lambda.util.Mouse
import com.lambda.util.math.ColorUtils.multAlpha
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.lerp
import com.lambda.util.math.Rect
import com.lambda.util.math.Rect.Companion.inv
import com.lambda.util.math.Vec2d
import com.lambda.util.math.multAlpha

class BooleanButton(
setting: BooleanSetting,
owner: ChildLayer.Drawable<SettingButton<*, *>, ModuleButton>,
) : SettingButton<Boolean, BooleanSetting>(setting, owner) {
private var active by animation.exp(0.0, 1.0, 0.6, ::value)
private val zoomAnimation get() = lerp(2.0, 0.0, showAnimation)
private val zoomAnimation get() = lerp(showAnimation, 2.0, 0.0)

private val checkboxRect
get() = Rect(rect.rightTop - Vec2d(rect.size.y * 1.65, 0.0), rect.rightBottom)
Expand All @@ -30,7 +30,7 @@ class BooleanButton(

private val knobStart get() = Rect.basedOn(checkboxRect.leftTop, Vec2d.ONE * checkboxRect.size.y)
private val knobEnd get() = Rect.basedOn(checkboxRect.rightBottom, Vec2d.ONE * checkboxRect.size.y * -1.0).inv()
private val checkboxKnob get() = lerp(knobStart, knobEnd, active).shrink(1.0 + zoomAnimation + interactAnimation)
private val checkboxKnob get() = lerp(active, knobStart, knobEnd).shrink(1.0 + zoomAnimation + interactAnimation)

override fun onEvent(e: GuiEvent) {
super.onEvent(e)
Expand Down
Loading