Skip to content

Commit

Permalink
chore(legacy): Replaced "on/off" rotation modes with a boolean "Rotat…
Browse files Browse the repository at this point in the history
…ions" option (just like before). (CCBlueX#4253)
  • Loading branch information
mems01 authored Oct 26, 2024
1 parent 07f739e commit 855028d
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ object AutoPot : Module("AutoPot", Category.COMBAT, hideModule = false) {
private val mode by ListValue("Mode", arrayOf("Normal", "Jump", "Port"), "Normal")

private val options = RotationSettings(this).withoutKeepRotation().apply {
rotationModeValue.set("On")

applyServerSideValue.isSupported = { false }
applyServerSideValue.note = BoolValue.NoteType.HIDE
resetTicksValue.isSupported = { false }
rotationModeValue.isSupported = { false }

immediate = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ object ProjectileAimbot : Module("ProjectileAimbot", Category.COMBAT, hideModule
private val predictSize by FloatValue("PredictSize", 2F, 0.1F..5F)
{ predict && gravityType == "Projectile"}

private val options = RotationSettings(this).withoutKeepRotation().apply {
rotationModeValue.set("On")
rotationModeValue.isSupported = { false }
}
private val options = RotationSettings(this).withoutKeepRotation()

private val randomizeRotations by BoolValue("RandomizeRotations", false) { options.rotationsActive }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ object NoRotateSet : Module("NoRotateSet", Category.MISC, gameDetecting = false,
val affectRotation by BoolValue("AffectRotation", true)

private val options = RotationSettings(this) { affectRotation }.apply {
rotationModeValue.set("On")
rotationModeValue.isSupported = { false }
applyServerSideValue.isSupported = { false }
applyServerSideValue.note = BoolValue.NoteType.HIDE
resetTicksValue.isSupported = { false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ object BedPlates : Module("BedPlates", Category.RENDER, hideModule = false) {
backgroundMode == "Gradient",
gradientX,
gradientY,
maxBackgroundGradientColors,
bgGradColors.toColorArray(maxBackgroundGradientColors),
gradientBackgroundSpeed,
gradientOffset
Expand All @@ -257,7 +256,6 @@ object BedPlates : Module("BedPlates", Category.RENDER, hideModule = false) {
textMode == "Gradient",
gradientX,
gradientY,
maxTextGradientColors,
textGradColors.toColorArray(maxTextGradientColors),
gradientTextSpeed,
gradientOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ import net.minecraft.util.*
import net.minecraft.world.WorldSettings
import net.minecraftforge.event.ForgeEventFactory
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11
import java.awt.Color
import javax.vecmath.Color3f
import kotlin.math.*

object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule = false) {
Expand Down Expand Up @@ -225,9 +223,10 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
) { eagleValue.isSupported() && eagle != "Off" }

// Rotation Options
private val options = RotationSettings(this).apply {
private val modeList = ListValue("Rotations", arrayOf("Off", "Normal", "Stabilized", "GodBridge"), "Normal")

private val options = RotationSettingsWithRotationModes(this, modeList).apply {
strictValue.isSupported = { false }
rotationModeValue.values = arrayOf("Off", "Normal", "Stabilized", "GodBridge")
resetTicksValue.setSupport { { it && scaffoldMode != "Telly" } }
}

Expand Down Expand Up @@ -296,7 +295,6 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
// Visuals
private val mark by BoolValue("Mark", false, subjective = true)
private val trackCPS by BoolValue("TrackCPS", false, subjective = true)
private val safetyLines by BoolValue("SafetyLines", false, subjective = true) { isGodBridgeEnabled }

// Target placement
var placeRotation: PlaceRotation? = null
Expand Down Expand Up @@ -819,6 +817,8 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
TickScheduler += {
serverSlot = player.inventory.currentItem
}

options.instant = false
}

// Entity movement event
Expand Down Expand Up @@ -868,8 +868,6 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
}
}

displaySafetyLinesIfEnabled()

if (!mark) {
return
}
Expand Down Expand Up @@ -909,6 +907,8 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
): Boolean {
val player = mc.thePlayer ?: return false

options.instant = false

if (!isReplaceable(blockPosition)) {
if (autoF5) mc.gameSettings.thirdPersonView = 0
return false
Expand Down Expand Up @@ -954,15 +954,15 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
placeRotation ?: return false

if (options.rotationsActive && !isGodBridgeEnabled) {
val rotationDifference = rotationDifference(placeRotation.rotation, currRotation)
val (hSpeed, vSpeed) = options.horizontalSpeed.random() to options.verticalSpeed.random()
val (factorH, factorV) = if (options.smootherMode == "Relative")
computeFactor(rotationDifference, hSpeed) to computeFactor(rotationDifference, vSpeed)
else hSpeed to vSpeed

options.instant = blockSafe && rotationDifference > (factorH + factorV) / 2f
setRotation(placeRotation.rotation, if (scaffoldMode == "Telly") 1 else options.resetTicks)
val rotationDifference = rotationDifference(placeRotation.rotation, currRotation)
val (hSpeed, vSpeed) = options.horizontalSpeed.random() to options.verticalSpeed.random()
val (factorH, factorV) = if (options.smootherMode == "Relative")
computeFactor(rotationDifference, hSpeed) to computeFactor(rotationDifference, vSpeed)
else hSpeed to vSpeed

options.instant = blockSafe && rotationDifference > (factorH + factorV) / 2f

setRotation(placeRotation.rotation, if (scaffoldMode == "Telly") 1 else options.resetTicks)
}

this.placeRotation = placeRotation
Expand Down Expand Up @@ -1102,105 +1102,6 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule
}
}

private fun displaySafetyLinesIfEnabled() {
if (!safetyLines || !isGodBridgeEnabled) {
return
}

val player = mc.thePlayer ?: return

// If player is not walking diagonally then continue
if (round(abs(MathHelper.wrapAngleTo180_float(player.rotationYaw)).roundToInt() / 45f) * 45f !in arrayOf(
135f,
45f
) || player.movementInput.moveForward == 0f || player.movementInput.moveStrafe != 0f
) {
val (posX, posY, posZ) = player.interpolatedPosition()

GL11.glPushMatrix()
GL11.glTranslated(-posX, -posY, -posZ)
GL11.glLineWidth(5.5f)
GL11.glDisable(GL11.GL_TEXTURE_2D)

val (yawX, yawZ) = player.horizontalFacing.directionVec.x * 1.5 to player.horizontalFacing.directionVec.z * 1.5

// The target rotation will either be the module's placeRotation or a forced rotation (usually that's where the GodBridge mode aims)
val targetRotation = run {
val yaw = floatArrayOf(-135f, -45f, 45f, 135f).minByOrNull {
abs(
RotationUtils.angleDifference(
it,
MathHelper.wrapAngleTo180_float(currRotation.yaw)
)
)
} ?: return

placeRotation?.rotation ?: Rotation(yaw, 73f)
}

// Calculate color based on rotation difference
val color = getColorForRotationDifference(
rotationDifference(
targetRotation,
currRotation
)
)

val main = BlockPos(player).down()

val pos = if (canBeClicked(main)) {
main
} else {
(-1..1).flatMap { x ->
(-1..1).map { z ->
val neighbor = main.add(x, 0, z)

neighbor to BlockUtils.getCenterDistance(neighbor)
}
}.filter { canBeClicked(it.first) }.minByOrNull { it.second }?.first ?: main
}.up().getVec()

for (offset in 0..1) {
for (i in -1..1 step 2) {
for (x1 in 0.25..0.5 step 0.01) {
val opposite = offset == 1

val (offsetX, offsetZ) = if (opposite) 0.0 to x1 * i else x1 * i to 0.0
val (lineX, lineZ) = if (opposite) yawX to 0.0 else 0.0 to yawZ

val (x, y, z) = pos.add(Vec3(offsetX, -0.99, offsetZ))

GL11.glBegin(GL11.GL_LINES)

GL11.glColor3f(color.x, color.y, color.z)
GL11.glVertex3d(x - lineX, y + 0.5, z - lineZ)
GL11.glVertex3d(x + lineX, y + 0.5, z + lineZ)

GL11.glEnd()
}
}
}
GL11.glEnable(GL11.GL_TEXTURE_2D)
GL11.glPopMatrix()
}
}

private fun getColorForRotationDifference(rotationDifference: Float): Color3f {
val maxDifferenceForGreen = 10.0f
val maxDifferenceForYellow = 40.0f

val interpolationFactor = when {
rotationDifference <= maxDifferenceForGreen -> 0.0f
rotationDifference <= maxDifferenceForYellow -> (rotationDifference - maxDifferenceForGreen) / (maxDifferenceForYellow - maxDifferenceForGreen)
else -> 1.0f
}

val green = 1.0f - interpolationFactor
val blue = 0.0f

return Color3f(interpolationFactor, green, blue)
}

private fun updatePlacedBlocksForTelly() {
if (blocksUntilAxisChange > horizontalPlacements + verticalPlacements) {
blocksUntilAxisChange = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import net.ccbluex.liquidbounce.features.module.modules.render.NoScoreboard;
import net.ccbluex.liquidbounce.ui.font.AWTFontRenderer;
import net.ccbluex.liquidbounce.utils.ClassUtils;
import net.ccbluex.liquidbounce.utils.render.*;
import net.ccbluex.liquidbounce.utils.render.ColorSettingsKt;
import net.ccbluex.liquidbounce.utils.render.FakeItemRender;
import net.ccbluex.liquidbounce.utils.render.RenderUtils;
import net.ccbluex.liquidbounce.utils.render.shader.shaders.GradientShader;
import net.ccbluex.liquidbounce.utils.render.shader.shaders.RainbowShader;
import net.minecraft.client.Minecraft;
Expand All @@ -27,7 +29,10 @@
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand Down Expand Up @@ -68,7 +73,9 @@ public abstract class MixinGuiInGame extends Gui {
@Shadow
protected abstract void renderHotbarItem(int index, int xPos, int yPos, float partialTicks, EntityPlayer player);

@Shadow @Final protected Minecraft mc;
@Shadow
@Final
protected Minecraft mc;

@Inject(method = "renderScoreboard", at = @At("HEAD"), cancellable = true)
private void renderScoreboard(CallbackInfo callbackInfo) {
Expand Down Expand Up @@ -158,7 +165,6 @@ protected void renderTooltip(ScaledResolution sr, float partialTicks) {
true,
gradientX,
gradientY,
hud.getMaxHotbarGradientColors(),
gradientColors,
hud.getGradientHotbarSpeed(),
gradientOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ class Arraylist(
!markAsInactive && backgroundMode == "Gradient",
gradientX,
gradientY,
maxBackgroundGradientColors,
bgGradColors.toColorArray(maxBackgroundGradientColors),
gradientBackgroundSpeed,
gradientOffset
Expand All @@ -283,7 +282,6 @@ class Arraylist(
!markAsInactive && textColorMode == "Gradient",
gradientX,
gradientY,
maxTextGradientColors,
textGradColors.toColorArray(maxTextGradientColors),
gradientTextSpeed,
gradientOffset
Expand Down Expand Up @@ -311,7 +309,6 @@ class Arraylist(
!markAsInactive && isCustomRectGradientSupported,
gradientX,
gradientY,
maxRectGradientColors,
rectGradColors.toColorArray(maxRectGradientColors),
gradientRectSpeed,
gradientOffset
Expand Down Expand Up @@ -384,7 +381,6 @@ class Arraylist(
!markAsInactive && backgroundMode == "Gradient",
gradientX,
gradientY,
maxBackgroundGradientColors,
bgGradColors.toColorArray(maxBackgroundGradientColors),
gradientBackgroundSpeed,
gradientOffset
Expand All @@ -407,7 +403,6 @@ class Arraylist(
!markAsInactive && textColorMode == "Gradient",
gradientX,
gradientY,
maxTextGradientColors,
textGradColors.toColorArray(maxTextGradientColors),
gradientTextSpeed,
gradientOffset
Expand Down Expand Up @@ -436,7 +431,6 @@ class Arraylist(
!markAsInactive && isCustomRectGradientSupported,
gradientX,
gradientY,
maxRectGradientColors,
rectGradColors.toColorArray(maxRectGradientColors),
gradientRectSpeed,
gradientOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class BlockCounter(x: Double = 520.0, y: Double = 245.0) : Element(x = x, y = y)
GradientShader.begin(backgroundMode == "Gradient",
gradientX,
gradientY,
maxBackgroundGradientColors,
bgGradColors.toColorArray(maxBackgroundGradientColors),
gradientBackgroundSpeed,
gradientOffset
Expand All @@ -103,7 +102,6 @@ class BlockCounter(x: Double = 520.0, y: Double = 245.0) : Element(x = x, y = y)
GradientFontShader.begin(textColorMode == "Gradient",
gradientX,
gradientY,
maxTextGradientColors,
textGradColors.toColorArray(maxTextGradientColors),
gradientTextSpeed,
gradientOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import net.ccbluex.liquidbounce.utils.render.ColorSettingsFloat
import net.ccbluex.liquidbounce.utils.render.ColorSettingsInteger
import net.ccbluex.liquidbounce.utils.render.ColorUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRoundedBorder
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRoundedBorderRect
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRoundedRect
import net.ccbluex.liquidbounce.utils.render.shader.shaders.GradientFontShader
import net.ccbluex.liquidbounce.utils.render.shader.shaders.GradientShader
Expand Down Expand Up @@ -277,7 +276,6 @@ class Text(x: Double = 10.0, y: Double = 10.0, scale: Float = 1F, side: Side = S
backgroundMode == "Gradient",
gradientX,
gradientY,
maxBackgroundGradientColors,
bgGradColors.toColorArray(maxBackgroundGradientColors),
gradientBackgroundSpeed,
gradientOffset
Expand Down Expand Up @@ -335,7 +333,6 @@ class Text(x: Double = 10.0, y: Double = 10.0, scale: Float = 1F, side: Side = S
GradientFontShader.begin(gradient,
gradientX,
gradientY,
maxTextGradientColors,
textGradColors.toColorArray(maxTextGradientColors),
gradientTextSpeed,
gradientOffset
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/net/ccbluex/liquidbounce/utils/ClassUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ object ClassUtils {
}
}

val superclass = element::class.java.superclass

/**
* For classes with values that include their value-containing super classes
*
* Example: class ClassWithValues() : OriginalClassWithValues()
*/
if (superclass?.`package`?.name?.contains("liquidbounce") == true && !Value::class.java.isAssignableFrom(superclass)) {
superclass.declaredFields.forEach {
it.isAccessible = true
val fieldValue = it[element] ?: return@forEach

if (fieldValue is Value<*>) {
list += fieldValue
} else {
findValues(fieldValue, configurables, list)
}
}
}

element.javaClass.declaredFields.forEach {
it.isAccessible = true
val fieldValue = it[element] ?: return@forEach
Expand Down
Loading

0 comments on commit 855028d

Please sign in to comment.