From 0163f28f1ffba0fc13742306f72bfb4dead3fffa Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 7 Aug 2022 21:30:16 +0200 Subject: [PATCH 01/85] Fix broken readme links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 622186b6d..0a86bd345 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,13 @@ Customize your experience, and improve your efficiency! Find our plugins [here](https://github.com/lambda-plugins).

- lambda-3.2.1.jar + lambda-3.2.1.jar

## Installation 1. Install Minecraft 1.12.2 2. Install the latest Forge for 1.12.2 [(download)](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.12.2.html) -3. Get the latest Lambda version here [(download)](https://github.com/lambda-client/lambda/releases/download/3.1/lambda-3.1.jar) +3. Get the latest Lambda version here [(download)](https://github.com/lambda-client/lambda/releases/download/3.2.1/lambda-3.2.1.jar) 4. Put the file in your `.minecraft/mods` folder ## FAQ From acb91c6ec835511569a6399f9229a0be0ee88e22 Mon Sep 17 00:00:00 2001 From: Nep Nep <43792621+NepNep21@users.noreply.github.com> Date: Mon, 8 Aug 2022 13:56:23 -0300 Subject: [PATCH 02/85] Fix opening URLs on linux without gnome (#362) --- src/main/kotlin/com/lambda/client/util/WebUtils.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/util/WebUtils.kt b/src/main/kotlin/com/lambda/client/util/WebUtils.kt index 7f8c7e5fd..8aa8d5e10 100644 --- a/src/main/kotlin/com/lambda/client/util/WebUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/WebUtils.kt @@ -57,7 +57,14 @@ object WebUtils { fun openWebLink(url: String) { try { - Desktop.getDesktop().browse(URI(url)) + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { + Desktop.getDesktop().browse(URI(url)) + } else { + val exitCode = Runtime.getRuntime().exec(arrayOf("xdg-open", url)).waitFor() + if (exitCode != 0) { + LambdaMod.LOG.error("Couldn't open link, xdg-open returned: $exitCode") + } + } } catch (e: IOException) { LambdaMod.LOG.error("Couldn't open link: $url") } From a16e98cf7e24fb066f073c4a7e060256d259b1ba Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Thu, 25 Aug 2022 14:29:10 -0400 Subject: [PATCH 03/85] Updated module descriptions (#372) * Updated module description Changed wording to be more clear and grammatically correct :3 * Updated module description Fixed up description to be shorter and easier to understand * Updated module description Removed the word used as the sentence makes the utilization clear without, and changed action to interaction as the player has interactions with the world, not actions. * Updated module description Changed transactions to interactions, as interactions is a word that better suits the intent of the sentence and reflects what a player is doing, interacting with their inventory, not making a transaction. * Updated description --- .../com/lambda/client/module/modules/player/NoGhostItems.kt | 4 ++-- .../com/lambda/client/module/modules/player/PacketCancel.kt | 4 ++-- .../com/lambda/client/module/modules/player/PacketLimiter.kt | 4 ++-- .../com/lambda/client/module/modules/player/PortalGodMode.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt index dbf3caf68..1fabbde5b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt @@ -14,7 +14,7 @@ import com.lambda.mixin.player.MixinPlayerControllerMP */ object NoGhostItems : Module( name = "NoGhostItems", - description = "Syncs inventory transactions for strict environments", + description = "Syncs inventory interactions for strict environments", category = Category.PLAYER ) { val syncMode by setting("Scope", SyncMode.MODULES) @@ -41,4 +41,4 @@ object NoGhostItems : Module( false } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt index 5a5f93f7f..c6f4857d8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt @@ -18,7 +18,7 @@ import net.minecraft.network.status.server.SPacketServerInfo object PacketCancel : Module( name = "PacketCancel", - description = "Cancels specific packets used for various actions", + description = "Cancels specific packets for various interactions", category = Category.PLAYER ) { enum class Side { @@ -285,4 +285,4 @@ object PacketCancel : Module( } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt index 18684a237..bf4a41e52 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt @@ -13,7 +13,7 @@ import kotlin.math.min object PacketLimiter : Module( name = "PacketLimiter", - description = "Adjust timer automatically to ensure not sending too many movement packets", + description = "Automatically adjusts timer to prevent sending excess movement packets", category = Category.PLAYER, modulePriority = 1000 ) { @@ -102,4 +102,4 @@ object PacketLimiter : Module( private fun limit(input: Float, max: Float) = if (input > max) max / input else null -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt index 19438be3e..01d35f06a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt @@ -9,7 +9,7 @@ import net.minecraft.network.play.client.CPacketConfirmTeleport object PortalGodMode : Module( name = "PortalGodMode", - description = "Don't take damage in portals", + description = "Prevents taking damage in portals", category = Category.PLAYER ) { private val instantTeleport by setting("Instant Teleport", true) @@ -35,4 +35,4 @@ object PortalGodMode : Module( packet = it.packet } } -} \ No newline at end of file +} From cac232dd2c56d9aaca8a6135c8d03f0b084a9a55 Mon Sep 17 00:00:00 2001 From: cattyn <60744119+cattyngmd@users.noreply.github.com> Date: Thu, 1 Sep 2022 05:21:55 +0300 Subject: [PATCH 04/85] Replaced getRoundedMovementInput method with math.sign (#374) --- .../kotlin/com/lambda/client/util/MovementUtils.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/util/MovementUtils.kt b/src/main/kotlin/com/lambda/client/util/MovementUtils.kt index 72c2d9472..f43ab0101 100644 --- a/src/main/kotlin/com/lambda/client/util/MovementUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/MovementUtils.kt @@ -11,6 +11,7 @@ import net.minecraft.util.MovementInput import net.minecraft.util.math.BlockPos import kotlin.math.cos import kotlin.math.hypot +import kotlin.math.sign import kotlin.math.sin object MovementUtils { @@ -36,14 +37,8 @@ object MovementUtils { return Math.toRadians(yaw.toDouble()) } - private val roundedForward get() = getRoundedMovementInput(mc.player.movementInput.moveForward) - private val roundedStrafing get() = getRoundedMovementInput(mc.player.movementInput.moveStrafe) - - private fun getRoundedMovementInput(input: Float) = when { - input > 0f -> 1f - input < 0f -> -1f - else -> 0f - } + private val roundedForward get() = sign(mc.player.movementInput.moveForward) + private val roundedStrafing get() = sign(mc.player.movementInput.moveStrafe) fun SafeClientEvent.setSpeed(speed: Double) { val yaw = calcMoveYaw() From 47ed35ea6193b333446eefed01e15b06819cbf52 Mon Sep 17 00:00:00 2001 From: Nep Nep <43792621+NepNep21@users.noreply.github.com> Date: Wed, 31 Aug 2022 23:30:29 -0300 Subject: [PATCH 05/85] Add a configurable DiscordRPC delay (#373) --- .../com/lambda/client/module/modules/misc/DiscordRPC.kt | 3 ++- .../kotlin/com/lambda/client/util/threads/BackgroundJob.kt | 7 ++++--- .../com/lambda/client/util/threads/BackgroundScope.kt | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt index f81734a22..e54b3d944 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt @@ -35,6 +35,7 @@ object DiscordRPC : Module( private val line2Left by setting("Line 2 Left", LineInfo.DIMENSION) // state left private val line2Right by setting("Line 2 Right", LineInfo.HEALTH) // state right private val coordsConfirm by setting("Coords Confirm", false, { showCoordsConfirm() }) + private val delay by setting("Update Delay", 5000, 500..60000, 1) private enum class LineInfo { VERSION, WORLD, DIMENSION, USERNAME, HEALTH, HUNGER, SERVER_IP, COORDS, SPEED, HELD_ITEM, FPS, TPS, NONE @@ -46,7 +47,7 @@ object DiscordRPC : Module( private val rpcBuilder = RichPresence.Builder() .setLargeImage("default", "https://github.com/lambda-client/lambda/") private val timer = TickTimer(TimeUnit.SECONDS) - private val job = BackgroundJob("Discord RPC", 5000L) { updateRPC() } + private val job = BackgroundJob("Discord RPC", { delay.toLong() }) { updateRPC() } init { onEnable { diff --git a/src/main/kotlin/com/lambda/client/util/threads/BackgroundJob.kt b/src/main/kotlin/com/lambda/client/util/threads/BackgroundJob.kt index d629caaec..cd7f3cebe 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/BackgroundJob.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/BackgroundJob.kt @@ -4,15 +4,16 @@ import kotlinx.coroutines.CoroutineScope class BackgroundJob( val name: String, - val delay: Long, + val delay: () -> Long, val block: suspend CoroutineScope.() -> Unit ) { + constructor(name: String, delay: Long, block: suspend CoroutineScope.() -> Unit) : this(name, { delay }, block) override fun equals(other: Any?) = this === other || (other is BackgroundJob && name == other.name - && delay == other.delay) + && delay() == other.delay()) - override fun hashCode() = 31 * name.hashCode() + delay.hashCode() + override fun hashCode() = 31 * name.hashCode() + delay().hashCode() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt b/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt index 261aac306..9819df6fe 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt @@ -40,7 +40,7 @@ object BackgroundScope : CoroutineScope by CoroutineScope(newFixedThreadPoolCont } catch (e: Exception) { LambdaMod.LOG.warn("Error occurred while running background job ${job.name}", e) } - delay(job.delay) + delay(job.delay()) } } } From 242e9d38e155c2539466e3ee81960119585538e2 Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 1 Sep 2022 04:36:48 +0200 Subject: [PATCH 06/85] Have reasonable step size in delay setting --- .../com/lambda/client/module/modules/misc/DiscordRPC.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt index e54b3d944..e1f1faf68 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt @@ -35,7 +35,7 @@ object DiscordRPC : Module( private val line2Left by setting("Line 2 Left", LineInfo.DIMENSION) // state left private val line2Right by setting("Line 2 Right", LineInfo.HEALTH) // state right private val coordsConfirm by setting("Coords Confirm", false, { showCoordsConfirm() }) - private val delay by setting("Update Delay", 5000, 500..60000, 1) + private val delay by setting("Update Delay", 5, 1..60, 1, unit = " s") private enum class LineInfo { VERSION, WORLD, DIMENSION, USERNAME, HEALTH, HUNGER, SERVER_IP, COORDS, SPEED, HELD_ITEM, FPS, TPS, NONE @@ -47,7 +47,7 @@ object DiscordRPC : Module( private val rpcBuilder = RichPresence.Builder() .setLargeImage("default", "https://github.com/lambda-client/lambda/") private val timer = TickTimer(TimeUnit.SECONDS) - private val job = BackgroundJob("Discord RPC", { delay.toLong() }) { updateRPC() } + private val job = BackgroundJob("Discord RPC", { delay * 1000L }) { updateRPC() } init { onEnable { @@ -137,7 +137,7 @@ object DiscordRPC : Module( try { ipc.connect() } catch (e: NoDiscordClientException) { - // Add something here if you want to spam the log i guess + // Add something here if you want to spam the log I guess } } From 862ef05f7f4ba76729878dfafb2e02640d9bf8a1 Mon Sep 17 00:00:00 2001 From: Maarten <50550545+mmvanheusden@users.noreply.github.com> Date: Mon, 5 Sep 2022 01:03:01 +0200 Subject: [PATCH 07/85] Add a timer "only when inputting" option (#370) * Add a timer "only when inputting option" * Fix setting name convention * Make timer pause in ClickGUI Co-authored-by: Constructor --- .../com/lambda/client/module/modules/player/Timer.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index 616c578bc..d0ad54d3e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -5,6 +5,8 @@ import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.module.modules.client.ClickGUI +import com.lambda.client.util.MovementUtils import net.minecraftforge.fml.common.gameevent.TickEvent object Timer : Module( @@ -13,6 +15,7 @@ object Timer : Module( category = Category.PLAYER, modulePriority = 500 ) { + private val onlyWhenInputting by setting("Only When Inputting", false) private val slow by setting("Slow Mode", false) private val tickNormal by setting("Tick N", 2.0f, 1f..10f, 0.1f, { !slow }) private val tickSlow by setting("Tick S", 8f, 1f..10f, 0.1f, { slow }) @@ -25,8 +28,15 @@ object Timer : Module( listener { if (it.phase != TickEvent.Phase.END) return@listener + if (ClickGUI.isEnabled) { + resetTimer() + return@listener + } + val multiplier = if (!slow) tickNormal else tickSlow / 10.0f - modifyTimer(50.0f / multiplier) + if (onlyWhenInputting) { + if (MovementUtils.isInputting) modifyTimer(50.0f / multiplier) + } else modifyTimer(50.0f / multiplier) } } } \ No newline at end of file From 1e5306dbb9522d3d0f2e0bdef864d24bb2b1cb33 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:55:00 -0400 Subject: [PATCH 08/85] Updated README to fix a single wrong capitalization (#385) Refer to title lol. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a86bd345..60cf3236b 100644 --- a/README.md +++ b/README.md @@ -138,4 +138,4 @@ Our [contributors](https://github.com/lambda-client/lambda/graphs/contributors) [![Stargazers](https://starchart.cc/lambda-client/lambda.svg)](https://starchart.cc/lambda-client/lambda) > ### Disclaimer -> This software does not contain any copyrighted Minecraft code. This is a Forge utility mod, Only meant for use in anarchy environments. Do not use without permission of server administration. +> This software does not contain any copyrighted Minecraft code. This is a Forge utility mod, only meant for use in anarchy environments. Do not use without permission of server administration. From 1a667b1a22845f1e66b8ffadd1302874305320c4 Mon Sep 17 00:00:00 2001 From: Nep Nep <43792621+NepNep21@users.noreply.github.com> Date: Wed, 28 Sep 2022 23:21:31 -0300 Subject: [PATCH 09/85] Add a configurable StorageESP max range (#377) * Add configurable StorageESP max range * Remove unnecessary float --- .../com/lambda/client/module/modules/render/StorageESP.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt index 6ad5f206d..36280c352 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt @@ -10,6 +10,7 @@ import com.lambda.client.util.color.DyeColors import com.lambda.client.util.color.HueCycler import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.graphics.GeometryMasks +import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.threads.safeAsyncListener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope @@ -38,6 +39,8 @@ object StorageESP : Module( private val dispenser by setting("Dispenser", false, { page == Page.TYPE }) private val hopper by setting("Hopper", false, { page == Page.TYPE }) private val cart by setting("Minecart", false, { page == Page.TYPE }) + private val infinite by setting("Infinite Range", true) // To avoid a hard to control range slider + private val range by setting("Range", 64, 8..512, 1, { page == Page.TYPE && !infinite }, unit = " blocks") /* Color settings */ private val colorChest by setting("Chest Color", DyeColors.ORANGE, { page == Page.COLOR }) @@ -105,6 +108,7 @@ object StorageESP : Module( private fun SafeClientEvent.updateTileEntities(list: MutableList>) { for (tileEntity in world.loadedTileEntityList.toList()) { + if (!infinite && player.distanceTo(tileEntity.pos) > range) continue if (!checkTileEntityType(tileEntity)) continue val box = world.getBlockState(tileEntity.pos).getSelectedBoundingBox(world, tileEntity.pos) ?: continue @@ -150,6 +154,7 @@ object StorageESP : Module( private fun SafeClientEvent.updateEntities(list: MutableList>) { for (entity in world.loadedEntityList.toList()) { + if (!infinite && player.getDistance(entity) > range) continue if (!checkEntityType(entity)) continue val box = entity.renderBoundingBox ?: continue From f73ce31836b981120b2cf17ecb76c24b75a247a2 Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 29 Sep 2022 04:53:27 +0200 Subject: [PATCH 10/85] Add option to set fade animation timing for Tracer (#388) * Add option to set fade animation timing for Tracer was unnecessary complicated lol * Better slider segment size * Allowing insta fade --- .../client/module/modules/render/Tracers.kt | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt index 9f17dd06e..741a16961 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt @@ -17,7 +17,6 @@ import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.concurrent.ConcurrentHashMap -import kotlin.math.min object Tracers : Module( name = "Tracers", @@ -49,6 +48,7 @@ object Tracers : Module( private val alpha by setting("Alpha", 255, 0..255, 1, { page == Page.RENDERING }) private val yOffset by setting("Y Offset Percentage", 0, 0..100, 5, { page == Page.RENDERING }) private val thickness by setting("Line Thickness", 2.0f, 0.25f..5.0f, 0.25f, { page == Page.RENDERING }) + private val fadeSpeed by setting("Fade Speed", 150, 0..500, 25, { page == Page.RENDERING }, unit = "ms") /* Range color settings */ private val rangedColor by setting("Ranged Color", true, { page == Page.RANGE_COLOR }) @@ -60,7 +60,7 @@ object Tracers : Module( ENTITY_TYPE, COLOR, RENDERING, RANGE_COLOR } - private var renderList = ConcurrentHashMap>() /* > */ + private var renderList = ConcurrentHashMap() private var cycler = HueCycler(600) private val renderer = ESPRenderer() @@ -70,9 +70,19 @@ object Tracers : Module( renderer.thickness = thickness renderer.tracerOffset = yOffset - for ((entity, pair) in renderList) { - val rgba = pair.first.clone() - rgba.a = (rgba.a * pair.second).toInt() + for ((entity, tracerData) in renderList) { + val rgba = tracerData.color.clone() + + if (fadeSpeed > 0) { + val animationCoefficient = tracerData.age * tracerData.color.a / fadeSpeed + + rgba.a = if (tracerData.isEntityPresent) { + animationCoefficient.toInt().coerceAtMost(tracerData.color.a) + } else { + (-animationCoefficient + tracerData.color.a).toInt().coerceAtLeast(0) + } + } + renderer.add(entity, rgba) } @@ -91,22 +101,26 @@ object Tracers : Module( ArrayList() } - val cacheMap = HashMap>() - for (entity in entityList) { - cacheMap[entity] = Pair(getColor(entity), 0f) + entityList.forEach { entity -> + renderList.computeIfAbsent(entity) { + TracerData(getColor(entity), System.currentTimeMillis(), true) + } } - for ((entity, pair) in renderList) { - cacheMap.computeIfPresent(entity) { _, cachePair -> Pair(cachePair.first, min(pair.second + 0.075f, 1f)) } - cacheMap.computeIfAbsent(entity) { Pair(getColor(entity), pair.second - 0.05f) } + renderList.forEach { (entity, tracerData) -> + if (entityList.contains(entity)) { + tracerData.color = getColor(entity) + return@forEach + } - if (pair.second < 0f) { - cacheMap.remove(entity) + if (tracerData.isEntityPresent) { + tracerData.isEntityPresent = false + tracerData.timeStamp = System.currentTimeMillis() + return@forEach } - } - renderList.clear() - renderList.putAll(cacheMap) + if (tracerData.age > fadeSpeed || fadeSpeed == 0) renderList.remove(entity) + } } } @@ -132,4 +146,8 @@ object Tracers : Module( val a = convertRange(distance, 0f, colorChangeRange.toFloat(), alpha.toFloat(), alphaFar.toFloat()).toInt() return ColorHolder(r, g, b, a) } + + private data class TracerData(var color: ColorHolder, var timeStamp: Long, var isEntityPresent: Boolean) { + val age get() = System.currentTimeMillis() - timeStamp + } } From 3dcbc8a6840ef5cbcb2e2dd1d3f5075ecd720fe9 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Thu, 29 Sep 2022 20:57:02 -0400 Subject: [PATCH 11/85] Revamped the README and fixed grammer and punctuation. (#389) --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 60cf3236b..4c7594c4a 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,14 @@ How do I...
... open the ClickGUI? -> Press `Y` +> Press `Y`.
... execute a command? -> Use the ingame chat with the prefix `;` +> Use the ingame chat with the prefix `;`.
@@ -55,15 +55,15 @@ How do I...
... export KAMI blue config to Lambda? -> Rename `.minecraft/kamiblue` to `.minecraft/lambda` -> Note that this might cause stability issues. +> Rename `.minecraft/kamiblue` to `.minecraft/lambda`. +> Please note that this might cause stability issues.
... fix most crashes on startup? -> Possibly you have multiple mods loaded. Forge loads mods in alphabetical order, so you can change the name of the Mod jar to make it load earlier or later. Add for example an exclamation mark to lambda jar to make it load first. +> You may have multiple mods loaded. Forge loads mods in alphabetical order, so you can change the name of the Mod jar to make it load earlier or later. Add for example an exclamation mark to lambda jar to make it load first. > If you got `Error: java.lang.IllegalAccessError: tried to access field net.minecraft.util.math.Vec3i.field_177962_a from class baritone.k` remove the `-noverify` tag from your arguments.
@@ -72,21 +72,21 @@ How do I... ... fix problems with Gradle? > Make sure you have a Java 8 JDK installed and in your PATH. -We recommend using the [Temurin](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot/) distribution of OpenJDK +We advise using the [Temurin](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot/) distribution of OpenJDK.
... reset the ClickGUI scale? -> Run the command `;set clickgui scale 100` +> Run the command `;set clickgui scale 100`.
... crashing with liteloader? -> Use liteloader as a forge mod, it is available [here](https://jenkins.liteloader.com/view/1.12.2/job/LiteLoader%201.12.2/lastSuccessfulBuild/artifact/build/libs/liteloader-1.12.2-SNAPSHOT-release.jar) +> Use liteloader as a forge mod, it is available [here](https://jenkins.liteloader.com/view/1.12.2/job/LiteLoader%201.12.2/lastSuccessfulBuild/artifact/build/libs/liteloader-1.12.2-SNAPSHOT-release.jar).

@@ -103,24 +103,24 @@ git clone https://github.com/lambda-client/lambda ``` Run `setupWorkspace.sh` to initialize the environment. -With terminal on Linux or [Git Bash](https://gitforwindows.org/) for Windows +Use your terminal on Linux or [Git Bash](https://gitforwindows.org/) for Windows. ``` ./setupWorkspace.sh ``` ### Setup IDE -In this guide we will use [IntelliJ IDEA](https://www.jetbrains.com/idea/) as IDE. +In this guide we will use [IntelliJ IDEA](https://www.jetbrains.com/idea/) as our IDE. 1. Open the project from `File > Open...` 2. Let the IDE collect dependencies and index the code. 3. Goto `File > Project Structure... > SDKs` and make sure an SDK for Java 8 is installed and selected, if not download - it [here](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot/) + one [here](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot/). ### Gradle build -Test if the environment is set up correctly by building the client and run it inside IDE using the Gradle tab on the right side of the IDE. +Test if the environment is set up correctly by building the client and running it inside the IDE using the Gradle tab on the right side of the IDE. 1. Go to `lambda > Tasks > build > runClient` in the Gradle tab and run the client. -2. To build the client as a jar run `lambda > Tasks > build > build`. Gradle will create a new directory called `build`. The final built jar will be in `build/libs` +2. To build the client as a jar run `lambda > Tasks > build > build`. Gradle will create a new directory called `build`. The final built jar will be in `build/libs`. ## Thanks to From 9b36ff4d1d54f09db7dae3e256972f52cad04434 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 29 Sep 2022 18:44:45 -0700 Subject: [PATCH 12/85] Mouse bindings (#379) * Mouse bindings * Allow mid click bindings and use button name numbers instead of index Human-readable mouse names start with 1. Using this scheme aligns with what you'd see in RusherHack for example. To accomplish this, any raw mouse input that comes as an index we simply increment by 1. I'm planning on PR'ing a hud module that shows all bindings, again like in Rusherhack. So this would trigger my OCD having those bind names not align between clients. * fix comment and comparisons for clarity * clarify what min index means * Cleanup and cast safety * More null safety (!! can throw an exception) also mousekey is concurrent and may change after first null check. Co-authored-by: Constructor --- .../client/event/ForgeEventProcessor.kt | 13 +++--- .../client/gui/rgui/component/BindButton.kt | 6 +++ .../com/lambda/client/module/ModuleManager.kt | 12 +++-- .../settings/impl/other/BindSetting.kt | 8 +++- .../kotlin/com/lambda/client/util/Bind.kt | 45 +++++++++++++++---- .../com/lambda/client/util/KeyboardUtils.kt | 2 +- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt b/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt index 13f23e040..f98b5f3e8 100644 --- a/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt +++ b/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt @@ -22,6 +22,7 @@ import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.network.FMLNetworkEvent import org.lwjgl.input.Keyboard +import org.lwjgl.input.Mouse internal object ForgeEventProcessor { private val mc = Wrapper.minecraft @@ -82,6 +83,13 @@ internal object ForgeEventProcessor { ModuleManager.onBind(Keyboard.getEventKey()) } + @SubscribeEvent + fun onEventMouse(event: InputEvent.MouseInputEvent) { + LambdaEventBus.post(event) + if (!Mouse.getEventButtonState()) return + ModuleManager.onMouseBind(Mouse.getEventButton() + 1) + } + @SubscribeEvent(priority = EventPriority.HIGHEST) fun onChatSent(event: ClientChatEvent) { MessageDetection.Command.BARITONE.removedOrNull(event.message)?.let { @@ -94,11 +102,6 @@ internal object ForgeEventProcessor { } } - @SubscribeEvent - fun onEventMouse(event: InputEvent.MouseInputEvent) { - LambdaEventBus.post(event) - } - /** * Includes events of subclasses like ChunkEvent and GetCollisionBoxesEvent */ diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/BindButton.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/BindButton.kt index 8218631ae..b78991113 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/BindButton.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/BindButton.kt @@ -4,6 +4,7 @@ import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.CustomFont import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.setting.settings.impl.other.BindSetting +import com.lambda.client.util.Bind.Companion.minMouseIndex import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f @@ -20,6 +21,11 @@ class BindButton( override fun onRelease(mousePos: Vec2f, buttonId: Int) { super.onRelease(mousePos, buttonId) + if (listening && buttonId >= minMouseIndex) { + setting.value.apply { + setMouseBind(buttonId + 1) + } + } listening = !listening } diff --git a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt index 407dcc0ec..2e45c09a1 100644 --- a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt +++ b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt @@ -64,9 +64,15 @@ object ModuleManager : AsyncLoader>> { internal fun onBind(eventKey: Int) { if (Keyboard.isKeyDown(Keyboard.KEY_F3)) return // if key is the 'none' key (stuff like mod key in i3 might return 0) - for (module in modules) { - if (module.bind.value.isDown(eventKey)) module.toggle() - } + modules.filter { + it.bind.value.isDown(eventKey) + }.forEach { it.toggle() } + } + + internal fun onMouseBind(eventMouse: Int) { + modules.filter { + it.bind.value.isMouseDown(eventMouse) + }.forEach { it.toggle() } } fun getModuleOrNull(moduleName: String?) = moduleName?.let { moduleSet[it] } diff --git a/src/main/kotlin/com/lambda/client/setting/settings/impl/other/BindSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/impl/other/BindSetting.kt index 78897de10..23e224f27 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/impl/other/BindSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/impl/other/BindSetting.kt @@ -14,7 +14,7 @@ class BindSetting( description: String = "" ) : ImmutableSetting(name, value, visibility, { _, input -> input }, description, unit = "") { - override val defaultValue: Bind = Bind(TreeSet(value.modifierKeys), value.key) + override val defaultValue: Bind = Bind(TreeSet(value.modifierKeys), value.key, null) override fun resetValue() { value.setBind(defaultValue.modifierKeys, defaultValue.key) @@ -25,6 +25,12 @@ class BindSetting( value.clear() return } + if (valueIn.startsWith("Mouse", ignoreCase = true)) { + valueIn.split("Mouse").lastOrNull()?.toIntOrNull()?.let { + value.setMouseBind(it) + } + return + } val splitNames = valueIn.split('+') val lastKey = KeyboardUtils.getKey(splitNames.last()) diff --git a/src/main/kotlin/com/lambda/client/util/Bind.kt b/src/main/kotlin/com/lambda/client/util/Bind.kt index 5f87f5818..a27c686c7 100644 --- a/src/main/kotlin/com/lambda/client/util/Bind.kt +++ b/src/main/kotlin/com/lambda/client/util/Bind.kt @@ -5,20 +5,23 @@ import java.util.* class Bind( modifierKeysIn: TreeSet, - keyIn: Int + keyIn: Int, + mouseIn: Int? ) { constructor() : this(0) - constructor(key: Int) : this(TreeSet(keyComparator), key) + constructor(key: Int) : this(TreeSet(keyComparator), key, null) - constructor(vararg modifierKeys: Int, key: Int) : this(TreeSet(keyComparator).apply { modifierKeys.forEach { add(it) } }, key) + constructor(vararg modifierKeys: Int, key: Int) : this(TreeSet(keyComparator).apply { modifierKeys.forEach { add(it) } }, key, null) val modifierKeys = modifierKeysIn var key = keyIn; private set + var mouseKey = mouseIn; private set + private var cachedName = getName() - val isEmpty get() = key !in 1..255 + val isEmpty get() = key !in 1..255 && compareValues(mouseKey, minMouseIndex) < 0 fun isDown(eventKey: Int): Boolean { return eventKey != 0 @@ -27,6 +30,12 @@ class Bind( && synchronized(this) { modifierKeys.all { isModifierKeyDown(eventKey, it) } } } + fun isMouseDown(eventKey: Int): Boolean { + return eventKey > minMouseIndex + && !isEmpty + && mouseKey == (eventKey) + } + private fun isModifierKeyDown(eventKey: Int, modifierKey: Int) = eventKey != modifierKey && when (modifierKey) { @@ -62,11 +71,21 @@ class Bind( setBind(cache, keyIn) } + fun setMouseBind(mouseIn: Int) { + synchronized(this) { + modifierKeys.clear() + key = 0 + mouseKey = mouseIn + cachedName = getName() + } + } + fun setBind(modifierKeysIn: Collection, keyIn: Int) { synchronized(this) { modifierKeys.clear() modifierKeys.addAll(modifierKeysIn) key = keyIn + mouseKey = null cachedName = getName() } } @@ -75,6 +94,7 @@ class Bind( synchronized(this) { modifierKeys.clear() key = 0 + mouseKey = null cachedName = getName() } } @@ -88,18 +108,25 @@ class Bind( "None" } else { StringBuilder().run { - for (key in modifierKeys) { - val name = modifierName[key] ?: KeyboardUtils.getDisplayName(key) ?: continue - append(name) - append('+') + mouseKey?.let { + if (it > minMouseIndex) append("Mouse$mouseKey") + } ?: run { + for (key in modifierKeys) { + val name = modifierName[key] ?: KeyboardUtils.getDisplayName(key) ?: continue + append(name) + append('+') + } + append(KeyboardUtils.getDisplayName(key)) } - append(KeyboardUtils.getDisplayName(key)) + toString() } } } companion object { + const val minMouseIndex: Int = 2 // middle click button index. Button number = index + 1. + private val modifierName: Map = hashMapOf( Keyboard.KEY_LCONTROL to "Ctrl", Keyboard.KEY_RCONTROL to "Ctrl", diff --git a/src/main/kotlin/com/lambda/client/util/KeyboardUtils.kt b/src/main/kotlin/com/lambda/client/util/KeyboardUtils.kt index ac43a33fe..24f442fbb 100644 --- a/src/main/kotlin/com/lambda/client/util/KeyboardUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/KeyboardUtils.kt @@ -36,7 +36,7 @@ object KeyboardUtils { fun sendUnknownKeyError(bind: String) { MessageSendHelper.sendErrorMessage("Unknown key [${formatValue(bind)}]! " + "Right shift is ${formatValue("rshift")}, " + - "left Control is ${formatValue("lcontrol")}, " + + "left control is ${formatValue("lcontrol")}, " + "and ` is ${formatValue("grave")}. " + "You cannot bind the ${formatValue("meta")} key." ) From c752c5f10c0951e8d4aa90091e7860b210dd7836 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Sun, 2 Oct 2022 21:51:48 -0400 Subject: [PATCH 13/85] Redid the ASCII logo with more detail (#394) Redid the lambda logo in ASCII, with color and much more detail. I think it looks pretty good compared to how it was before, but let me know if that's just me. I swear this is the most unneeded change but I dig it, change my mind. --- logo_ascii.txt | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/logo_ascii.txt b/logo_ascii.txt index 54f308061..e1081e6ad 100644 --- a/logo_ascii.txt +++ b/logo_ascii.txt @@ -1,23 +1,26 @@ - - - ////// - *////////(( - ***////////(((((( - **////////(((((((( - /////((((((((# - //((((((((##% - ((((((((###& - (((((((####&& - ((((((((###%%% - ((((((((###%%%%% - /((((((((##%%%%%%% - //((((((((#%%%%%%%%% - ////((((((((%%%%%%%%%%%# - /////((((((( %%%%%####### - ///////((((( ############# - ////////(((( ############ - *////////((/ ############# - *////////( /########## - ///// ##### - - + ####### + ############# + ################# + ##################### + *###################### + #################### + ################## + ,,############### + ,,,,############# + ,,,,,,,########## + .///,,,,,,,######## + ..////////,,,,,##### + ....////////////,,,## + **....////////////////// + *****,...///////////////// + **********..///////////////// + ***************///////////////// + ***************** ///////////////// + **************** ///////////////// + **************** ///////////////// + **************** ///////////////// + **************** *///////////////// + *************** //////////////// + ************* ////////////// + ******** /////// + From edd8f35bc1f7aecd144c72c957fbc4e9904e7f2b Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Sun, 2 Oct 2022 22:53:26 -0400 Subject: [PATCH 14/85] Updated the Github issue templates (#396) * Updated the incompatibilty report form Updated it by adding more detailed questions, making it have better wording, and rewrote some sentences. This will make submitting a Incompatibility report easier, and assessing the report easier as well. * Updated the feature request template Improved the wording and grammar and overall made it easier for someone to fill out, and after the fact have someone analyze and accurately determine the request. * Updated the enchancment template It seems like this was copied right from the feature request template, so I improved both wording and grammar, and also edited the questions slightly to be more enchantment specific. * Enhanced the bug report template Just improved wording a little bit. --- .github/ISSUE_TEMPLATE/BUG_REPORT.md | 4 ++-- .github/ISSUE_TEMPLATE/ENHANCEMENT.md | 6 +++--- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 10 +++++----- .github/ISSUE_TEMPLATE/INCOMPATIBILITY_REPORT.md | 13 ++++++++----- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md index b0aae871f..3b53191fb 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -7,7 +7,7 @@ labels: bug, -module **Describe the bug** -**To Reproduce** +**Steps to reproduce the bug** 1. Go to '...' @@ -19,7 +19,7 @@ labels: bug, -module **Debug info** - + **Additional context / media** diff --git a/.github/ISSUE_TEMPLATE/ENHANCEMENT.md b/.github/ISSUE_TEMPLATE/ENHANCEMENT.md index 778b22115..d3d4edb2b 100644 --- a/.github/ISSUE_TEMPLATE/ENHANCEMENT.md +++ b/.github/ISSUE_TEMPLATE/ENHANCEMENT.md @@ -4,14 +4,14 @@ about: Suggest an idea for a feature labels: enhancement, -module --- -**Is your feature request related to a problem? Please describe.** +**Is your enhancement request related to a problem? Please describe.** -**Describe the solution you'd like** +**Describe the solution you'd like in order to enchance your experience.** **Describe alternatives you've considered** **Additional context** - + diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md index 57d88faaf..058f1602f 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -4,14 +4,14 @@ about: Suggest an idea for this project labels: new, -module --- -**Is your feature request related to a problem? Please describe.** +**Is your feature request related to a problem? Please elaborate.** -**Describe the solution you'd like** +**Describe the solution or feature you'd like implemented.** -**Describe alternatives you've considered** +**Describe alternatives you've considered.** -**Additional context** - +**Additional context:** + diff --git a/.github/ISSUE_TEMPLATE/INCOMPATIBILITY_REPORT.md b/.github/ISSUE_TEMPLATE/INCOMPATIBILITY_REPORT.md index 08705c19e..b775ee0b7 100644 --- a/.github/ISSUE_TEMPLATE/INCOMPATIBILITY_REPORT.md +++ b/.github/ISSUE_TEMPLATE/INCOMPATIBILITY_REPORT.md @@ -4,11 +4,14 @@ about: Module incompatibility or incompatible with another Forge mod labels: -incompatible --- -**What mod?** - +**What mod/module causes an issue?** + -**Logs** - +**What issue is caused?** + + +**Please attach your Minecraft logs** + **Additional context** - + From 60e26d24f78264ac23799862a0bba0b410761bb0 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 2 Oct 2022 20:05:33 -0700 Subject: [PATCH 15/85] Migrated to new UUID to name conversion API (#395) * fix uuid -> name from API * correct uri path --- .../kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt b/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt index 825feb079..cb6c13231 100644 --- a/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt +++ b/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt @@ -80,7 +80,7 @@ abstract class AbstractUUIDManager( try { val jsonElement = parser.parse(response) if (isUUID) { - val name = jsonElement.asJsonArray.last().asJsonObject["name"].asString + val name = jsonElement.asJsonObject["name"].asString PlayerProfile(UUID.fromString(nameOrUUID), name) } else { val id = jsonElement.asJsonObject["id"].asString @@ -95,7 +95,7 @@ abstract class AbstractUUIDManager( } private fun requestProfileFromUUID(uuid: String): String? { - return request("https://api.mojang.com/user/profiles/${UUIDUtils.removeDashes(uuid)}/names") + return request("https://sessionserver.mojang.com/session/minecraft/profile/${UUIDUtils.removeDashes(uuid)}") } private fun requestProfileFromName(name: String): String? { From 8c5d68b2b07e4a4537c58eeed59f0fed8b446254 Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 4 Oct 2022 00:59:08 +0200 Subject: [PATCH 16/85] Update Kotlin 1.7.10 -> 1.7.20 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 099a235fe..2499d264b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,5 +10,5 @@ forgeVersion=14.23.5.2860 mappingsChannel=stable mappingsVersion=39-1.12 -kotlinVersion=1.7.10 +kotlinVersion=1.7.20 kotlinxCoroutinesVersion=1.6.4 From b28c73905aadaeebfff4e237d9a1ed9f5ac94abe Mon Sep 17 00:00:00 2001 From: nickcat325 <80810636+nickcat325@users.noreply.github.com> Date: Mon, 3 Oct 2022 18:34:04 -0500 Subject: [PATCH 17/85] Update Baritone.kt (#391) Adds Water bucket clutch with Max bucket height --- .../com/lambda/client/module/modules/client/Baritone.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt index 5805b27bf..b4e5ea52a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt @@ -26,6 +26,8 @@ object Baritone : Module( private val allowPlace by setting("Allow Place", true) private val allowInventory by setting("Allow Inventory", false) private val freeLook by setting("Free Look", true) + private val allowWaterBucketFall by setting("Water bucket clutch", true, description = "Uses a water bucket to get down quickly.") + private val maxFallHeightBucket by setting("Max bucket height", 20, 5..255, 5, { allowWaterBucketFall }, description = "Max height that baritone can use a water bucket.") private val allowDownwardTunneling by setting("Downward Tunneling", true) private val allowParkour by setting("Allow Parkour", true) private val allowParkourPlace by setting("Allow Parkour Place", true) @@ -75,6 +77,8 @@ object Baritone : Module( it.allowPlace.value = allowPlace it.allowInventory.value = allowInventory it.freeLook.value = freeLook + it.allowWaterBucketFall.value = allowWaterBucketFall + it.maxFallHeightBucket.value = maxFallHeightBucket it.allowDownward.value = allowDownwardTunneling it.allowParkour.value = allowParkour it.allowParkourPlace.value = allowParkourPlace From 3fd22fe7a52b6df0bb9923def11b567acd871576 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 3 Oct 2022 16:34:22 -0700 Subject: [PATCH 18/85] HUD: Bindings Element (#383) * Bindings list HUD element (cherry picked from commit ccc4cade1b1d046c7fc9092daa866b4bed0f2901) * settings for text shadow and line v spacing * ignore client bindings setting * Changed to LabelHud sry but is way less code and same features Co-authored-by: Constructor --- .../gui/hudgui/elements/client/Bindings.kt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Bindings.kt diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Bindings.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Bindings.kt new file mode 100644 index 000000000..188752379 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Bindings.kt @@ -0,0 +1,55 @@ +package com.lambda.client.gui.hudgui.elements.client + +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.SafeClientEvent +import com.lambda.client.gui.hudgui.LabelHud +import com.lambda.client.module.AbstractModule +import com.lambda.client.module.ModuleManager +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.font.HAlign +import com.lambda.client.util.threads.safeAsyncListener +import net.minecraftforge.fml.common.gameevent.TickEvent + +internal object Bindings : LabelHud( + name = "Bindings", + category = Category.CLIENT, + description = "Display current module keybindings" +) { + + private val sortingMode by setting("Sorting Mode", SortingMode.LENGTH) + private val ignoreClientBindings by setting("Ignore Client Category", true, + description = "Ignore bindings for client specific bindings like the ClickGUI") + + @Suppress("UNUSED") + private enum class SortingMode( + override val displayName: String, + val comparator: Comparator + ) : DisplayEnum { + LENGTH("Length", compareByDescending { it.name.length }), + ALPHABET("Alphabet", compareBy { it.name }), + CATEGORY("Category", compareBy { it.category.ordinal }) + } + + private var modulesWithBindings: List = emptyList() + + init { + dockingH = HAlign.RIGHT + + safeAsyncListener { event -> + if (event.phase != TickEvent.Phase.END) return@safeAsyncListener + + // this isn't terribly efficient, consider creating events for editing bindings and module toggle state + modulesWithBindings = ModuleManager.modules + .sortedWith(sortingMode.comparator) + .filter { if (ignoreClientBindings) it.category != com.lambda.client.module.Category.CLIENT else true } + .filterNot { it.bind.value.isEmpty } + } + } + + override fun SafeClientEvent.updateText() { + modulesWithBindings.forEach { + displayText.add(it.name, if (it.isEnabled) ColorHolder(0, 255, 0) else primaryColor) + displayText.addLine(it.bind.toString(), secondaryColor) + } + } +} \ No newline at end of file From aa7febdf5d1f6f357e923e8ed602bf6eba37220b Mon Sep 17 00:00:00 2001 From: 3arthqu4ke <56741599+3arthqu4ke@users.noreply.github.com> Date: Tue, 4 Oct 2022 01:45:19 +0200 Subject: [PATCH 19/85] Removed Firework Mixin hack (#384) --- .../EntityLivingBaseFireworkHelper.java | 33 ++++++++++++++ .../mixin/entity/MixinEntityLivingBase.java | 45 +++---------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java diff --git a/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java b/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java new file mode 100644 index 000000000..21112abde --- /dev/null +++ b/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java @@ -0,0 +1,33 @@ +package com.lambda; + +import com.lambda.client.module.modules.movement.ElytraFlight; +import com.lambda.mixin.accessor.AccessorEntityFireworkRocket; +import com.lambda.mixin.entity.MixinEntityLivingBase; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.entity.EntityLivingBase; + +/** + * Using {@link AccessorEntityFireworkRocket} in {@link MixinEntityLivingBase} causes a crash on older + * Mixin versions (like the one Impact uses). Putting the methods using AccessorEntityFireworkRocket outside + * the MixinEntityLivingBase seems to fix the issue. + */ +public class EntityLivingBaseFireworkHelper { + public static boolean shouldWork(EntityLivingBase entity) { + return EntityPlayerSP.class.isAssignableFrom(entity.getClass()) + && ElytraFlight.INSTANCE.isEnabled() + && ElytraFlight.INSTANCE.getMode().getValue() == ElytraFlight.ElytraFlightMode.VANILLA; + } + + public static boolean shouldModify(EntityLivingBase entity) { + return shouldWork(entity) && entity.world.loadedEntityList.stream().anyMatch(firework -> { + if (firework instanceof AccessorEntityFireworkRocket) { + EntityLivingBase boosted = ((AccessorEntityFireworkRocket) firework).getBoostedEntity(); + return boosted != null && boosted.equals(entity); + } + + return false; + } + ); + } + +} diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java b/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java index 8d5386504..285031014 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java @@ -1,14 +1,12 @@ package com.lambda.mixin.entity; +import com.lambda.EntityLivingBaseFireworkHelper; import com.lambda.client.module.modules.movement.ElytraFlight; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -19,19 +17,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.lang.reflect.Field; - @Mixin(EntityLivingBase.class) public abstract class MixinEntityLivingBase extends Entity { @Unique private Vec3d modifiedVec = null; - // This is a bit silly and bad for performance but fixes compatibility with old mixin versions like the one used by impact - @Unique - private static final Field boostedEntity; - - static { - boostedEntity = ObfuscationReflectionHelper.findField(EntityFireworkRocket.class, "field_191513_e"); - } public MixinEntityLivingBase(World worldIn) { super(worldIn); @@ -42,7 +31,7 @@ public MixinEntityLivingBase(World worldIn) { at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/EntityLivingBase;getLookVec()Lnet/minecraft/util/math/Vec3d;", ordinal = 0) ) private Vec3d vec3d(Vec3d original) { - if (shouldWork()) { + if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) { float negPacketPitch = -ElytraFlight.INSTANCE.getPacketPitch(); float f0 = MathHelper.cos((float) (-this.rotationYaw * 0.017453292f - Math.PI)); float f1 = MathHelper.sin((float) (-this.rotationYaw * 0.017453292f - Math.PI)); @@ -60,7 +49,7 @@ private Vec3d vec3d(Vec3d original) { ordinal = 3 ) private float f(float original) { - if (shouldWork()) { + if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) { return ElytraFlight.INSTANCE.getPacketPitch() * 0.017453292f; } return original; @@ -87,7 +76,7 @@ private void getVec( at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionX:D", ordinal = 7) ) public double motionX(EntityLivingBase it) { - if (shouldModify()) { + if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { it.motionX += modifiedVec.x * 0.1 + (modifiedVec.x * 1.5 - this.motionX) * 0.5; } return it.motionX; @@ -98,7 +87,7 @@ public double motionX(EntityLivingBase it) { at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionY:D", ordinal = 7) ) public double motionY(EntityLivingBase it) { - if (shouldModify()) { + if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { it.motionY += modifiedVec.y * 0.1 + (modifiedVec.y * 1.5 - this.motionY) * 0.5; } return it.motionY; @@ -109,32 +98,10 @@ public double motionY(EntityLivingBase it) { at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionZ:D", ordinal = 7) ) public double motionZ(EntityLivingBase it) { - if (shouldModify()) { + if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { it.motionZ += modifiedVec.z * 0.1 + (modifiedVec.z * 1.5 - this.motionZ) * 0.5; } return it.motionZ; } - @Unique - private boolean shouldWork() { - return EntityPlayerSP.class.isAssignableFrom(getClass()) - && ElytraFlight.INSTANCE.isEnabled() - && ElytraFlight.INSTANCE.getMode().getValue() == ElytraFlight.ElytraFlightMode.VANILLA; - } - - @Unique - private boolean shouldModify() { - return shouldWork() && world.loadedEntityList.stream().anyMatch(entity -> { - if (entity instanceof EntityFireworkRocket) { - try { - EntityLivingBase boosted = (EntityLivingBase) boostedEntity.get(entity); - return boosted != null && boosted.equals(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); // This should absolutely never happen - } - } - return false; - } - ); - } } From 804f5f0cee73a1a4532843a3aadd95caed87e50f Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 4 Oct 2022 02:50:43 +0200 Subject: [PATCH 20/85] Sketch --- .../module/modules/player/ScaffoldRewrite.kt | 88 +++++++++++++++++++ .../com/lambda/client/util/world/Interact.kt | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt new file mode 100644 index 000000000..e314baeaf --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt @@ -0,0 +1,88 @@ +package com.lambda.client.module.modules.player + +import com.lambda.client.LambdaMod +import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.manager.managers.HotbarManager.serverSideItem +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.ESPRenderer +import com.lambda.client.util.threads.safeListener +import com.lambda.client.util.world.* +import net.minecraft.block.BlockBarrier +import net.minecraft.block.state.IBlockState +import net.minecraft.init.Blocks +import net.minecraft.item.ItemBlock +import net.minecraft.util.EnumHand +import net.minecraft.util.SoundCategory +import net.minecraft.util.math.BlockPos + +object ScaffoldRewrite : Module( + name = "ScaffoldRewrite", + description = "Places blocks under you", + category = Category.PLAYER, + modulePriority = 500 +) { + private val page by setting("Page", Page.SETTINGS) + + private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") + private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") + private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") + private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") + private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") + + private enum class Page { + SETTINGS, RENDER + } + + val renderer by lazy { ESPRenderer() } + +// var currentStructure: Set = emptySet() + var baseBlock: BlockPos = BlockPos.ORIGIN + + init { + safeListener { + val basePos = player.flooredPosition.down() + + if (world.isPlaceable(basePos)) { +// LambdaMod.LOG.error(player.position.down()) + val placeSequence = getNeighbourSequence(basePos, 1, visibleSideCheck = true) + + if (placeSequence.isNotEmpty()) { + placeSequence.firstOrNull()?.let { + world.setBlockState(basePos, Blocks.BARRIER.defaultState) + + connection.sendPacket(it.toPlacePacket(EnumHand.MAIN_HAND)) + player.swingArm(EnumHand.MAIN_HAND) + + val itemStack = player.serverSideItem + val block = (itemStack.item as? ItemBlock?)?.block ?: return@safeListener + val metaData = itemStack.metadata + val blockState = block.getStateForPlacement(world, it.pos, it.side, it.hitVecOffset.x.toFloat(), it.hitVecOffset.y.toFloat(), it.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) + val soundType = blockState.block.getSoundType(blockState, world, it.pos, player) + world.playSound(player, it.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) + } + } + +// if (baseBlock != basePos) { +// +// } + baseBlock = basePos +// world.setBlockState(basePos, Blocks.BARRIER.defaultState) + } + } + + safeListener { + renderer.aFilled = if (filled) alphaFilled else 0 + renderer.aOutline = if (outline) alphaOutline else 0 + renderer.thickness = thickness + + renderer.add(baseBlock, ColorHolder(0, 255, 0)) + + renderer.render(clear = true) + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index 30d10fe41..c919c46e8 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -285,5 +285,5 @@ fun SafeClientEvent.placeBlock( world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) } -private fun PlaceInfo.toPlacePacket(hand: EnumHand) = +fun PlaceInfo.toPlacePacket(hand: EnumHand) = CPacketPlayerTryUseItemOnBlock(this.pos, this.side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file From 205865d25d449e90e8219d984feae655322a5446 Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 4 Oct 2022 02:50:43 +0200 Subject: [PATCH 21/85] Revert "Sketch" This reverts commit 804f5f0cee73a1a4532843a3aadd95caed87e50f. --- .../module/modules/player/ScaffoldRewrite.kt | 88 ------------------- .../com/lambda/client/util/world/Interact.kt | 2 +- 2 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt deleted file mode 100644 index e314baeaf..000000000 --- a/src/main/kotlin/com/lambda/client/module/modules/player/ScaffoldRewrite.kt +++ /dev/null @@ -1,88 +0,0 @@ -package com.lambda.client.module.modules.player - -import com.lambda.client.LambdaMod -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.event.events.RenderWorldEvent -import com.lambda.client.manager.managers.HotbarManager.serverSideItem -import com.lambda.client.module.Category -import com.lambda.client.module.Module -import com.lambda.client.util.EntityUtils.flooredPosition -import com.lambda.client.util.color.ColorHolder -import com.lambda.client.util.graphics.ESPRenderer -import com.lambda.client.util.threads.safeListener -import com.lambda.client.util.world.* -import net.minecraft.block.BlockBarrier -import net.minecraft.block.state.IBlockState -import net.minecraft.init.Blocks -import net.minecraft.item.ItemBlock -import net.minecraft.util.EnumHand -import net.minecraft.util.SoundCategory -import net.minecraft.util.math.BlockPos - -object ScaffoldRewrite : Module( - name = "ScaffoldRewrite", - description = "Places blocks under you", - category = Category.PLAYER, - modulePriority = 500 -) { - private val page by setting("Page", Page.SETTINGS) - - private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") - private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") - private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") - private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") - private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") - - private enum class Page { - SETTINGS, RENDER - } - - val renderer by lazy { ESPRenderer() } - -// var currentStructure: Set = emptySet() - var baseBlock: BlockPos = BlockPos.ORIGIN - - init { - safeListener { - val basePos = player.flooredPosition.down() - - if (world.isPlaceable(basePos)) { -// LambdaMod.LOG.error(player.position.down()) - val placeSequence = getNeighbourSequence(basePos, 1, visibleSideCheck = true) - - if (placeSequence.isNotEmpty()) { - placeSequence.firstOrNull()?.let { - world.setBlockState(basePos, Blocks.BARRIER.defaultState) - - connection.sendPacket(it.toPlacePacket(EnumHand.MAIN_HAND)) - player.swingArm(EnumHand.MAIN_HAND) - - val itemStack = player.serverSideItem - val block = (itemStack.item as? ItemBlock?)?.block ?: return@safeListener - val metaData = itemStack.metadata - val blockState = block.getStateForPlacement(world, it.pos, it.side, it.hitVecOffset.x.toFloat(), it.hitVecOffset.y.toFloat(), it.hitVecOffset.z.toFloat(), metaData, player, EnumHand.MAIN_HAND) - val soundType = blockState.block.getSoundType(blockState, world, it.pos, player) - world.playSound(player, it.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) - } - } - -// if (baseBlock != basePos) { -// -// } - baseBlock = basePos -// world.setBlockState(basePos, Blocks.BARRIER.defaultState) - } - } - - safeListener { - renderer.aFilled = if (filled) alphaFilled else 0 - renderer.aOutline = if (outline) alphaOutline else 0 - renderer.thickness = thickness - - renderer.add(baseBlock, ColorHolder(0, 255, 0)) - - renderer.render(clear = true) - } - } - -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index c919c46e8..30d10fe41 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -285,5 +285,5 @@ fun SafeClientEvent.placeBlock( world.playSound(player, placeInfo.pos, soundType.placeSound, SoundCategory.BLOCKS, (soundType.getVolume() + 1.0f) / 2.0f, soundType.getPitch() * 0.8f) } -fun PlaceInfo.toPlacePacket(hand: EnumHand) = +private fun PlaceInfo.toPlacePacket(hand: EnumHand) = CPacketPlayerTryUseItemOnBlock(this.pos, this.side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file From 0ca4d83e72a6e6c143fbaa1a35cb08b5b2963fab Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Mon, 10 Oct 2022 12:58:51 -0400 Subject: [PATCH 22/85] Changed delay setting from seconds to ms, should be nicer. --- .../com/lambda/client/module/modules/misc/DiscordRPC.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt index e1f1faf68..70e349110 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt @@ -35,7 +35,7 @@ object DiscordRPC : Module( private val line2Left by setting("Line 2 Left", LineInfo.DIMENSION) // state left private val line2Right by setting("Line 2 Right", LineInfo.HEALTH) // state right private val coordsConfirm by setting("Coords Confirm", false, { showCoordsConfirm() }) - private val delay by setting("Update Delay", 5, 1..60, 1, unit = " s") + private val delay by setting("Update Delay", 200, 200..2000, 1, unit = "ms") private enum class LineInfo { VERSION, WORLD, DIMENSION, USERNAME, HEALTH, HUNGER, SERVER_IP, COORDS, SPEED, HELD_ITEM, FPS, TPS, NONE @@ -46,8 +46,8 @@ object DiscordRPC : Module( private var initialised = false private val rpcBuilder = RichPresence.Builder() .setLargeImage("default", "https://github.com/lambda-client/lambda/") - private val timer = TickTimer(TimeUnit.SECONDS) - private val job = BackgroundJob("Discord RPC", { delay * 1000L }) { updateRPC() } + private val timer = TickTimer(TimeUnit.MILLISECONDS) + private val job = BackgroundJob("Discord RPC", { delay * 200L }) { updateRPC() } init { onEnable { From 138d339151c9bf8151e2de0f9eaa71fe8ab45351 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sat, 29 Oct 2022 00:16:28 +0200 Subject: [PATCH 23/85] Easier discord join --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4c7594c4a..514c2f6b4 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ Find our plugins [here](https://github.com/lambda-plugins). lambda-3.2.1.jar

+
+ Link to the lambda discord server https://discord.gg/QjfBxJzE5x +
+ ## Installation 1. Install Minecraft 1.12.2 2. Install the latest Forge for 1.12.2 [(download)](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.12.2.html) From 7d37d7517ae9d6cc4441fb48f5b0ff321dcbee77 Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Sun, 30 Oct 2022 00:25:22 +0100 Subject: [PATCH 24/85] Add 85km/h YPort mode to Speed (#288) * Add Boost to Speed, settings edited on other modes to be better compliant with NCP * Fix Boost speed, now fully functional * Fix formatting * Other fixes * Removed Boost mode and added YPort mode (disabling accelerate is the same as old boost mode) * Add some settings, these are in the video * YPort update No32767 Added maximum speed slider Added Air Strict mode to emulate Y motion better Inflicted pain on Doogie13 * Fixed YPort AirStrict to make it calculate motion properly this time Removed debug messages * Clean up * Clean up 2 * Another cleanup * Added working 42 km/h overhead strafe for 2b Co-authored-by: Constructor --- .../client/module/modules/combat/HoleSnap.kt | 2 +- .../client/module/modules/combat/Surround.kt | 2 +- .../client/module/modules/movement/Speed.kt | 260 +++++++++++++----- 3 files changed, 197 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt index cdb4023f3..f590ca671 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt @@ -94,7 +94,7 @@ object HoleSnap : Module( } getHole()?.let { - if (disableStrafe && Speed.mode == Speed.SpeedMode.STRAFE) Speed.disable() + if (disableStrafe && Speed.mode.value == Speed.SpeedMode.STRAFE) Speed.disable() if ((airStrafe || player.onGround) && !player.isCentered(it)) { val playerPos = player.positionVector val targetPos = Vec3d(it.x + 0.5, player.posY, it.z + 0.5) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt index 34ffedfba..f8dde7012 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/Surround.kt @@ -101,7 +101,7 @@ object Surround : Module( // Centered check if (!player.centerPlayer()) return@safeListener - if (disableStrafe && Speed.mode == Speed.SpeedMode.STRAFE) { + if (disableStrafe && Speed.mode.value == Speed.SpeedMode.STRAFE) { Speed.disable() } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt index 3d69c7884..83dfb26c5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Speed.kt @@ -1,21 +1,21 @@ package com.lambda.client.module.modules.movement +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.SafeClientEvent +import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.mixin.extension.isInWeb +import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.player.AutoEat import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.MovementUtils import com.lambda.client.util.MovementUtils.applySpeedPotionEffects import com.lambda.client.util.MovementUtils.calcMoveYaw -import com.lambda.client.util.MovementUtils.isMoving import com.lambda.client.util.MovementUtils.setSpeed import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer @@ -23,11 +23,16 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.settings.KeyBinding +import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraftforge.fml.common.gameevent.TickEvent import java.lang.Double.max +import java.lang.Double.min import kotlin.math.cos +import kotlin.math.hypot import kotlin.math.sin + object Speed : Module( name = "Speed", description = "Move faster", @@ -35,65 +40,84 @@ object Speed : Module( modulePriority = 100 ) { // General settings - val mode by setting("Mode", SpeedMode.STRAFE) - - // strafe settings - private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.029f, 0.01f..0.04f, 0.001f, { mode == SpeedMode.STRAFE }) - private val strafeTimerBoost by setting("Timer Boost", true, { mode == SpeedMode.STRAFE }) - private val strafeAutoJump by setting("Auto Jump", true, { mode == SpeedMode.STRAFE }) - private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode == SpeedMode.STRAFE }) - private val strafeCancelInertia by setting("Cancel Inertia", false, { mode == SpeedMode.STRAFE }) - - // onGround settings - private val onGroundTimer by setting("Timer", true, { mode == SpeedMode.ONGROUND }) - private val onGroundTimerSpeed by setting("Timer Speed", 1.29f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND && onGroundTimer }) - private val onGroundSpeed by setting("Speed", 1.31f, 1.0f..2.0f, 0.01f, { mode == SpeedMode.ONGROUND }) - private val onGroundSprint by setting("Sprint", true, { mode == SpeedMode.ONGROUND }) - private val onGroundCheckAbove by setting("Smart Mode", true, { mode == SpeedMode.ONGROUND }) + val mode = setting("Mode", SpeedMode.STRAFE) + + // Strafe settings + private val strafeAirSpeedBoost by setting("Air Speed Boost", 0.028f, 0.01f..0.04f, 0.001f, { mode.value == SpeedMode.STRAFE }) + private val strafeTimerBoost by setting("Timer Boost", true, { mode.value == SpeedMode.STRAFE }) + private val strafeAutoJump by setting("Auto Jump", true, { mode.value == SpeedMode.STRAFE }, description = "WARNING: Food intensive!") + private val strafeOnlyOverhead by setting("Only strafe on overhead", false, { mode.value == SpeedMode.STRAFE && strafeAutoJump }) + private val strafeOnHoldingSprint by setting("On Holding Sprint", false, { mode.value == SpeedMode.STRAFE }) + private val strafeCancelInertia by setting("Cancel Inertia", false, { mode.value == SpeedMode.STRAFE }) + + // YPort settings + private val yPortAccelerate by setting("Accelerate", true, { mode.value == SpeedMode.YPORT }) + private val yPortStrict by setting("Head Strict", false, { mode.value == SpeedMode.YPORT }, description = "Only allow YPort when you are under a block") + private val yPortAirStrict by setting("Air Strict", false, { mode.value == SpeedMode.YPORT }, description = "Force YPort to handle Y movement differently, slows this down A LOT") + private val yPortMaxSpeed by setting("Maximum Speed", 0.0, 0.0..2.0, 0.001, { mode.value == SpeedMode.YPORT }) + private val yPortAcceleration by setting("Acceleration Speed", 2.149, 1.0..5.0, 0.001, { mode.value == SpeedMode.YPORT }) + private val yPortDecay by setting("Decay Amount", 0.66, 0.0..1.0, 0.001, { mode.value == SpeedMode.YPORT }) + + private const val TIMER_SPEED = 45.955883f // Strafe Mode private var jumpTicks = 0 private val strafeTimer = TickTimer(TimeUnit.TICKS) - // onGround Mode - private var wasSprintEnabled = Sprint.isEnabled + // yport stuff + private var currentSpeed = .2873 + private var currentY = 0.0 + private var phase: YPortPhase = YPortPhase.WALKING + private var prevPhase: YPortPhase = YPortPhase.WALKING + private var goUp = false + private var lastDistance = 0.0 - private var currentMode = mode + private enum class YPortPhase { + // to help with bypassing right after setback + WAITING, + // to get some speed initially + WALKING, + // to jump and accelerate + ACCELERATING, + // to fall to the ground + SLOWDOWN, + // to slowly fall to the ground + FALLING + } - enum class SpeedMode { - STRAFE, ONGROUND + enum class SpeedMode(override val displayName: String) : DisplayEnum { + STRAFE("Strafe"), + YPORT("YPort") } init { onEnable { - wasSprintEnabled = Sprint.isEnabled + currentSpeed = .2873 + phase = YPortPhase.WALKING + prevPhase = YPortPhase.WALKING + goUp = false + currentY = 0.0 } onDisable { - if (!wasSprintEnabled && mode == SpeedMode.ONGROUND) Sprint.disable() runSafe { reset() } } safeListener { - if (mode != currentMode) { - currentMode = mode - reset() - } - - if (mode == SpeedMode.ONGROUND && Sprint.isDisabled && onGroundSprint) Sprint.enable() - } - - safeListener { - if (mode == SpeedMode.STRAFE && shouldStrafe()) strafe() + lastDistance = hypot(player.posX - player.prevPosX, player.posZ - player.prevPosZ) + if (mode.value == SpeedMode.STRAFE + && shouldStrafe() + ) strafe() } safeListener { - when (mode) { + when (mode.value) { SpeedMode.STRAFE -> { - if (shouldStrafe()) setSpeed(max(player.speed, applySpeedPotionEffects(0.2873))) - else { + if (shouldStrafe()) { + setSpeed(max(player.speed, applySpeedPotionEffects(0.2873))) + } else { reset() if (strafeCancelInertia && !strafeTimer.tick(2L, false)) { player.motionX = 0.0 @@ -101,50 +125,83 @@ object Speed : Module( } } } - SpeedMode.ONGROUND -> { - if (shouldOnGround()) onGround() - else resetTimer() + + SpeedMode.YPORT -> { + handleBoost(it) + } + } + } + + safeListener { + if (mode.value != SpeedMode.YPORT + || it.packet !is CPacketPlayer + || !goUp + ) return@safeListener + + var offset = .42 + + //.015625 is the largest number that block heights are always divisible + while (world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0, offset, .0))) { + if (offset <= 0) + break + + offset -= .015625 + } + + val unModOffset = offset + + if (currentY + unModOffset > 0) + offset += currentY + else if (yPortAirStrict && phase == YPortPhase.FALLING && prevPhase == YPortPhase.FALLING) { + + var predictedY = currentY + predictedY -= 0.08 + predictedY *= 0.9800000190734863 // 0.333200006 vs 0.341599999 + + if (predictedY + player.posY <= player.posY) { + phase = YPortPhase.WAITING } } + + it.packet.playerY = (offset + player.posY) + + currentY = offset - unModOffset + } + + safeListener { + if (mode.value != SpeedMode.YPORT || it.packet !is SPacketPlayerPosLook) return@safeListener + + currentSpeed = 0.0 + currentY = 0.0 + goUp = false + // 3 extra ticks at base speed + phase = YPortPhase.WAITING + } + + mode.listeners.add { + runSafe { reset() } } } private fun SafeClientEvent.strafe() { player.jumpMovementFactor = strafeAirSpeedBoost - if (strafeTimerBoost) modifyTimer(45.87156f) - if ((Step.isDisabled || !player.collidedHorizontally) && strafeAutoJump) jump() + // slightly slower timer speed bypasses better (1.088) + if (strafeTimerBoost) modifyTimer(TIMER_SPEED) - strafeTimer.reset() - } + if ((Step.isDisabled || player.onGround) && strafeAutoJump) jump() - private fun SafeClientEvent.onGround() { - if (onGroundTimer) modifyTimer(50.0f / onGroundTimerSpeed) - else resetTimer() - - player.motionX *= onGroundSpeed - player.motionZ *= onGroundSpeed + strafeTimer.reset() } private fun SafeClientEvent.shouldStrafe(): Boolean = - (!player.capabilities.isFlying + !player.capabilities.isFlying && !player.isElytraFlying && !mc.gameSettings.keyBindSneak.isKeyDown && (!strafeOnHoldingSprint || mc.gameSettings.keyBindSprint.isKeyDown) && !BaritoneUtils.isPathing && MovementUtils.isInputting - && !(player.isInOrAboveLiquid || player.isInWeb)) - - private fun SafeClientEvent.shouldOnGround(): Boolean = - (world.getBlockState(player.flooredPosition.add(0.0, 2.0, 0.0)).material.isSolid || !onGroundCheckAbove) - && !AutoEat.eating - && player.isMoving - && MovementUtils.isInputting - && !player.movementInput.sneak - && player.onGround && !(player.isInOrAboveLiquid || player.isInWeb) - && !player.capabilities.isFlying - && !player.isElytraFlying - && !mc.gameSettings.keyBindSneak.isKeyDown + && (!strafeOnlyOverhead || world.collidesWithAnyBlock(player.entityBoundingBox.offset(.0,.42,.0))) private fun SafeClientEvent.reset() { player.jumpMovementFactor = 0.02f @@ -168,4 +225,77 @@ object Speed : Module( jumpTicks-- } -} \ No newline at end of file + + private fun SafeClientEvent.handleBoost(event: PlayerMoveEvent) { + if (player.movementInput.moveForward == 0f && player.movementInput.moveStrafe == 0f + || player.isInOrAboveLiquid + || mc.gameSettings.keyBindJump.isKeyDown + || !player.onGround + || !world.collidesWithAnyBlock(player.entityBoundingBox.offset(0.0, 0.42, 0.0)) && yPortStrict + ) { + resetTimer() + currentSpeed = .2873 + return + } + + modifyTimer(TIMER_SPEED) + + prevPhase = phase + + when (phase) { + YPortPhase.ACCELERATING -> { + // NCP says hDistance < 2.15 * hDistanceBaseRef + currentSpeed *= yPortAcceleration + phase = if (yPortAirStrict) YPortPhase.FALLING else YPortPhase.SLOWDOWN + goUp = true + currentY = 0.0 + } + + YPortPhase.SLOWDOWN -> { + // NCP says hDistDiff >= 0.66 * (lastMove.hDistance - hDistanceBaseRef) + currentSpeed = if (yPortAccelerate) { + lastDistance - yPortDecay * (lastDistance - .2873) + } else { + .2873 + } + phase = YPortPhase.ACCELERATING + goUp = false + } + + YPortPhase.FALLING -> { + if (prevPhase == YPortPhase.WALKING) { + currentSpeed = if (yPortAccelerate) { + lastDistance - yPortDecay * (lastDistance - .2873) + } else { + .2873 + } + } + + goUp = true + + currentSpeed -= currentSpeed / 159 + + currentY -= 0.08 + currentY *= 0.9800000190734863 + } + + else -> { + currentSpeed = max(currentSpeed, .2873) + phase = YPortPhase.values()[phase.ordinal + 1 % YPortPhase.values().size] + goUp = false + } + } + + val yaw = calcMoveYaw() + + if (yPortMaxSpeed != 0.0) { + currentSpeed = currentSpeed.coerceAtMost(yPortMaxSpeed) + } + + event.x = -sin(yaw) * currentSpeed + event.y = min(0.0, event.y) + event.z = cos(yaw) * currentSpeed + + player.setVelocity(event.x, event.y, event.z) + } +} From c52481de748c55917186d9bc5a94e82ed2ae6d32 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 30 Oct 2022 03:29:45 +0100 Subject: [PATCH 25/85] Added packet info HUD element --- .../client/gui/hudgui/elements/misc/FPS.kt | 25 ++++------ .../gui/hudgui/elements/misc/Packets.kt | 48 +++++++++++++++++++ .../client/manager/managers/PacketManager.kt | 28 ++++++++++- 3 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Packets.kt diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/FPS.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/FPS.kt index 2def3fb85..6d51cd89b 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/FPS.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/FPS.kt @@ -4,8 +4,6 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.CircularArray import com.lambda.client.util.graphics.AnimationUtils -import kotlin.math.max -import kotlin.math.min import kotlin.math.roundToInt internal object FPS : LabelHud( @@ -14,9 +12,9 @@ internal object FPS : LabelHud( description = "Frames per second in game" ) { - private val showAverage = setting("Show Average", true) - private val showMin = setting("Show Min", false) - private val showMax = setting("Show Max", false) + private val showAverage by setting("Show Average", true) + private val showMin by setting("Show Min", false) + private val showMax by setting("Show Max", false) private var updateTime = 0L private var prevFps = 0 @@ -44,29 +42,22 @@ internal object FPS : LabelHud( val fps = (prevFps + (currentFps - prevFps) * deltaTime).roundToInt() val avg = (prevAvgFps + (currentAvgFps - prevAvgFps) * deltaTime).roundToInt() - var min = 6969 - var max = 0 - for (value in longFps) { - if (value != 0) min = min(value, min) - max = max(value, max) - } - displayText.add("FPS", secondaryColor) displayText.add(fps.toString(), primaryColor) - if (showAverage.value) { + if (showAverage) { displayText.add("AVG", secondaryColor) displayText.add(avg.toString(), primaryColor) } - if (showMin.value) { + if (showMin) { displayText.add("MIN", secondaryColor) - displayText.add(min.toString(), primaryColor) + displayText.add(longFps.min().toString(), primaryColor) } - if (showMax.value) { + if (showMax) { displayText.add("MAX", secondaryColor) - displayText.add(max.toString(), primaryColor) + displayText.add(longFps.max().toString(), primaryColor) } } diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Packets.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Packets.kt new file mode 100644 index 000000000..d606b4381 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Packets.kt @@ -0,0 +1,48 @@ +package com.lambda.client.gui.hudgui.elements.misc + +import com.lambda.client.event.SafeClientEvent +import com.lambda.client.gui.hudgui.LabelHud +import com.lambda.client.manager.managers.PacketManager + +internal object Packets : LabelHud( + name = "Packets", + category = Category.MISC, + description = "Information about your packet traffic." +) { + private val perSecond by setting("Per second", true) + private val total by setting("Total", true) + private val lastSent by setting("Last sent packet info", true) + private val lastReceived by setting("Last received packet info", true) + + override fun SafeClientEvent.updateText() { + if (perSecond) { + displayText.add("Sent/s", secondaryColor) + displayText.add(PacketManager.recentSent.count().toString(), primaryColor) + displayText.add("Received/s", secondaryColor) + displayText.addLine(PacketManager.recentReceived.count().toString(), primaryColor) + } + + if (total) { + displayText.add("Total sent", secondaryColor) + displayText.add(PacketManager.totalSent.toString(), primaryColor) + displayText.add("Total received", secondaryColor) + displayText.addLine(PacketManager.totalReceived.toString(), primaryColor) + } + + if (lastSent) { + PacketManager.recentSent.lastOrNull()?.let { + displayText.add("Last sent", secondaryColor) + displayText.add(it.first.javaClass.simpleName ?: "None", primaryColor) + displayText.addLine("${System.currentTimeMillis() - it.second}ms", primaryColor) + } + } + + if (lastReceived) { + PacketManager.recentReceived.lastOrNull()?.let { + displayText.add("Last received", secondaryColor) + displayText.add(it.first.javaClass.simpleName ?: "None", primaryColor) + displayText.addLine("${System.currentTimeMillis() - it.second}ms", primaryColor) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/manager/managers/PacketManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/PacketManager.kt index 7e9ed03ba..c631ede24 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/PacketManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/PacketManager.kt @@ -5,13 +5,32 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.util.threads.safeListener +import net.minecraft.network.Packet import net.minecraft.network.play.server.SPacketPlayerPosLook +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.concurrent.ConcurrentLinkedDeque object PacketManager : Manager { + private const val maxAge = 1000L + + val recentReceived = ConcurrentLinkedDeque,Long>>() + var totalReceived = 0 + + val recentSent = ConcurrentLinkedDeque,Long>>() + var totalSent = 0 + var lastTeleportId = -1 init { - listener { + listener { + recentSent.add(Pair(it.packet, System.currentTimeMillis())) + totalSent++ + } + + listener { + recentReceived.add(Pair(it.packet, System.currentTimeMillis())) + totalReceived++ + when (it.packet) { is SPacketPlayerPosLook -> { lastTeleportId = it.packet.teleportId @@ -22,5 +41,12 @@ object PacketManager : Manager { safeListener { lastTeleportId = -1 } + + safeListener { + val currentTime = System.currentTimeMillis() + + recentReceived.removeIf { currentTime - it.second > maxAge } + recentSent.removeIf { currentTime - it.second > maxAge } + } } } \ No newline at end of file From 827ef82aed3adf2e9f815e8438fedca99a8c4fe1 Mon Sep 17 00:00:00 2001 From: Constructor Date: Fri, 4 Nov 2022 02:44:28 +0100 Subject: [PATCH 26/85] Added feature to change MenuShader in main menu (#411) --- .../lambda/mixin/gui/MixinGuiMainMenu.java | 59 +++++++++++++++---- .../lambda/client/commons/extension/Enum.kt | 4 ++ .../module/modules/client/MenuShader.kt | 28 ++++++--- 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiMainMenu.java b/src/main/java/com/lambda/mixin/gui/MixinGuiMainMenu.java index a357edfca..045116257 100644 --- a/src/main/java/com/lambda/mixin/gui/MixinGuiMainMenu.java +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiMainMenu.java @@ -19,8 +19,10 @@ @Mixin(GuiMainMenu.class) public abstract class MixinGuiMainMenu extends GuiScreen { - private int widthVersion; - private int widthVersionRest; + private int widthWatermark; + private int widthWatermarkRest; + private int widthUpdate; + private int widthUpdateRest; @Inject(method = "initGui", at = @At("RETURN")) public void initGui$Inject$RETURN(CallbackInfo ci) { @@ -33,29 +35,52 @@ public abstract class MixinGuiMainMenu extends GuiScreen { KamiCheck.INSTANCE.setDidDisplayWarning(true); mc.displayGuiScreen(new LambdaGuiIncompat()); } + + // Version FontRenderer fr = fontRenderer; - String slogan = TextFormatting.WHITE + LambdaMod.NAME + " " + TextFormatting.GRAY + LambdaMod.VERSION; - String version; + String watermark = TextFormatting.WHITE + LambdaMod.NAME + " " + TextFormatting.GRAY + LambdaMod.VERSION; + String update; + if (WebUtils.INSTANCE.isLatestVersion()) { - version = ""; + update = ""; } else { - version = TextFormatting.DARK_RED + " Update Available! (" + WebUtils.INSTANCE.getLatestVersion() + ")"; + update = TextFormatting.DARK_RED + " Update Available! (" + WebUtils.INSTANCE.getLatestVersion() + ")"; + } + + String combined = watermark + update; + drawString(fr, combined, width - fr.getStringWidth(combined) - 2, height - 20, -1); + + widthWatermark = fr.getStringWidth(watermark); + widthWatermarkRest = width - widthWatermark - 2; + widthUpdate = fr.getStringWidth(update); + widthUpdateRest = width - widthUpdate - 2; + + if (isInside(mouseX, mouseY, widthUpdate, widthUpdateRest)) { + drawRect(widthUpdateRest, height - 11, widthUpdate + widthUpdateRest, height - 10, -1); } - String combined = slogan + version; - drawString(fr, combined, width - fr.getStringWidth(combined) - 2, this.height - 20, -1); - widthVersion = fr.getStringWidth(version); - widthVersionRest = width - widthVersion - 2; - if (mouseX > widthVersionRest && mouseX < widthVersionRest + widthVersion && mouseY > height - 20 && mouseY < height - 10 && Mouse.isInsideWindow()) { - drawRect(widthVersionRest, height - 11, widthVersion + widthVersionRest, height - 10, -1); + if (isInside(mouseX, mouseY, widthWatermark, widthWatermarkRest)) { + drawRect(widthWatermarkRest, height - 11, widthWatermark + widthWatermarkRest, height - 10, -1); } + } @Inject(method = "mouseClicked", at = @At("RETURN")) public void mouseClicked$Inject$RETURN(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) { - if (mouseX > widthVersionRest && mouseX < widthVersionRest + widthVersion && mouseY > height - 20 && mouseY < height - 10) { + if (isInside(mouseX, mouseY, widthUpdate, widthUpdateRest) + && !WebUtils.INSTANCE.isLatestVersion() + ) { WebUtils.INSTANCE.openWebLink(LambdaMod.DOWNLOAD_LINK); } + + if (isInside(mouseX, mouseY, widthWatermark, widthWatermarkRest)) { + if (mouseButton == 0) { + MenuShader.setNextShader(); + } else { + MenuShader.setPreviousShader(); + } + MenuShader.reset(); + } } @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiMainMenu;drawGradientRect(IIIIII)V")) @@ -72,4 +97,12 @@ public abstract class MixinGuiMainMenu extends GuiScreen { ci.cancel(); } } + + private boolean isInside(int mouseX, int mouseY, int base, int rest) { + return mouseX > rest + && mouseX < rest + base + && mouseY > height - 20 + && mouseY < height - 10 + && Mouse.isInsideWindow(); + } } diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt b/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt index c69b6a481..d361d17a0 100644 --- a/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt +++ b/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt @@ -7,5 +7,9 @@ fun > E.next(): E = declaringJavaClass.enumConstants.run { get((ordinal + 1) % size) } +fun > E.previous(): E = declaringJavaClass.enumConstants.run { + get((ordinal - 1).mod(size)) +} + fun Enum<*>.readableName() = (this as? DisplayEnum)?.displayName ?: name.mapEach('_') { low -> low.lowercase().capitalize() }.joinToString(" ") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/MenuShader.kt b/src/main/kotlin/com/lambda/client/module/modules/client/MenuShader.kt index ced1142da..58bc430e6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/MenuShader.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/MenuShader.kt @@ -1,6 +1,8 @@ package com.lambda.client.module.modules.client import com.lambda.client.LambdaMod +import com.lambda.client.commons.extension.next +import com.lambda.client.commons.extension.previous import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.Wrapper @@ -20,7 +22,7 @@ object MenuShader : Module( enabledByDefault = true ) { private val mode by setting("Mode", Mode.SET) - private val shader by setting("Shader", ShaderEnum.CLOUDS, { mode == Mode.SET }) + private val shader = setting("Shader", ShaderEnum.CLOUDS, { mode == Mode.SET }) private enum class Mode { RANDOM, SET @@ -28,9 +30,9 @@ object MenuShader : Module( @Suppress("UNUSED") private enum class ShaderEnum(val path: String) { - BLUEGRID("/assets/shaders/menu/bluegrid.fsh"), - BLUENEBULA("/assets/shaders/menu/bluenebula.fsh"), - BLUEVORTEX("/assets/shaders/menu/bluevortex.fsh"), + BLUE_GRID("/assets/shaders/menu/bluegrid.fsh"), + BLUE_NEBULA("/assets/shaders/menu/bluenebula.fsh"), + BLUE_VORTEX("/assets/shaders/menu/bluevortex.fsh"), CAVE("/assets/shaders/menu/cave.fsh"), CLOUDS("/assets/shaders/menu/clouds.fsh"), DOUGHNUTS("/assets/shaders/menu/doughnuts.fsh"), @@ -38,9 +40,9 @@ object MenuShader : Module( JUPITER("/assets/shaders/menu/jupiter.fsh"), MATRIX("/assets/shaders/menu/matrix.fsh"), MINECRAFT("/assets/shaders/menu/minecraft.fsh"), - PURPLEGRID("/assets/shaders/menu/purplegrid.fsh"), - PURPLEMIST("/assets/shaders/menu/purplemist.fsh"), - REDGLOW("/assets/shaders/menu/redglow.fsh"), + PURPLE_GRID("/assets/shaders/menu/purplegrid.fsh"), + PURPLE_MIST("/assets/shaders/menu/purplemist.fsh"), + RED_GLOW("/assets/shaders/menu/redglow.fsh"), SKY("/assets/shaders/menu/sky.fsh"), SNAKE("/assets/shaders/menu/snake.fsh"), SPACE("/assets/shaders/menu/space.fsh"), @@ -66,11 +68,21 @@ object MenuShader : Module( currentShader = getShader() } + @JvmStatic + fun setNextShader() { + shader.value = shader.value.next() + } + + @JvmStatic + fun setPreviousShader() { + shader.value = shader.value.previous() + } + private fun getShader(): ShaderProgram { val shader = if (mode == Mode.RANDOM) { ShaderEnum.values().random() } else { - shader + shader.value } return shaderCache.getOrPut(shader) { From d6cbd9780575a4ea55b38f73b5dd5317bfe4ef7e Mon Sep 17 00:00:00 2001 From: Constructor Date: Sat, 5 Nov 2022 01:21:58 +0100 Subject: [PATCH 27/85] Fix NoGhostBlocks in singleplayer --- src/main/java/com/lambda/mixin/world/MixinItemBlock.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/lambda/mixin/world/MixinItemBlock.java b/src/main/java/com/lambda/mixin/world/MixinItemBlock.java index 1055f8483..5aac4a55e 100644 --- a/src/main/java/com/lambda/mixin/world/MixinItemBlock.java +++ b/src/main/java/com/lambda/mixin/world/MixinItemBlock.java @@ -2,6 +2,7 @@ import com.lambda.client.module.modules.player.NoGhostBlocks; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.item.ItemBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -11,9 +12,12 @@ @Mixin(ItemBlock.class) public class MixinItemBlock { + + private final Minecraft mc = Minecraft.getMinecraft(); + @Redirect(method = "placeBlockAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;I)Z")) private boolean ignoreSetBlockState(World instance, BlockPos p_setBlockState_1_, IBlockState p_setBlockState_2_, int p_setBlockState_3_) { - if (NoGhostBlocks.INSTANCE.isEnabled()) { + if (NoGhostBlocks.INSTANCE.isEnabled() && !mc.isSingleplayer()) { return true; } else { return instance.setBlockState(p_setBlockState_1_, p_setBlockState_2_, p_setBlockState_3_); From 8b2554bf0d7e11e0041460d1ec00df1dc576ecd4 Mon Sep 17 00:00:00 2001 From: nickcat325 <80810636+nickcat325@users.noreply.github.com> Date: Sun, 13 Nov 2022 21:17:38 -0600 Subject: [PATCH 28/85] Baritone.kt rewrite (#399) * Baritone.kt Darft * Update baritone.kt * Compile fix All of the original stuff and more works. * New Baritone controls * Baritone.kt complete * Fix typos Co-authored-by: Constructor --- .../client/module/modules/client/Baritone.kt | 94 ++++++++++++++----- 1 file changed, 72 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt index b4e5ea52a..e7f46d785 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt @@ -19,22 +19,54 @@ object Baritone : Module( showOnArray = false, alwaysEnabled = true ) { - private val showOnRadar by setting("Show Path on Radar", true, description = "Show the current path on radar.") - private val color by setting("Path Color", ColorHolder(32, 250, 32), visibility = { showOnRadar }) - private val allowBreak by setting("Allow Break", true) - private val allowSprint by setting("Allow Sprint", true) - private val allowPlace by setting("Allow Place", true) - private val allowInventory by setting("Allow Inventory", false) - private val freeLook by setting("Free Look", true) - private val allowWaterBucketFall by setting("Water bucket clutch", true, description = "Uses a water bucket to get down quickly.") - private val maxFallHeightBucket by setting("Max bucket height", 20, 5..255, 5, { allowWaterBucketFall }, description = "Max height that baritone can use a water bucket.") - private val allowDownwardTunneling by setting("Downward Tunneling", true) - private val allowParkour by setting("Allow Parkour", true) - private val allowParkourPlace by setting("Allow Parkour Place", true) - private val avoidPortals by setting("Avoid Portals", false) - private val renderGoal by setting("Render Goals", true) - private val failureTimeout by setting("Fail Timeout", 2, 1..20, 1, unit = "s") - private val blockReachDistance by setting("Reach Distance", 4.5f, 1.0f..10.0f, 0.5f) + /* + * Baritone variables can be found here. + * https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java + */ + + private val page by setting("Page", Page.BASIC) + + /* Basic */ + private val allowBreak by setting("Allow Break", true, { page == Page.BASIC }, description = "Allow Baritone to break blocks.") + private val allowPlace by setting("Allow Place", true, { page == Page.BASIC }, description = "Allow Baritone to place blocks.") + private val allowSprint by setting("Allow Sprint", true, { page == Page.BASIC }, description = "Allow Baritone to sprint.") + private val allowInventory by setting("Allow Inventory", false, { page == Page.BASIC }, description = "Allow Baritone to move items in your inventory to your hotbar.") + private val allowDownwardTunneling by setting("Downward Tunneling", true, { page == Page.BASIC }, description = "Allow mining blocks directly beneath you.") + private val allowParkour by setting("Allow Parkour", true, { page == Page.BASIC }) + private val allowParkourPlace by setting("Allow Parkour Place", true, { allowParkour && page == Page.BASIC }) + private val buildInLayers by setting("Build In Layers", false, { page == Page.BASIC }, description = "Build/mine one layer at a time in schematics and selections.") + private val layerOrder by setting("Top To Bottom", false, { buildInLayers && page == Page.BASIC }, description = "Build/mine from top to bottom in schematics and selections.") + + /* Visual */ + private val freeLook by setting("Free Look", true, { page == Page.VISUAL }, description = "Move without having to force the client-sided rotations.") + private val renderGoal by setting("Render Goals", true, { page == Page.VISUAL }, description = "Render the goal.") + private val censorCoordinates by setting("Censor Coordinates", false, { page == Page.VISUAL }, description = "Censor coordinates in goals and block positions.") + private val censorRanCommands by setting("Censor RanCommands", false, { page == Page.VISUAL }, description = "Censor arguments to ran commands, to hide, for example, coordinates to #goal.") + private val showOnRadar by setting("Show Path on Radar", true, { page == Page.VISUAL }, description = "Show the current path on radar.") + private val color by setting("Path Color", ColorHolder(32, 250, 32), visibility = { showOnRadar && page == Page.VISUAL }, description = "Path color for the radar.") + + /* Fall */ + private val maxFallHeightNoWater by setting("Max Fall Height", 3, 3..5, 1, { page == Page.FALL }, description = "Distance baritone can fall without water.") + private val allowWaterBucketFall by setting("Water Bucket Clutch", true, { page == Page.FALL }, description = "Uses a water bucket to get down quickly.") + private val maxFallHeightBucket by setting("Max Bucket Height", 20, 10..250, 10, { allowWaterBucketFall && page == Page.FALL }, description = "Max height that baritone can use a water bucket.") + + /* Advanced */ + private val blockReachDistance by setting("Reach Distance", 4.5f, 1.0f..10.0f, 0.5f, { page == Page.ADVANCED }, description = "Max distance baritone can place blocks.") + private val enterPortals by setting("Enter Portals", true, { page == Page.ADVANCED }, description = "Baritone will walk all the way into the portal, instead of stopping one block before.") + private val blockPlacementPenalty by setting("Block Placement Penalty", 20, 0..40, 5, { page == Page.ADVANCED }, description = "Decrease to make Baritone more often consider paths that would require placing blocks.") + private val blockBreakAdditionalPenalty by setting("Block Break Additional Penalty", 2, 0..10, 1, { page == Page.ADVANCED }, description = "Lower chance to break blocks. This is a tiebreaker.") + private val jumpPenalty by setting("Jump Penalty", 2, 0..10, 1, { page == Page.ADVANCED }, description = "Additional penalty for hitting the space bar (ascend, pillar, or parkour) because it uses hunger.") + private val assumeWalkOnWater by setting("Assume Walk On Water", false, { page == Page.ADVANCED }, description = "Allow Baritone to assume it can walk on still water just like any other block. Requires jesus to be enabled.") + private val failureTimeout by setting("Fail Timeout", 2, 1..20, 1, { page == Page.ADVANCED }, unit = "s") + private val avoidance by setting("Avoidance", false, { page == Page.ADVANCED }, description = "Enables the 4 avoidance settings. It's disabled by default because of the noticeable performance impact.") + private val mobAvoidanceRadius by setting("Mob Avoidance Radius", 15, 0..65, 5, visibility = { avoidance && page == Page.ADVANCED }, description = "Distance to avoid mobs.") + private val mobAvoidanceCoefficient by setting("Mob Avoidance Coefficient", 1.5f, 0f..5f, 0.5f, visibility = { avoidance && page == Page.ADVANCED }, description = "Set to 1.0 to effectively disable this feature. Set below 1.0 to go out of your way to walk near mobs.") + private val mobSpawnerAvoidanceRadius by setting("Mob Spawner Avoidance Radius", 10, 0..60, 10, visibility = { avoidance && page == Page.ADVANCED }, description = "Distance to avoid mob spawners.") + private val mobSpawnerAvoidanceCoefficient by setting("Mob Spawner Avoidance Coefficient", 1.5f, 0f..5f, 0.5f, visibility = { avoidance && page == Page.ADVANCED }, description = "Set to 1.0 to effectively disable this feature. Set below 1.0 to go out of your way to walk near mob spawners.") + + private enum class Page { + BASIC, VISUAL, FALL, ADVANCED + } init { settingList.forEach { @@ -72,20 +104,38 @@ object Baritone : Module( private fun sync() { BaritoneUtils.settings?.let { it.chatControl.value = false // enable chatControlAnyway if you want to use it + /* Basic */ it.allowBreak.value = allowBreak - it.allowSprint.value = allowSprint it.allowPlace.value = allowPlace + it.allowSprint.value = allowSprint it.allowInventory.value = allowInventory - it.freeLook.value = freeLook - it.allowWaterBucketFall.value = allowWaterBucketFall - it.maxFallHeightBucket.value = maxFallHeightBucket it.allowDownward.value = allowDownwardTunneling it.allowParkour.value = allowParkour it.allowParkourPlace.value = allowParkourPlace - it.enterPortal.value = !avoidPortals + it.buildInLayers.value = buildInLayers + it.layerOrder.value = layerOrder + /* Visual */ + it.freeLook.value = freeLook it.renderGoal.value = renderGoal - it.failureTimeoutMS.value = failureTimeout * 1000L + it.censorCoordinates.value = censorCoordinates + it.censorRanCommands.value = censorRanCommands + /* Fall */ + it.maxFallHeightNoWater.value = maxFallHeightNoWater + it.allowWaterBucketFall.value = allowWaterBucketFall + it.maxFallHeightBucket.value = maxFallHeightBucket + /* Advanced */ it.blockReachDistance.value = blockReachDistance + it.enterPortal.value = enterPortals + it.blockPlacementPenalty.value = blockPlacementPenalty.toDouble() + it.blockBreakAdditionalPenalty.value = blockBreakAdditionalPenalty.toDouble() + it.jumpPenalty.value = jumpPenalty.toDouble() + it.assumeWalkOnWater.value = assumeWalkOnWater + it.failureTimeoutMS.value = failureTimeout * 1000L + it.avoidance.value = avoidance + it.mobAvoidanceRadius.value = mobAvoidanceRadius + it.mobAvoidanceCoefficient.value = mobAvoidanceCoefficient.toDouble() + it.mobSpawnerAvoidanceRadius.value = mobSpawnerAvoidanceRadius + it.mobSpawnerAvoidanceCoefficient.value = mobSpawnerAvoidanceCoefficient.toDouble() } } } From d8f561968dc2319f7bf4079df12a037cf97a6dd0 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 21 Nov 2022 00:28:09 +0100 Subject: [PATCH 29/85] Window grid snapping and GUI fixes (#413) * Focus test * Hide module feature * Window grid snapping * Upgrade Kotlin 1.7.20 -> 1.7.21 * Fix frame margin * Resize corner ToDo: change render layer * Change mutex to sync block * Added freemove * Code refactor * Revert hide buttons bc it broke plugins * Oopsie * Fix hover object bug and margin split * Fix bottom margin and adjustable rubberband speed * Fix OpenGL 1281: Invalid value * Make SettingWindow unscrollable * Fix saving window size setting and option to disable scroll rubberband * Fix double click height calc * Fix left resize event * Make auto resize fully work --- gradle.properties | 2 +- .../lambda/client/gui/AbstractLambdaGui.kt | 19 ++- .../client/gui/clickgui/LambdaClickGui.kt | 24 +--- .../lambda/client/gui/hudgui/LambdaHudGui.kt | 43 +++--- .../com/lambda/client/gui/rgui/Component.kt | 12 +- .../lambda/client/gui/rgui/WindowComponent.kt | 60 ++++---- .../client/gui/rgui/component/Slider.kt | 4 +- .../client/gui/rgui/windows/BasicWindow.kt | 1 + .../client/gui/rgui/windows/ListWindow.kt | 129 ++++++++---------- .../client/gui/rgui/windows/SettingWindow.kt | 6 +- .../client/module/modules/client/ClickGUI.kt | 8 +- .../lambda/client/plugin/PluginClassLoader.kt | 1 - 12 files changed, 150 insertions(+), 159 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2499d264b..bd25efc90 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,5 +10,5 @@ forgeVersion=14.23.5.2860 mappingsChannel=stable mappingsVersion=39-1.12 -kotlinVersion=1.7.20 +kotlinVersion=1.7.21 kotlinxCoroutinesVersion=1.6.4 diff --git a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt index 16ee3e8fa..8700c1161 100644 --- a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt @@ -88,15 +88,15 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { safeListener { event -> if (event.phase != TickEvent.Phase.START) return@safeListener - blurShader.shader?.let { + blurShader.shader?.let { shaderGroup -> val multiplier = ClickGUI.blur * fadeMultiplier - for (shader in it.listShaders) { + shaderGroup.listShaders.forEach { shader -> shader.shaderManager.getShaderUniform("multiplier")?.set(multiplier) } } if (displayed.value || alwaysTicking) { - for (window in windowList) window.onTick() + windowList.forEach { it.onTick() } } } @@ -143,7 +143,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { displayed.value = true - for (window in windowList) window.onDisplayed() + windowList.forEach { it.onDisplayed() } } override fun initGui() { @@ -153,7 +153,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { width = scaledResolution.scaledWidth + 16 height = scaledResolution.scaledHeight + 16 - for (window in windowList) window.onGuiInit() + windowList.forEach { it.onGuiInit() } } override fun onGuiClosed() { @@ -165,7 +165,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { displayed.value = false - for (window in windowList) window.onClosed() + windowList.forEach { it.onClosed() } updateSettingWindow() } // End of gui init @@ -318,11 +318,10 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { } private fun drawEachWindow(renderBlock: (WindowComponent) -> Unit) { - for (window in windowList) { - if (!window.visible) continue + windowList.filter { it.visible }.forEach { glPushMatrix() - glTranslatef(window.renderPosX, window.renderPosY, 0.0f) - renderBlock(window) + glTranslatef(it.renderPosX, it.renderPosY, 0.0f) + renderBlock(it) glPopMatrix() } } diff --git a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt index 09ca83968..7de0eef7f 100644 --- a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt @@ -9,6 +9,7 @@ import com.lambda.client.gui.clickgui.window.ModuleSettingWindow import com.lambda.client.gui.rgui.Component import com.lambda.client.gui.rgui.windows.ListWindow import com.lambda.client.module.AbstractModule +import com.lambda.client.module.Category import com.lambda.client.module.ModuleManager import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.plugin.PluginManager @@ -37,37 +38,24 @@ object LambdaClickGui : AbstractLambdaGui() private var moduleCount = ModuleManager.modules.size init { - val allButtons = ModuleManager.modules - .groupBy { it.category.displayName } - .mapValues { (_, modules) -> modules.map { ModuleButton(it) } } - var posX = 0.0f - var posY = 0.0f - val screenWidth = mc.displayWidth / ClickGUI.getScaleFactorFloat() - /* Modules */ - for ((category, buttons) in allButtons) { - val window = ListWindow(category, posX, posY, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI) - - window.addAll(buttons.customSort()) + Category.values().forEach { category -> + val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI) windows.add(window) - posX += 90.0f - if (posX > screenWidth) { - posX = 0.0f - posY += 100.0f - } + posX += 90.0f } /* Plugins */ - pluginWindow = PluginWindow("Plugins", posX, posY) + pluginWindow = PluginWindow("Plugins", posX, 0.0f) pluginWindow.add(ImportPluginButton) pluginWindow.add(DownloadPluginButton) windows.add(pluginWindow) posX += 120.0f - remotePluginWindow = PluginWindow("Remote plugins", posX, posY) + remotePluginWindow = PluginWindow("Remote plugins", posX, 0.0f) remotePluginWindow.visible = false windows.add(remotePluginWindow) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt index f119fab0e..34f179f50 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt @@ -3,7 +3,6 @@ package com.lambda.client.gui.hudgui import com.lambda.client.event.events.RenderOverlayEvent import com.lambda.client.event.listener.listener import com.lambda.client.gui.AbstractLambdaGui -import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.gui.hudgui.component.HudButton import com.lambda.client.gui.hudgui.window.HudSettingWindow import com.lambda.client.gui.rgui.Component @@ -14,6 +13,7 @@ import com.lambda.client.module.modules.client.HudEditor import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f +import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard import org.lwjgl.opengl.GL11.* @@ -26,20 +26,13 @@ object LambdaHudGui : AbstractLambdaGui() init { var posX = 0.0f - var posY = 0.0f - val screenWidth = LambdaClickGui.mc.displayWidth / ClickGUI.getScaleFactorFloat() - for (category in AbstractHudElement.Category.values()) { + AbstractHudElement.Category.values().forEach { category -> val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.HUD_GUI) windowList.add(window) hudWindows[category] = window posX += 90.0f - - if (posX > screenWidth) { - posX = 0.0f - posY += 100.0f - } } listener { @@ -47,22 +40,21 @@ object LambdaHudGui : AbstractLambdaGui() if (eventKey == Keyboard.KEY_NONE || Keyboard.isKeyDown(Keyboard.KEY_F3)) return@listener - for (child in windowList) { - if (child !is AbstractHudElement) continue - if (!child.bind.isDown(eventKey)) continue - child.visible = !child.visible - } + windowList + .filterIsInstance() + .filter { it.bind.isDown(eventKey) } + .forEach { it.visible = !it.visible } } } internal fun register(hudElement: AbstractHudElement) { val button = HudButton(hudElement) - hudWindows[hudElement.category]!!.add(button) + hudWindows[hudElement.category]?.add(button) windowList.add(hudElement) } internal fun unregister(hudElement: AbstractHudElement) { - hudWindows[hudElement.category]!!.children.removeIf { it is HudButton && it.hudElement == hudElement } + hudWindows[hudElement.category]?.children?.removeIf { it is HudButton && it.hudElement == hudElement } windowList.remove(hudElement) } @@ -98,27 +90,26 @@ object LambdaHudGui : AbstractLambdaGui() } private fun setHudButtonVisibility(function: (HudButton) -> Boolean) { - windowList.filterIsInstance().forEach { - for (child in it.children) { - if (child !is HudButton) continue - child.visible = function(child) + windowList.filterIsInstance().forEach { window -> + window.children.filterIsInstance().forEach { button -> + button.visible = function(button) } } } init { - listener(0) { - if (mc?.world == null || mc?.player == null || mc?.currentScreen == this || mc?.gameSettings?.showDebugInfo != false) return@listener + safeListener(0) { + if (Hud.isDisabled) return@safeListener val vertexHelper = VertexHelper(GlStateUtils.useVbo()) GlStateUtils.rescaleLambda() - if (Hud.isEnabled) { - for (window in windowList) { - if (window !is AbstractHudElement || !window.visible) continue + windowList + .filterIsInstance() + .filter { it.visible } + .forEach { window -> renderHudElement(vertexHelper, window) } - } GlStateUtils.rescaleMc() GlStateUtils.depth(true) diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt index 689d53070..277454355 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt @@ -31,13 +31,13 @@ open class Component( protected val dockingHSetting = setting("Docking H", HAlign.LEFT) protected val dockingVSetting = setting("Docking V", VAlign.TOP) - private var widthSetting = setting("Width", widthIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minWidth, max(scaledDisplayWidth, minWidth)) }) - private var heightSetting = setting("Height", heightIn, 0.0f..69420.911f, 0.1f, { false }, { _, it -> it.coerceIn(minHeight, max(scaledDisplayHeight, minHeight)) }) + private var widthSetting = setting("Width", widthIn, 0.0f..69420.914f, 0.1f, { false }) + private var heightSetting = setting("Height", heightIn, 0.0f..69420.914f, 0.1f, { false }) - private var relativePosXSetting = setting("Pos X", posXIn, -69420.911f..69420.911f, 0.1f, { false }, - { _, it -> if (this is WindowComponent && LambdaMod.ready) absToRelativeX(relativeToAbsX(it).coerceIn(1.0f, max(scaledDisplayWidth - width - 1.0f, 1.0f))) else it }) - private var relativePosYSetting = setting("Pos Y", posYIn, -69420.911f..69420.911f, 0.1f, { false }, - { _, it -> if (this is WindowComponent && LambdaMod.ready) absToRelativeY(relativeToAbsY(it).coerceIn(1.0f, max(scaledDisplayHeight - height - 1.0f, 1.0f))) else it }) + private var relativePosXSetting = setting("Pos X", posXIn, -69420.914f..69420.914f, 0.1f, { false }, + { _, it -> if (this is WindowComponent && LambdaMod.ready) absToRelativeX(relativeToAbsX(it).coerceIn(.0f, max(scaledDisplayWidth - width, .0f))) else it }) + private var relativePosYSetting = setting("Pos Y", posYIn, -69420.914f..69420.914f, 0.1f, { false }, + { _, it -> if (this is WindowComponent && LambdaMod.ready) absToRelativeY(relativeToAbsY(it).coerceIn(.0f, max(scaledDisplayHeight - height, .0f))) else it }) var width by widthSetting open var height by heightSetting diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt index 9c7d981e5..951a9f3e9 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt @@ -1,14 +1,17 @@ package com.lambda.client.gui.rgui import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.module.modules.client.ClickGUI.gridSize import com.lambda.client.setting.GuiConfig.setting import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.graphics.AnimationUtils import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.math.Vec2f +import org.lwjgl.input.Keyboard import kotlin.math.max import kotlin.math.min +import kotlin.math.roundToInt open class WindowComponent( name: String, @@ -106,7 +109,12 @@ open class WindowComponent( else -> null } - val centerSplitterVCenter = if (draggableHeight != height && horizontalSide == HAlign.CENTER) 2.5 else min(15.0, preDragSize.x / 3.0) + val centerSplitterVCenter = if (draggableHeight != height && horizontalSide == HAlign.CENTER) { + 2.5 + } else { + min(15.0, preDragSize.x / 3.0) + } + val verticalSide = when (relativeClickPos.y) { in -2.0..centerSplitterVCenter -> VAlign.TOP in centerSplitterVCenter..preDragSize.y - centerSplitterV -> VAlign.CENTER @@ -114,30 +122,28 @@ open class WindowComponent( else -> null } + if (horizontalSide == null || verticalSide == null) return + val draggedDist = mousePos.minus(clickPos) - if (horizontalSide != null && verticalSide != null) { - if (resizable && !minimized && (horizontalSide != HAlign.CENTER || verticalSide != VAlign.CENTER)) { - handleResizeX(horizontalSide, draggedDist) - handleResizeY(verticalSide, draggedDist) + if (resizable && !minimized && (horizontalSide != HAlign.CENTER || verticalSide != VAlign.CENTER)) { + handleResizeX(horizontalSide, draggedDist) + handleResizeY(verticalSide, draggedDist) - onResize() - } else if (draggableHeight == height || relativeClickPos.y <= draggableHeight) { - posX = (preDragPos.x + draggedDist.x).coerceIn(1.0f, mc.displayWidth - width - 1.0f) - posY = (preDragPos.y + draggedDist.y).coerceIn(1.0f, mc.displayHeight - height - 1.0f) + onResize() + } else if (draggableHeight == height || relativeClickPos.y <= draggableHeight) { + posX = roundOnGrid(preDragPos.x + draggedDist.x).coerceIn(.0f, mc.displayWidth - width) + posY = roundOnGrid(preDragPos.y + draggedDist.y).coerceIn(.0f, mc.displayHeight - height) - onReposition() - } else { - // TODO - } + onReposition() } } private fun handleResizeX(horizontalSide: HAlign, draggedDist: Vec2f) { when (horizontalSide) { HAlign.LEFT -> { - val draggedX = max(draggedDist.x, 1.0f - preDragPos.x) - var newWidth = max(preDragSize.x - draggedX, minWidth) + val draggedX = max(roundOnGrid(draggedDist.x), 1.0f - preDragPos.x) + var newWidth = max(roundOnGrid(preDragSize.x - draggedX), minWidth) if (maxWidth != -1.0f) newWidth = min(newWidth, maxWidth) newWidth = min(newWidth, scaledDisplayWidth - 2.0f) @@ -147,8 +153,8 @@ open class WindowComponent( posX += prevWidth - newWidth } HAlign.RIGHT -> { - val draggedX = min(draggedDist.x, preDragPos.x + preDragSize.x - 1.0f) - var newWidth = max(preDragSize.x + draggedX, minWidth) + val draggedX = min(roundOnGrid(draggedDist.x), preDragPos.x + preDragSize.x - 1.0f) + var newWidth = max(roundOnGrid(preDragSize.x + draggedX), minWidth) if (maxWidth != -1.0f) newWidth = min(newWidth, maxWidth) newWidth = min(newWidth, scaledDisplayWidth - posX - 2.0f) @@ -156,7 +162,7 @@ open class WindowComponent( width = newWidth } else -> { - // Nothing lol + // Ignored } } } @@ -164,8 +170,8 @@ open class WindowComponent( private fun handleResizeY(verticalSide: VAlign, draggedDist: Vec2f) { when (verticalSide) { VAlign.TOP -> { - val draggedY = max(draggedDist.y, 1.0f - preDragPos.y) - var newHeight = max(preDragSize.y - draggedY, minHeight) + val draggedY = max(roundOnGrid(draggedDist.y), 1.0f - preDragPos.y) + var newHeight = max(roundOnGrid(preDragSize.y - draggedY), minHeight) if (maxHeight != -1.0f) newHeight = min(newHeight, maxHeight) newHeight = min(newHeight, scaledDisplayHeight - 2.0f) @@ -175,20 +181,26 @@ open class WindowComponent( posY += prevHeight - newHeight } VAlign.BOTTOM -> { - val draggedY = min(draggedDist.y, preDragPos.y + preDragSize.y - 1.0f) - var newHeight = max(preDragSize.y + draggedY, minHeight) + val draggedY = min(roundOnGrid(draggedDist.y), preDragPos.y + preDragSize.y - 1.0f) + var newHeight = max(roundOnGrid(preDragSize.y + draggedY), minHeight) if (maxHeight != -1.0f) newHeight = min(newHeight, maxHeight) newHeight = min(newHeight, scaledDisplayHeight - posY - 2.0f) height = newHeight } - else -> { - // Nothing lol + VAlign.CENTER -> { + // Ignored } } } + private fun roundOnGrid(delta: Float) = + if (gridSize == .0f + || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) + || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) + ) delta else (delta / gridSize).roundToInt() * gridSize + fun isInWindow(mousePos: Vec2f): Boolean { return visible && mousePos.x in preDragPos.x - 2.0f..preDragPos.x + preDragSize.x + 2.0f && mousePos.y in preDragPos.y - 2.0f..preDragPos.y + max(preDragSize.y * renderMinimizeProgress, draggableHeight) + 2.0f diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/Slider.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/Slider.kt index 6bc045cfd..61ff711b8 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/Slider.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/Slider.kt @@ -168,7 +168,9 @@ open class Slider( RenderUtils2D.drawRectFilled( vertexHelper, posEnd = Vec2d(textWidth, textHeight).plus(4.0), - color = GuiColors.backGround.apply { a = (a * alpha).toInt() }) + color = GuiColors.backGround.apply { a = (a * alpha).toInt() } + ) + if (ClickGUI.windowOutline) { RenderUtils2D.drawRectOutline( vertexHelper, diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt index 7e542993e..f4481512a 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt @@ -32,6 +32,7 @@ open class BasicWindow( ClickGUI.radius, color = GuiColors.backGround ) + if (ClickGUI.windowOutline) { RenderUtils2D.drawRoundedRectOutline( vertexHelper, diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt index dd00cad74..026f6045a 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt @@ -1,7 +1,5 @@ package com.lambda.client.gui.rgui.windows -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt import com.lambda.client.commons.extension.sumByFloat import com.lambda.client.gui.AbstractLambdaGui import com.lambda.client.gui.rgui.Component @@ -11,9 +9,6 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock import org.lwjgl.input.Mouse import org.lwjgl.opengl.GL11.* import kotlin.math.max @@ -29,7 +24,6 @@ open class ListWindow( vararg childrenIn: Component ) : TitledWindow(name, posX, posY, width, height, saveToConfig) { val children = ArrayList() - private val contentMutex = Mutex() override val minWidth = 80.0f override val minHeight = 200.0f @@ -48,12 +42,12 @@ open class ListWindow( private val scrollTimer = TickTimer() private var scrollSpeed = 0.0f - private var scrollProgress = 0.0f + var scrollProgress = 0.0f set(value) { prevScrollProgress = field field = value } - private var prevScrollProgress = 0.0f + var prevScrollProgress = 0.0f private val renderScrollProgress get() = prevScrollProgress + (scrollProgress - prevScrollProgress) * mc.renderPartialTicks @@ -65,65 +59,57 @@ open class ListWindow( } fun addAll(all: Collection) { - runBlocking { - contentMutex.withLock { - children.addAll(all) - } + synchronized(this) { + children.addAll(all) } } fun add(c: Component) { - runBlocking { - contentMutex.withLock { - children.add(c) - } + synchronized(this) { + children.add(c) } } fun remove(c: Component) { - runBlocking { - contentMutex.withLock { - children.remove(c) - } + synchronized(this) { + children.remove(c) } } fun clear() { - runBlocking { - contentMutex.withLock { - children.clear() - } + synchronized(this) { + children.clear() } } private fun updateChild() { - runBlocking { - contentMutex.withLock { - var y = (if (draggableHeight != height) draggableHeight else 0.0f) + ClickGUI.entryMargin - for (child in children) { - if (!child.visible) continue - child.posX = ClickGUI.entryMargin * 1.618f - child.posY = y - child.width = width - ClickGUI.entryMargin * 3.236f - y += child.height + ClickGUI.entryMargin + synchronized(this) { + var y = (if (draggableHeight != height) draggableHeight else 0.0f) + ClickGUI.verticalMargin + + children + .filter { it.visible } + .forEach { + it.posX = ClickGUI.horizontalMargin + it.posY = y + it.width = width - ClickGUI.horizontalMargin * 2 + y += it.height + ClickGUI.verticalMargin } - } } } override fun onDisplayed() { super.onDisplayed() - for (child in children) child.onDisplayed() + children.forEach { it.onDisplayed() } } override fun onClosed() { super.onClosed() - for (child in children) child.onClosed() + children.forEach { it.onClosed() } } override fun onGuiInit() { super.onGuiInit() - for (child in children) child.onGuiInit() + children.forEach { it.onGuiInit() } updateChild() } @@ -135,32 +121,35 @@ open class ListWindow( override fun onTick() { super.onTick() if (children.isEmpty()) return + val lastVisible = children.lastOrNull { it.visible } - val maxScrollProgress = lastVisible?.let { max(it.posY + it.height + ClickGUI.entryMargin - height, 0.01f) } + val maxScrollProgress = lastVisible?.let { max(it.posY + it.height + ClickGUI.verticalMargin + ClickGUI.resizeBar - height, 0.01f) } ?: draggableHeight scrollProgress = (scrollProgress + scrollSpeed) scrollSpeed *= 0.5f - if (scrollTimer.tick(100L, false)) { - if (scrollProgress < 0.0) { - scrollSpeed = scrollProgress * -0.25f + + if (!ClickGUI.scrollRubberband) { + scrollProgress = scrollProgress.coerceIn(.0f, maxScrollProgress) + prevScrollProgress = prevScrollProgress.coerceIn(.0f, maxScrollProgress) + } else if (scrollTimer.tick(100L, false)) { + if (scrollProgress < 0) { + scrollSpeed = scrollProgress * -ClickGUI.scrollRubberbandSpeed } else if (scrollProgress > maxScrollProgress) { - scrollSpeed = (scrollProgress - maxScrollProgress) * -0.25f + scrollSpeed = (scrollProgress - maxScrollProgress) * -ClickGUI.scrollRubberbandSpeed } } updateChild() - for (child in children) child.onTick() + children.forEach { it.onTick() } } override fun onRender(vertexHelper: VertexHelper, absolutePos: Vec2f) { super.onRender(vertexHelper, absolutePos) - runBlocking { - contentMutex.withLock { - renderChildren { - it.onRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress)) - } + synchronized(this) { + renderChildren { + it.onRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress)) } } } @@ -168,37 +157,32 @@ open class ListWindow( override fun onPostRender(vertexHelper: VertexHelper, absolutePos: Vec2f) { super.onPostRender(vertexHelper, absolutePos) - runBlocking { - contentMutex.withLock { - renderChildren { - it.onPostRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress)) - } + synchronized(this) { + renderChildren { + it.onPostRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress)) } } } - fun containsName(name: String): Boolean = - children.any { - it.name == name - } + fun containsName(name: String): Boolean = children.any { it.name == name } private fun renderChildren(renderBlock: (Component) -> Unit) { GlStateUtils.scissor( - ((renderPosX + ClickGUI.entryMargin * 1.618) * ClickGUI.getScaleFactor() - 0.5f).floorToInt(), - mc.displayHeight - ((renderPosY + renderHeight) * ClickGUI.getScaleFactor() - 0.5f).floorToInt(), - ((renderWidth - ClickGUI.entryMargin * 3.236) * ClickGUI.getScaleFactor() + 1.0f).ceilToInt(), - ((renderHeight - draggableHeight) * ClickGUI.getScaleFactor() + 1.0f).ceilToInt() + ((renderPosX + ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(), + mc.displayHeight - ((renderPosY + renderHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt(), + ((renderWidth - ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(), + ((renderHeight - draggableHeight - ClickGUI.resizeBar)* ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0) ) glEnable(GL_SCISSOR_TEST) glTranslatef(0.0f, -renderScrollProgress, 0.0f) - for (child in children) { - if (!child.visible) continue - if (child.renderPosY + child.renderHeight - renderScrollProgress < draggableHeight) continue - if (child.renderPosY - renderScrollProgress > renderHeight) continue + children.filter { it.visible + && it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight + && it.renderPosY - renderScrollProgress < renderHeight + }.forEach { glPushMatrix() - glTranslatef(child.renderPosX, child.renderPosY, 0.0f) - renderBlock(child) + glTranslatef(it.renderPosX, it.renderPosY, 0.0f) + renderBlock(it) glPopMatrix() } @@ -222,7 +206,12 @@ open class ListWindow( } private fun updateHovered(relativeMousePos: Vec2f) { - hoveredChild = if (relativeMousePos.y < draggableHeight || relativeMousePos.x < ClickGUI.entryMargin || relativeMousePos.x > renderWidth - ClickGUI.entryMargin) null + hoveredChild = if (relativeMousePos.y < draggableHeight + scrollProgress + || relativeMousePos.y > renderHeight + scrollProgress - ClickGUI.resizeBar + || relativeMousePos.x < ClickGUI.horizontalMargin + || relativeMousePos.x > renderWidth - ClickGUI.horizontalMargin + ) null + else children.firstOrNull { it.visible && relativeMousePos.y in it.posY..it.posY + it.height } } @@ -271,8 +260,8 @@ open class ListWindow( doubleClickTime = if (currentTime - doubleClickTime > 500L) { currentTime } else { - val sum = children.filter(Component::visible).sumByFloat { it.height + ClickGUI.entryMargin } - val targetHeight = max(height, sum + draggableHeight + ClickGUI.entryMargin) + val sum = children.filter(Component::visible).sumByFloat { it.height + ClickGUI.verticalMargin } + val targetHeight = sum + draggableHeight + ClickGUI.verticalMargin + ClickGUI.resizeBar val maxHeight = scaledDisplayHeight - 2.0f height = min(targetHeight, scaledDisplayHeight - 2.0f) diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt index 9c1fdd639..9f7e52995 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt @@ -1,6 +1,7 @@ package com.lambda.client.gui.rgui.windows import com.lambda.client.commons.extension.sumByFloat +import com.lambda.client.gui.rgui.InteractiveComponent import com.lambda.client.gui.rgui.component.* import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.settings.AbstractSetting @@ -13,6 +14,7 @@ import com.lambda.client.setting.settings.impl.primitive.StringSetting import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f import org.lwjgl.input.Keyboard +import org.lwjgl.input.Mouse abstract class SettingWindow( name: String, @@ -25,7 +27,7 @@ abstract class SettingWindow( override val minWidth: Float get() = 100.0f override val minHeight: Float get() = draggableHeight override var height: Float = 0.0f - get() = children.filter { it.visible }.sumByFloat { it.height + ClickGUI.entryMargin } + ClickGUI.entryMargin + 6.0f + FontRenderAdapter.getFontHeight() + get() = children.filter { it.visible }.sumByFloat { it.height + ClickGUI.verticalMargin } + ClickGUI.verticalMargin + draggableHeight + ClickGUI.resizeBar override val minimizable get() = false @@ -79,6 +81,8 @@ abstract class SettingWindow( super.onTick() if (listeningChild?.listening == false) listeningChild = null Keyboard.enableRepeatEvents(listeningChild != null) + scrollProgress = .0f + prevScrollProgress = .0f } override fun onClosed() { diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt index 6edbb12ce..3705939aa 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt @@ -24,10 +24,15 @@ object ClickGUI : Module( val windowOutline by setting("Window Outline", false) val buttonOutline by setting("Button Outline", false) val outlineWidth by setting("Outline Width", 2.5f, 0.5f..3.5f, 0.5f, { windowOutline || buttonOutline }) - val entryMargin by setting("Margin", 0.0f, 0.0f..10.0f, 0.5f, unit = "px") + val resizeBar by setting("Resize Bar", 5, 0..20, 1, unit = "px") + val horizontalMargin by setting("Horizontal Margin", 0.0f, 0.0f..10.0f, 0.5f, unit = "px") + val verticalMargin by setting("Vertical Margin", 0.0f, 0.0f..10.0f, 0.5f, unit = "px") val darkness by setting("Darkness", 0.25f, 0.0f..1.0f, 0.05f) + val gridSize by setting("Snap Grid", 10.0f, 0.0f..50.0f, 1.0f, unit = "px") val fadeInTime by setting("Fade In Time", 0.25f, 0.0f..1.0f, 0.05f, unit = "s") val fadeOutTime by setting("Fade Out Time", 0.1f, 0.0f..1.0f, 0.05f, unit = "s") + val scrollRubberband by setting("Scroll Rubberband", false) + val scrollRubberbandSpeed by setting("Scroll Rubberband Speed", 0.5f, 0.01f..1.0f, 0.05f, { scrollRubberband }) val showModifiedInBold by setting("Show Modified In Bold", false, description = "Display modified settings in a bold font") private val resetComponents = setting("Reset Positions", false) private val resetScale = setting("Reset Scale", false) @@ -92,6 +97,7 @@ object ClickGUI : Module( if (mc.currentScreen !is LambdaClickGui) { HudEditor.disable() mc.displayGuiScreen(LambdaClickGui) + LambdaClickGui.isFocused = true LambdaClickGui.onDisplayed() } } diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt b/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt index 35bf375d5..eccfe66d9 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt @@ -39,7 +39,6 @@ class PluginClassLoader(jar: JarFile, parent: ClassLoader) : ClassLoader(parent) private fun getClasses(jar: JarFile) { for (entry in jar.entries()) { - if (entry.name.endsWith(".class")) { classes[entry.name.removeSuffix(".class").replace("/", ".")] = getDataFromEntry(jar, entry) } else if (!entry.name.endsWith("/")) { From 0cdcbc59608e8b081ca19fe05fa1128217e7ecf3 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 21 Nov 2022 01:01:12 +0100 Subject: [PATCH 30/85] Added Parkour module (#416) * Adding Parkour module * Move setting update block * Add renderer thickness --- .../client/module/modules/movement/Parkour.kt | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/movement/Parkour.kt diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Parkour.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Parkour.kt new file mode 100644 index 000000000..07ea8bb58 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Parkour.kt @@ -0,0 +1,65 @@ +package com.lambda.client.module.modules.movement + +import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.module.modules.client.GuiColors +import com.lambda.client.module.modules.render.Search.setting +import com.lambda.client.util.Wrapper +import com.lambda.client.util.graphics.ESPRenderer +import com.lambda.client.util.graphics.GeometryMasks +import com.lambda.client.util.threads.safeListener +import net.minecraft.util.math.AxisAlignedBB +import net.minecraft.util.math.BlockPos +import net.minecraftforge.client.event.InputUpdateEvent + +object Parkour: Module( + name = "Parkour", + category = Category.MOVEMENT, + description = "Jumps when you are at the edge of a block" +) { + private val autoJump by setting("Auto Jump", true) + private val onlyOnForwardKey by setting("Only on Forward", true, { autoJump }) + private val onSneak by setting("On Sneak", false) + private val distanceToEdge by setting("Distance to edge", 0.001, 0.001..1.0, 0.001, { autoJump }, unit = " blocks") + private val distanceToFloor by setting("Distance to floor", 0.07, 0.01..0.6, 0.01, { autoJump }, unit = " blocks") + private val esp by setting("FeetESP", true) + private val espFilledAlpha by setting("ESP Filled Alpha", 47, 0..255, 1, { esp }) + private val espOutlineAlpha by setting("ESP Outline Alpha", 0, 0..255, 1, { esp }) + private val thickness by setting("Line Thickness", 2.0f, 0.25f..5.0f, 0.25f, { esp }) + private val espColor by setting("ESP Color", GuiColors.primary, false, { esp }) + + private val renderer = ESPRenderer() + private var currentCheckAABB = AxisAlignedBB(BlockPos.ORIGIN) + + init { + safeListener { + currentCheckAABB = player.entityBoundingBox + .offset(0.0, -distanceToFloor, 0.0) + .grow(-distanceToEdge, 0.0, -distanceToEdge) + + if (autoJump + && player.onGround + && world.getCollisionBoxes(player, currentCheckAABB).isEmpty() + && (!player.isSneaking || !onSneak) + && (it.movementInput.forwardKeyDown || !onlyOnForwardKey) + ) it.movementInput.jump = true + } + + listener { + if (!esp) return@listener + + renderer.aFilled = espFilledAlpha + renderer.aOutline = espOutlineAlpha + renderer.thickness = thickness + + renderer.clear() + Wrapper.player?.let { + renderer.add(it, espColor, GeometryMasks.Quad.DOWN) + } + + renderer.render(false) + } + } +} \ No newline at end of file From 71508be5de1d01086d1d74c50117557b68020401 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 21 Nov 2022 01:42:46 +0100 Subject: [PATCH 31/85] Small change big effect: Instant hover responsiveness --- src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt index 8700c1161..4f56b2eaf 100644 --- a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt @@ -196,7 +196,6 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { } } - hoveredWindow?.onMouseInput(mousePos) super.handleMouseInput() updateSettingWindow() } @@ -283,6 +282,8 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { drawTypedString() GlStateUtils.depth(false) + + hoveredWindow?.onMouseInput(getRealMousePos()) } private fun drawBackground(vertexHelper: VertexHelper, partialTicks: Float) { From c073a8f1bfaf235362a6c478f9ccef18a1ebb6d3 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 21 Nov 2022 11:26:33 -0800 Subject: [PATCH 32/85] Fix unfocused clickgui issue (#417) --- .../lambda/mixin/accessor/gui/AccessorGuiScreen.java | 12 ++++++++++++ .../com/lambda/client/gui/AbstractLambdaGui.kt | 2 ++ src/main/resources/mixins.lambda.json | 1 + 3 files changed, 15 insertions(+) create mode 100644 src/main/java/com/lambda/mixin/accessor/gui/AccessorGuiScreen.java diff --git a/src/main/java/com/lambda/mixin/accessor/gui/AccessorGuiScreen.java b/src/main/java/com/lambda/mixin/accessor/gui/AccessorGuiScreen.java new file mode 100644 index 000000000..9e7a1beda --- /dev/null +++ b/src/main/java/com/lambda/mixin/accessor/gui/AccessorGuiScreen.java @@ -0,0 +1,12 @@ +package com.lambda.mixin.accessor.gui; + +import net.minecraft.client.gui.GuiScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(value = GuiScreen.class) +public interface AccessorGuiScreen { + + @Accessor("eventButton") + void setEventButton(final int eventButton); +} diff --git a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt index 4f56b2eaf..70333af61 100644 --- a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt @@ -15,6 +15,7 @@ import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.gui.AccessorGuiScreen import net.minecraft.client.gui.GuiScreen import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager @@ -140,6 +141,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { open fun onDisplayed() { lastClickedWindow = null lastEventButton = -1 + (this as AccessorGuiScreen).setEventButton(-1) displayed.value = true diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index 3d065cea2..08b385b45 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -18,6 +18,7 @@ "accessor.gui.AccessorGuiChat", "accessor.gui.AccessorGuiDisconnected", "accessor.gui.AccessorGuiEditSign", + "accessor.gui.AccessorGuiScreen", "accessor.network.AccessorCPacketChatMessage", "accessor.network.AccessorCPacketCloseWindow", "accessor.network.AccessorCPacketPlayer", From b3bf03720a1912575ba65aaaaa46bea721d27f5a Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 23 Nov 2022 06:15:03 +0100 Subject: [PATCH 33/85] Added contributor graph --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 514c2f6b4..b1a3eda74 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Clone the repository to your local machine. Use the link of either your fork or git clone https://github.com/lambda-client/lambda ``` -Run `setupWorkspace.sh` to initialize the environment. +Run `setupWorkspace.sh` to initialize the environment. Use your terminal on Linux or [Git Bash](https://gitforwindows.org/) for Windows. ``` ./setupWorkspace.sh @@ -126,8 +126,13 @@ Test if the environment is set up correctly by building the client and running i 1. Go to `lambda > Tasks > build > runClient` in the Gradle tab and run the client. 2. To build the client as a jar run `lambda > Tasks > build > build`. Gradle will create a new directory called `build`. The final built jar will be in `build/libs`. +### Stargazers +[![Stargazers](https://starchart.cc/lambda-client/lambda.svg)](https://starchart.cc/lambda-client/lambda) + ## Thanks to +[![GitHub contributors](https://contrib.rocks/image?repo=lambda-client/lambda)](https://github.com/lambda-client/lambda/graphs/contributors) + [zeroeightysix](https://github.com/zeroeightysix) for the original [KAMI](https://github.com/zeroeightysix/KAMI) [KAMI Blue](https://github.com/kami-blue) for the continuation of [KAMI](https://github.com/zeroeightysix/KAMI) @@ -136,10 +141,5 @@ Test if the environment is set up correctly by building the client and running i [MinecraftForge](https://github.com/MinecraftForge) for [Forge](https://github.com/MinecraftForge/MinecraftForge) -Our [contributors](https://github.com/lambda-client/lambda/graphs/contributors) ❤️ - -### Stargazers -[![Stargazers](https://starchart.cc/lambda-client/lambda.svg)](https://starchart.cc/lambda-client/lambda) - > ### Disclaimer > This software does not contain any copyrighted Minecraft code. This is a Forge utility mod, only meant for use in anarchy environments. Do not use without permission of server administration. From 38b43e14cd04948d47422440756b12c4108e3207 Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 28 Nov 2022 04:41:28 +0100 Subject: [PATCH 34/85] New feature for Freecam: Cheese Mode (#420) --- .../client/module/modules/player/Freecam.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt index 81145fc6e..6b16ac72f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt @@ -30,6 +30,7 @@ import net.minecraft.entity.Entity import net.minecraft.entity.MoverType import net.minecraft.entity.player.EntityPlayer import net.minecraft.network.play.client.CPacketUseEntity +import net.minecraft.network.play.server.SPacketEntityHeadLook import net.minecraft.util.MovementInput import net.minecraft.util.MovementInputFromOptions import net.minecraft.util.math.BlockPos @@ -55,6 +56,7 @@ object Freecam : Module( private val horizontalSpeed by setting("Horizontal Speed", 20.0f, 1.0f..50.0f, 1f) private val verticalSpeed by setting("Vertical Speed", 20.0f, 1.0f..50.0f, 1f, { directionMode == FlightMode.CREATIVE }) private val autoRotate by setting("Auto Rotate", true) + private val cheese by setting("Cheese", false, description = "Make group pictures without headache") private val arrowKeyMove by setting("Arrow Key Move", true) private val disableOnDisconnect by setting("Disconnect Disable", true) private val leftClickCome by setting("Left Click Come", false) @@ -158,10 +160,26 @@ object Freecam : Module( if (BaritoneUtils.isActive) return@safeListener - if (autoRotate) updatePlayerRotation() + if (cheese) { + cameraGuy?.let { camGuy -> + world.loadedEntityList.filterIsInstance() + .filter { otherPlayer -> otherPlayer != camGuy } + .forEach { otherPlayer -> + val rotation = getRotationTo(otherPlayer.getPositionEyes(1.0f), camGuy.getPositionEyes(1.0f)) + + otherPlayer.rotationYaw = rotation.x + otherPlayer.rotationYawHead = rotation.x + otherPlayer.rotationPitch = rotation.y + } + } + } else if (autoRotate) updatePlayerRotation() if (arrowKeyMove) updatePlayerMovement() } + safeListener { + if (it.packet is SPacketEntityHeadLook && cheese) it.cancel() + } + listener { if (leftClickCome && Mouse.getEventButton() == 0 && clickTimer.tick(1L)) { val result: BlockPos = mc.objectMouseOver.blockPos ?: return@listener From 5ebd677dcfaba728857d630c621163aaae251bc3 Mon Sep 17 00:00:00 2001 From: Constructor Date: Thu, 1 Dec 2022 05:32:05 +0100 Subject: [PATCH 35/85] Making use of setting consumer --- .../module/modules/misc/MapDownloader.kt | 10 +++---- .../module/modules/player/PacketLogger.kt | 10 +++---- .../client/module/modules/render/NewChunks.kt | 27 +++++++------------ 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/MapDownloader.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/MapDownloader.kt index 55b82cb74..404b6d7f0 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/MapDownloader.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/MapDownloader.kt @@ -37,7 +37,10 @@ internal object MapDownloader : Module( private val saveMapsFromEntity by setting("Save maps from entity", true) private val saveMapsFromInventory by setting("Save maps from inventory", true, description = "When rendering a new map it will save one image for every map update!") private val saveDelay by setting("Save delay", 0.2, 0.1..2.0, 0.1, unit = " s") - private val openImageFolder = setting("Open Image Folder...", false) + private val openImageFolder = setting("Open Image Folder...", false, consumer = { _, _ -> + FolderUtils.openFolder(FolderUtils.mapImagesFolder) + true + }) private val pendingHashes = mutableSetOf() private var existingHashes = mutableSetOf() private var pendingTasks = mutableSetOf() @@ -73,11 +76,6 @@ internal object MapDownloader : Module( getMaps() } - - openImageFolder.consumers.add { _, it -> - if (it) FolderUtils.openFolder(FolderUtils.mapImagesFolder) - false - } } private fun getExistingHashes(): MutableSet { diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt index 6a146cc9a..29b484993 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt @@ -43,7 +43,10 @@ object PacketLogger : Module( private val ignoreUnknown by setting("Ignore Unknown Packets", false, description = "Ignore packets that aren't explicitly handled.") private val ignoreChat by setting("Ignore Chat", true, description = "Ignore chat packets.") private val ignoreCancelled by setting("Ignore Cancelled", true, description = "Ignore cancelled packets.") - private val openLogFolder = setting("Open Log Folder...", false) + private val openLogFolder by setting("Open Log Folder...", false, consumer = { _, _ -> + FolderUtils.openFolder(FolderUtils.packetLogFolder) + true + }) private val fileTimeFormatter = DateTimeFormatter.ofPattern("HH-mm-ss_SSS") @@ -135,11 +138,6 @@ object PacketLogger : Module( sendPacket(it.packet) } - - openLogFolder.consumers.add { _, it -> - if (it) FolderUtils.openFolder(FolderUtils.logFolder) - false - } } private fun receivePacket(packet: Packet<*>) { diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index e74e38421..701bdcc59 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -50,8 +50,15 @@ object NewChunks : Module( private val saveOption by setting("Save Option", SaveOption.EXTRA_FOLDER, { saveNewChunks }) private val saveInRegionFolder by setting("In Region", false, { saveNewChunks }) private val alsoSaveNormalCoords by setting("Save Normal Coords", false, { saveNewChunks }) - private val closeFile = setting("Close file", false, { saveNewChunks }) - private val openNewChunksFolder = setting("Open NewChunks Folder...", false, { saveNewChunks }) + private val closeFile by setting("Close file", false, { saveNewChunks }, consumer = { _, _ -> + logWriterClose() + MessageSendHelper.sendChatMessage("$chatName Saved file to $path!") + false + }) + private val openNewChunksFolder by setting("Open NewChunks Folder...", false, { saveNewChunks }, consumer = { _, _ -> + FolderUtils.openFolder(FolderUtils.newChunksFolder) + false + }) private val yOffset by setting("Y Offset", 0, -256..256, 4, fineStep = 1, description = "Render offset in Y axis") private val color by setting("Color", ColorHolder(255, 64, 64, 200), description = "Highlighting color") private val thickness by setting("Thickness", 1.5f, 0.1f..4.0f, 0.1f, description = "Thickness of the highlighting square") @@ -350,20 +357,4 @@ object NewChunks : Module( ip = mc.currentServerData?.serverIP } } - - init { - closeFile.valueListeners.add { _, _ -> - if (closeFile.value) { - logWriterClose() - MessageSendHelper.sendChatMessage("$chatName Saved file!") - MessageSendHelper.sendChatMessage("$path") - closeFile.value = false - } - } - - openNewChunksFolder.consumers.add { _, it -> - if (it) FolderUtils.openFolder(FolderUtils.newChunksFolder) - false - } - } } \ No newline at end of file From 9de3cc1cc04f5a9c7347b5adcdc75e8824166764 Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Thu, 1 Dec 2022 22:12:29 +0000 Subject: [PATCH 36/85] Refactor Flight (#381) * Rewrite Flight -> Packet mode * Cleanup Co-authored-by: Constructor --- .../client/module/modules/movement/Flight.kt | 257 ++++++++++++++---- 1 file changed, 209 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt index 27f50378f..3d5802147 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt @@ -3,9 +3,8 @@ package com.lambda.client.module.modules.movement import com.lambda.client.event.Phase import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.listener.listener -import com.lambda.client.manager.managers.PacketManager import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.playerPosLookPitch import com.lambda.client.mixin.extension.playerPosLookYaw @@ -14,42 +13,67 @@ import com.lambda.client.module.Module import com.lambda.client.util.MovementUtils import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.threads.runSafe +import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import net.minecraft.network.play.client.CPacketConfirmTeleport import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.network.play.server.SPacketCloseWindow import net.minecraft.network.play.server.SPacketPlayerPosLook +import net.minecraft.util.math.Vec3d import kotlin.math.cos +import kotlin.math.floor +import kotlin.math.hypot import kotlin.math.sin + object Flight : Module( name = "Flight", description = "Makes the player fly", category = Category.MOVEMENT, modulePriority = 500 ) { + // non packet private val mode by setting("Mode", FlightMode.PACKET) - private val speed by setting("Speed", 1.0f, 0.0f..10.0f, 0.1f) - private val glideSpeed by setting("Glide Speed", 0.05, 0.0..0.3, 0.001) - private val packetMode by setting("Packet Mode", PacketMode.NEGATIVE, { mode == FlightMode.PACKET }) - private val upSpeed by setting("Up Speed", 0.0622, 0.0..0.3, 0.001, { mode == FlightMode.PACKET }) + private val speed by setting("Speed", 1.0f, 0f..10f, 0.1f, { mode != FlightMode.PACKET }) + private val glideSpeed by setting("Glide Speed", 0.05, 0.0..0.3, 0.001, { mode != FlightMode.PACKET }) + + // packet + private val packetMode by setting("Packet Mode", PacketMode.FAST, { mode == FlightMode.PACKET }) + private val bounds by setting("Packet Type", PacketType.NEGATIVE, { mode == FlightMode.PACKET }) + private val factor by setting("Bypass Factor", 1f, 0f..10f, .1f, { mode == FlightMode.PACKET }) + private val concealFactor by setting("Conceal Factor", 2f, 0f..10f, .1f, { mode == FlightMode.PACKET }) + private val conceal by setting("Conceal", false, { mode == FlightMode.PACKET }) private val antiKick by setting("Anti Kick", true, { mode == FlightMode.PACKET }) - private val antiKickSpeed by setting("Anti Kick Speed", 0.0622, 0.0..0.3, 0.001, { mode == FlightMode.PACKET && antiKick }) - private val antiKickDelay by setting("Anti Kick Delay", 14, 0..100, 1, { mode == FlightMode.PACKET && antiKick }, unit = " ticks") - private val hShrinkAmount by setting("Horizontal Shrink Amount", 4.0, 1.0..10.0, 0.1, { mode == FlightMode.PACKET }) - private val vShrinkAmount by setting("Vertical Shrink Amount", 2.70, 1.0..10.0, 0.1, { mode == FlightMode.PACKET }) private enum class FlightMode { PACKET, VANILLA, STATIC } + private enum class PacketType { + POSITIVE, NEGATIVE, STRICT + } + private enum class PacketMode { - POSITIVE, NEGATIVE + FAST, SETBACK } + private const val BASE_SPEED = .2873 + private const val CONCEAL_SPEED = .0624 + private const val SQRT_TWO_OVER_TWO = .707106781 + private const val ANTIKICK_AMOUNT = .03125 + + private val history = HashMap() + private val filter = ArrayList() + private var tpID = -1 + private var ticksEnabled = 0 + init { onDisable { runSafe { + tpID = -1 + ticksEnabled = 0 + player.noClip = false + player.capabilities?.apply { isFlying = false flySpeed = 0.05f @@ -57,53 +81,160 @@ object Flight : Module( } } - safeListener { + onEnable { + runSafeR { + val position = CPacketPlayer.Position(.0, .0, .0, true) + filter.add(position) + connection.sendPacket(position) + } ?: disable() + } + + safeListener { when (mode) { + // uses the same concepts as https://gist.github.com/Doogie13/aa04c6a8eb496c1afdb9c675e2ebd91c + // completely written from scratch, however FlightMode.PACKET -> { - it.cancel() + player.noClip = true - player.motionY = if (mc.gameSettings.keyBindJump.isKeyDown xor mc.gameSettings.keyBindSneak.isKeyDown) { - if (mc.gameSettings.keyBindJump.isKeyDown) { - if (player.ticksExisted % antiKickDelay == 0 && antiKick) { - -antiKickSpeed / vShrinkAmount - } else { - upSpeed / vShrinkAmount - } - } else (-upSpeed / vShrinkAmount) - } else { - if (MovementUtils.isInputting) { - val yaw = calcMoveYaw() - player.motionX = (-sin(yaw) * 0.2f * speed) / hShrinkAmount - player.motionZ = (cos(yaw) * 0.2f * speed) / hShrinkAmount - } - -glideSpeed / vShrinkAmount + // region Motion + val concealing = world.collidesWithAnyBlock(player.entityBoundingBox) || conceal + var motionY: Double + var up = 0 + + // we must use else if to allow phasing + if (mc.gameSettings.keyBindJump.isKeyDown) + up++ + else if (mc.gameSettings.keyBindSneak.isKeyDown) + up-- + + motionY = if (up == 0) + .0 + else + CONCEAL_SPEED * up.toDouble() + + var motionXZ: Double = if (!MovementUtils.isInputting) + .0 + else if (concealing) + CONCEAL_SPEED + else + BASE_SPEED + + if (motionY != .0 && motionXZ == BASE_SPEED) + motionY = .0 + + if (motionXZ == CONCEAL_SPEED && motionY == CONCEAL_SPEED) { + motionXZ *= SQRT_TWO_OVER_TWO + motionY *= SQRT_TWO_OVER_TWO } - val posX = player.posX + (player.motionX * hShrinkAmount) - val posY = player.posY + (player.motionY * vShrinkAmount) - val posZ = player.posZ + (player.motionZ * hShrinkAmount) + //endregion + + //region packets + + val calcFactor = + if (hypot(motionXZ, motionY) < .0625) + concealFactor + else + factor + + var factorInt = floor(calcFactor).toInt() + val diff = calcFactor - factorInt - val invalidPacketOffset = when (packetMode) { - PacketMode.POSITIVE -> 1000 - PacketMode.NEGATIVE -> -1000 + if (++ticksEnabled % 10 < diff * 10) + factorInt++ + + if (factorInt == 0) { + player.setVelocity(.0, .0, .0) + return@safeListener } - connection.sendPacket(CPacketPlayer.Position(posX, posY, posZ, false)) - connection.sendPacket(CPacketPlayer.Position(posX, player.posY + invalidPacketOffset, posZ, false)) - if (PacketManager.lastTeleportId != -1) { - connection.sendPacket(CPacketConfirmTeleport(PacketManager.lastTeleportId++)) + if (motionXZ == .0 && motionY == .0) + factorInt = 1 + + val yaw = calcMoveYaw() + + val baseX = -sin(yaw) * motionXZ + val baseY = motionY + val baseZ = cos(yaw) * motionXZ + + var currentX = baseX + var currentY = if (antiKick && ticksEnabled % 10 == 0) -ANTIKICK_AMOUNT else baseY + var currentZ = baseZ + + for (i in 1..factorInt) { + // should never happen + if (i > 10) + break + + val moveVec = Vec3d(currentX, currentY, currentZ) + + var yOffset: Double + + //region bounds + when (bounds) { + PacketType.STRICT -> { + var random = (Math.random() * 256) + 256 + + (random + player.posY > (if (player.dimension == -1) 127 else 255)) + random *= -1 + + yOffset = random + } + PacketType.POSITIVE -> { + yOffset = 1337.0 + } + PacketType.NEGATIVE -> { + yOffset = -1337.0 + } + } + //endregion + + //region sending + + val boundsPacket = CPacketPlayer.Position(player.posX + moveVec.x, player.posY + moveVec.y + yOffset, player.posZ + moveVec.z, true) + val movePacket = CPacketPlayer.Position(player.posX + moveVec.x, player.posY + moveVec.y, player.posZ + moveVec.z, true) + + filter.add(movePacket) + filter.add(boundsPacket) + + connection.sendPacket(movePacket) + connection.sendPacket(boundsPacket) + + history[++tpID] = moveVec.add(player.positionVector) + connection.sendPacket(CPacketConfirmTeleport(tpID)) + + currentX += baseX + currentY += baseY + currentZ += baseZ + + //endregion + } + + //endregion + + if (packetMode == PacketMode.FAST) + player.setVelocity(currentX - baseX, currentY - baseY, currentZ - baseZ) + else + player.setVelocity(.0, .0, .0) + } FlightMode.STATIC -> { - player.capabilities.isFlying = true - player.capabilities.flySpeed = speed + var up = 0 + + if (mc.gameSettings.keyBindJump.isKeyDown) up++ + + if (mc.gameSettings.keyBindSneak.isKeyDown) up-- - player.motionX = 0.0 - player.motionY = -glideSpeed - player.motionZ = 0.0 + player.motionY = if (up == 0) -glideSpeed else speed * up.toDouble() + + if (!MovementUtils.isInputting) + return@safeListener + + val yaw = calcMoveYaw() + player.motionX -= sin(yaw) * speed + player.motionZ += cos(yaw) * speed - if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY += speed / 2.0f - if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY -= speed / 2.0f } FlightMode.VANILLA -> { player.capabilities.isFlying = true @@ -125,15 +256,45 @@ object Flight : Module( safeListener { if (mode != FlightMode.PACKET) return@safeListener - when (it.packet) { + + when (val packet = it.packet) { is SPacketPlayerPosLook -> { - it.packet.playerPosLookYaw = player.rotationYaw - it.packet.playerPosLookPitch = player.rotationPitch + val id = packet.teleportId + + if (history.containsKey(packet.teleportId) && tpID != -1) { + history[id]?.let { vec -> + if (vec.x == packet.x && vec.y == packet.y && vec.z == packet.z) { + if (packetMode != PacketMode.SETBACK) + it.cancel() + + history.remove(id) + player.connection.sendPacket(CPacketConfirmTeleport(id)) + return@safeListener + } + } + } + + packet.playerPosLookYaw = player.rotationYaw + packet.playerPosLookPitch = player.rotationPitch + + player.connection.sendPacket(CPacketConfirmTeleport(id)) + + tpID = id } is SPacketCloseWindow -> { it.cancel() } } } + + safeListener { + if (mode != FlightMode.PACKET || it.packet !is CPacketPlayer) return@safeListener + + if (!filter.contains(it.packet)) + it.cancel() + else + filter.remove(it.packet) + + } } } From 64a8fb697e904f961b63348461556e553a8660ad Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Thu, 1 Dec 2022 20:50:00 -0500 Subject: [PATCH 37/85] Updated CustomChat description (#424) Changed add to adds, and removed the punctuation. --- .../kotlin/com/lambda/client/module/modules/chat/CustomChat.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/CustomChat.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/CustomChat.kt index 75032a3c1..50eadf448 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/CustomChat.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/CustomChat.kt @@ -9,7 +9,7 @@ import kotlin.math.min object CustomChat : Module( name = "CustomChat", - description = "Add a custom ending to your message!", + description = "Adds a custom ending to your message", category = Category.CHAT, showOnArray = false, modulePriority = 200 From 7d49e9014074e412ac13cb49c39debb121ef5c43 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Sun, 4 Dec 2022 19:02:25 -0500 Subject: [PATCH 38/85] Updated README (#427) Changed the title "Thanks to" to "Thanks to...". This makes more sense as there is a pause from reading the title to seeing the contributors list, and the other stuff, so it makes sense to put three dots to indicate the following will continue what is being communicated. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1a3eda74..505a07d6a 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Test if the environment is set up correctly by building the client and running i ### Stargazers [![Stargazers](https://starchart.cc/lambda-client/lambda.svg)](https://starchart.cc/lambda-client/lambda) -## Thanks to +## Thanks to... [![GitHub contributors](https://contrib.rocks/image?repo=lambda-client/lambda)](https://github.com/lambda-client/lambda/graphs/contributors) From 2746d6f96761019842a84463a9ec77977b2188ee Mon Sep 17 00:00:00 2001 From: nickcat325 <80810636+nickcat325@users.noreply.github.com> Date: Sun, 11 Dec 2022 18:06:43 -0600 Subject: [PATCH 39/85] Updated Baritone and ElytraFlight settings (#422) * Changed Baritone and efly Defaults * Changed "Up Pitch" to 30 --- .../lambda/client/module/modules/client/Baritone.kt | 2 -- .../client/module/modules/movement/ElytraFlight.kt | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt index e7f46d785..82b8ae7d8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt @@ -54,7 +54,6 @@ object Baritone : Module( private val blockReachDistance by setting("Reach Distance", 4.5f, 1.0f..10.0f, 0.5f, { page == Page.ADVANCED }, description = "Max distance baritone can place blocks.") private val enterPortals by setting("Enter Portals", true, { page == Page.ADVANCED }, description = "Baritone will walk all the way into the portal, instead of stopping one block before.") private val blockPlacementPenalty by setting("Block Placement Penalty", 20, 0..40, 5, { page == Page.ADVANCED }, description = "Decrease to make Baritone more often consider paths that would require placing blocks.") - private val blockBreakAdditionalPenalty by setting("Block Break Additional Penalty", 2, 0..10, 1, { page == Page.ADVANCED }, description = "Lower chance to break blocks. This is a tiebreaker.") private val jumpPenalty by setting("Jump Penalty", 2, 0..10, 1, { page == Page.ADVANCED }, description = "Additional penalty for hitting the space bar (ascend, pillar, or parkour) because it uses hunger.") private val assumeWalkOnWater by setting("Assume Walk On Water", false, { page == Page.ADVANCED }, description = "Allow Baritone to assume it can walk on still water just like any other block. Requires jesus to be enabled.") private val failureTimeout by setting("Fail Timeout", 2, 1..20, 1, { page == Page.ADVANCED }, unit = "s") @@ -127,7 +126,6 @@ object Baritone : Module( it.blockReachDistance.value = blockReachDistance it.enterPortal.value = enterPortals it.blockPlacementPenalty.value = blockPlacementPenalty.toDouble() - it.blockBreakAdditionalPenalty.value = blockBreakAdditionalPenalty.toDouble() it.jumpPenalty.value = jumpPenalty.toDouble() it.assumeWalkOnWater.value = assumeWalkOnWater it.failureTimeoutMS.value = failureTimeout * 1000L diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 0f0729530..d02e3d7b9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -48,7 +48,7 @@ object ElytraFlight : Module( private val easyTakeOff by setting("Easy Takeoff", true, { page == Page.GENERIC_SETTINGS }) private val timerControl by setting("Takeoff Timer", true, { easyTakeOff && page == Page.GENERIC_SETTINGS }) private val highPingOptimize by setting("High Ping Optimize", false, { easyTakeOff && page == Page.GENERIC_SETTINGS }) - private val minTakeoffHeight by setting("Min Takeoff Height", 0.5f, 0.0f..1.5f, 0.1f, { easyTakeOff && !highPingOptimize && page == Page.GENERIC_SETTINGS }) + private val minTakeoffHeight by setting("Min Takeoff Height", 1.2f, 0.0f..1.5f, 0.1f, { easyTakeOff && !highPingOptimize && page == Page.GENERIC_SETTINGS }) /* Acceleration */ private val accelerateStartSpeed by setting("Start Speed", 100, 0..100, 5, { mode.value != ElytraFlightMode.BOOST && mode.value != ElytraFlightMode.VANILLA && page == Page.GENERIC_SETTINGS }) @@ -68,8 +68,8 @@ object ElytraFlight : Module( /* Mode Settings */ /* Boost */ private val speedBoost by setting("Speed B", 1.0f, 0.0f..10.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS }) - private val upSpeedBoost by setting("Up Speed B", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS }) - private val downSpeedBoost by setting("Down Speed B", 1.0f, 1.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS }) + private val upSpeedBoost by setting("Up Speed B", 1.0f, 0.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS }) + private val downSpeedBoost by setting("Down Speed B", 1.0f, 0.0f..5.0f, 0.1f, { mode.value == ElytraFlightMode.BOOST && page == Page.MODE_SETTINGS }) /* Control */ private val boostPitchControl by setting("Base Boost Pitch", 20, 0..90, 5, { mode.value == ElytraFlightMode.CONTROL && page == Page.MODE_SETTINGS }) @@ -95,8 +95,8 @@ object ElytraFlight : Module( /* Vanilla */ - private val upPitch by setting("Up Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) - private val downPitch by setting("Down Pitch", 30f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val upPitch by setting("Up Pitch", 30f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val downPitch by setting("Down Pitch", 0f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) private val rocketPitch by setting("Rocket Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) /* End of Mode Settings */ From 609092810ef1571c9810461ac865204f63ae60b8 Mon Sep 17 00:00:00 2001 From: Blade <98755526+INotBLADE@users.noreply.github.com> Date: Mon, 12 Dec 2022 02:15:17 +0200 Subject: [PATCH 40/85] Update PacketCancel.kt (#428) --- .../lambda/client/module/modules/player/PacketCancel.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt index c6f4857d8..c490fc3b5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt @@ -46,7 +46,9 @@ object PacketCancel : Module( private val CPacketCustomPayloadSetting by setting("CPacketCustomPayload", false, { side == Side.CLIENT && categorySetting == CategorySlider.SYSTEM }) private val CPacketEnchantItemSetting by setting("CPacketEnchantItem", false, { side == Side.CLIENT && categorySetting == CategorySlider.INVENTORY }) private val CPacketEntityActionSetting by setting("CPacketEntityAction", false, { side == Side.CLIENT && categorySetting == CategorySlider.ENTITY }) - private val CPacketPlayerSetting by setting("CPacketPlayer", false, { side == Side.CLIENT && categorySetting == CategorySlider.PLAYER }) + private val CPacketPlayerPositionSetting by setting("CPacketPlayerPosition", false, { side == Side.CLIENT && categorySetting == CategorySlider.PLAYER }) + private val CPacketPlayerRotationSetting by setting("CPacketPlayerRotation", false, { side == Side.CLIENT && categorySetting == CategorySlider.PLAYER }) + private val CPacketPlayerPositionRotationSetting by setting("CPacketPlayerPositionRotation", false, { side == Side.CLIENT && categorySetting == CategorySlider.PLAYER }) private val CPacketHeldItemChangeSetting by setting("CPacketHeldItemChange", false, { side == Side.CLIENT && categorySetting == CategorySlider.INVENTORY }) private val CPacketInputSetting by setting("CPacketInput", false, { side == Side.CLIENT && categorySetting == CategorySlider.PLAYER }) private val CPacketPlaceRecipeSetting by setting("CPacketPlaceRecipe", false, { side == Side.CLIENT && categorySetting == CategorySlider.INVENTORY }) @@ -176,7 +178,9 @@ object PacketCancel : Module( is CPacketCustomPayload -> if (CPacketCustomPayloadSetting) it.cancel().also { numPackets++ } is CPacketEnchantItem -> if (CPacketEnchantItemSetting) it.cancel().also { numPackets++ } is CPacketEntityAction -> if (CPacketEntityActionSetting) it.cancel().also { numPackets++ } - is CPacketPlayer -> if (CPacketPlayerSetting) it.cancel().also { numPackets++ } + is CPacketPlayer.Position -> if (CPacketPlayerPositionSetting) it.cancel().also { numPackets++ } + is CPacketPlayer.Rotation -> if (CPacketPlayerRotationSetting) it.cancel().also { numPackets++ } + is CPacketPlayer.PositionRotation -> if (CPacketPlayerPositionRotationSetting) it.cancel().also { numPackets++ } is CPacketHeldItemChange -> if (CPacketHeldItemChangeSetting) it.cancel().also { numPackets++ } is CPacketInput -> if (CPacketInputSetting) it.cancel().also { numPackets++ } is CPacketPlaceRecipe -> if (CPacketPlaceRecipeSetting) it.cancel().also { numPackets++ } From f46bed48a8d08c2efabadaa5d24ed78c4a4e9211 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Sun, 11 Dec 2022 19:15:53 -0500 Subject: [PATCH 41/85] Updated TotemPopCounter description (#429) The module both counts and displays the count, so it makes more sense to say displays instead of counts. --- .../lambda/client/module/modules/combat/TotemPopCounter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 5d7c6acb8..94a761232 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -21,7 +21,7 @@ import java.util.* object TotemPopCounter : Module( name = "TotemPopCounter", - description = "Counts how many times players pop", + description = "Displays the number of times a player has popped", category = Category.COMBAT ) { private val countFriends by setting("Count Friends", true) @@ -120,4 +120,4 @@ object TotemPopCounter : Module( MessageSendHelper.sendChatMessage("$chatName $message") } } -} \ No newline at end of file +} From 8993ab9785e7240750664c6b2659808e541ffc8c Mon Sep 17 00:00:00 2001 From: Blade <98755526+INotBLADE@users.noreply.github.com> Date: Mon, 12 Dec 2022 02:16:56 +0200 Subject: [PATCH 42/85] Fix Cape equal check (#430) --- src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt b/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt index 5d2fd6b57..11d57a2c4 100644 --- a/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt +++ b/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt @@ -33,7 +33,7 @@ data class Cape( return this === other || other is Cape && other.capeUUID == capeUUID - && other.type == other.type + && other.type == type } override fun hashCode(): Int { From 0a80a68e707fb673e44036f942728a8fdc3a2461 Mon Sep 17 00:00:00 2001 From: Kamigen <46357922+Edouard127@users.noreply.github.com> Date: Sun, 11 Dec 2022 19:20:23 -0500 Subject: [PATCH 43/85] AntiSpam: Prevent heavy unicode & utf16/32 from lagging the game (#425) * lag prevent * Change to safeListener Co-authored-by: Constructor --- .../client/module/modules/chat/AntiSpam.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt index 4ce320f9f..b3a87ad1a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.chat import com.lambda.client.LambdaMod -import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.SpamFilters +import com.lambda.client.util.threads.safeListener import net.minecraft.util.text.TextComponentString import net.minecraftforge.client.event.ClientChatReceivedEvent import java.util.concurrent.ConcurrentHashMap @@ -32,6 +32,8 @@ object AntiSpam : Module( private val specialCharBegin = setting("Special Begin", true, { page == Page.TYPE }) private val greenText = setting("Green Text", false, { page == Page.TYPE }) private val fancyChat by setting("Fancy Chat", false, { page == Page.TYPE }) + private val lagMessage by setting("Lag Message", true, { page == Page.TYPE }) + private val thresholdLagMessage by setting("Threshold Lag", 256, 256..1024, 1, { page == Page.TYPE && lagMessage }) // Is 1024 the max? /* Page Two */ private val aggressiveFiltering by setting("Aggressive Filtering", true, { page == Page.SETTINGS }) @@ -82,8 +84,10 @@ object AntiSpam : Module( messageHistory.clear() } - listener { event -> - if (mc.player == null) return@listener + safeListener { event -> + if (lagMessage && isLagMessage(event.message.unformattedText)) { + event.isCanceled = true + } messageHistory.values.removeIf { System.currentTimeMillis() - it > 600000 } @@ -131,6 +135,16 @@ object AntiSpam : Module( } } + private fun isLagMessage(message: String): Boolean { + return if (!filterOwn && isOwn(message) + || !filterDMs && MessageDetection.Direct.ANY detect message + || !filterServer && MessageDetection.Server.ANY detect message) { + false + } else { + message.getBytes() > thresholdLagMessage + } + } + private fun detectSpam(message: String): String? { for ((key, value) in settingMap) { findPatterns(value, message)?.let { @@ -169,6 +183,9 @@ object AntiSpam : Module( return isDuplicate } + private fun String.getBytes(): Int { + return this.toByteArray().size + } private fun isOwn(message: String): Boolean { /* mc.player is null when the module is being registered, so this matcher isn't added alongside the other FilterPatterns */ From 9bb28029ce8845478fb5ab4dc4088e77217d53a1 Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Sun, 18 Dec 2022 11:49:25 -0500 Subject: [PATCH 44/85] Updated two module descriptions to make them clearer and more consice. (#437) * Updated the Chattimestamp module description. Updated the description to be slightly shorter, while making it grammatically correct, and more concise. * Updated module description with a single letter Saying draw in the sentence is not grammatically correct, rather saying draws is the correct context, as saying "the module draw lines" is not correct, but "the module draws lines" is. --- .../com/lambda/client/module/modules/chat/ChatTimestamp.kt | 2 +- .../com/lambda/client/module/modules/render/EyeFinder.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt index 7fec7004a..6ef069629 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt @@ -12,7 +12,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent object ChatTimestamp : Module( name = "ChatTimestamp", - description = "Shows the time a message was sent beside the message", + description = "Displays the time a message was sent beside it", category = Category.CHAT, showOnArray = false ) { diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt index 08ac70c8c..a971fdc2f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt @@ -21,7 +21,7 @@ import kotlin.math.min object EyeFinder : Module( name = "EyeFinder", - description = "Draw lines from entity's heads to where they are looking", + description = "Draws lines from entity's heads to where they are looking", category = Category.RENDER ) { private val page by setting("Page", Page.ENTITY_TYPE) @@ -131,4 +131,4 @@ object EyeFinder : Module( renderer.render(true) } } -} \ No newline at end of file +} From 84a5f3b826c40793b13c05a8d6b72e74de5eaa12 Mon Sep 17 00:00:00 2001 From: Blade <98755526+INotBLADE@users.noreply.github.com> Date: Sun, 18 Dec 2022 19:24:09 +0200 Subject: [PATCH 45/85] Velocity: NoBlockPush (#435) * Adding PushOutOfBlocksEvent * Add needed mixin for PushOutOfBlocksEvent * Add Block setting for NoPush * Block default setting off Co-authored-by: Constructor --- .../com/lambda/mixin/player/MixinEntityPlayerSP.java | 10 ++++++++++ .../lambda/client/event/events/PushOutOfBlocksEvent.kt | 5 +++++ .../lambda/client/module/modules/movement/Velocity.kt | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/event/events/PushOutOfBlocksEvent.kt diff --git a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java index 57e40faa7..683eaa206 100644 --- a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java @@ -3,6 +3,7 @@ import com.lambda.client.event.LambdaEventBus; import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent; import com.lambda.client.event.events.PlayerMoveEvent; +import com.lambda.client.event.events.PushOutOfBlocksEvent; import com.lambda.client.gui.mc.LambdaGuiBeacon; import com.lambda.client.manager.managers.MessageManager; import com.lambda.client.manager.managers.PlayerPacketManager; @@ -70,6 +71,15 @@ public void closeScreen(Minecraft minecraft, GuiScreen screen) { if (PortalChat.INSTANCE.isDisabled()) Wrapper.getMinecraft().displayGuiScreen(screen); } + @Inject(method = "pushOutOfBlocks", at = @At("HEAD"), cancellable = true) + private void onPushOutOfBlocks(CallbackInfoReturnable callbackInfoReturnable) { + PushOutOfBlocksEvent event = new PushOutOfBlocksEvent(); + LambdaEventBus.INSTANCE.post(event); + if (event.getCancelled()) { + callbackInfoReturnable.setReturnValue(false); + } + } + /** * @author TBM * Used with full permission from TBM - l1ving diff --git a/src/main/kotlin/com/lambda/client/event/events/PushOutOfBlocksEvent.kt b/src/main/kotlin/com/lambda/client/event/events/PushOutOfBlocksEvent.kt new file mode 100644 index 000000000..fb78968da --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/events/PushOutOfBlocksEvent.kt @@ -0,0 +1,5 @@ +package com.lambda.client.event.events + +import com.lambda.client.event.* + +class PushOutOfBlocksEvent : Event, ICancellable by Cancellable() diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt index e68232838..ad7c49538 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.movement import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.events.PushOutOfBlocksEvent import com.lambda.client.mixin.extension.* import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -31,6 +32,7 @@ object Velocity : Module( private val noPush by setting("No Push", true) private val entity by setting("Entity", true, { noPush }) private val liquid by setting("Liquid", true, { noPush }) + private val block by setting("Block", false, { noPush }) init { safeListener { @@ -57,6 +59,10 @@ object Velocity : Module( } } } + + safeListener { + if (block) it.cancel() + } } private val isZero get() = horizontal == 0.0f && vertical == 0.0f From f4f99ecef9e491963a551dbd044f70aaa89ecca7 Mon Sep 17 00:00:00 2001 From: Maarten <50550545+mmvanheusden@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:28:45 +0100 Subject: [PATCH 46/85] Expand Avoid with more features (renamed to Prevent) (#432) * Expand Avoid with more features * Renamed Avoid to Prevent * Added an option for dragon eggs, and void * Added mixin cancelling particles from spawning when clicking the egg * Fix typo --- .../mixin/world/MixinBlockDragonEgg.java | 21 ++++++++++ .../mixin/world/MixinGetCollisionBB.java | 11 +++--- .../client/module/modules/movement/Avoid.kt | 14 ------- .../client/module/modules/movement/Prevent.kt | 38 +++++++++++++++++++ src/main/resources/mixins.lambda.json | 1 + 5 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java delete mode 100644 src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt create mode 100644 src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt diff --git a/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java b/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java new file mode 100644 index 000000000..57eb5319d --- /dev/null +++ b/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java @@ -0,0 +1,21 @@ +package com.lambda.mixin.world; + +import com.lambda.client.module.modules.movement.Prevent; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BlockDragonEgg.class) +public class MixinBlockDragonEgg { + @Inject(method = "teleport", at = @At("HEAD"), cancellable = true) + public void onTeleport(World worldIn, BlockPos pos, CallbackInfo ci) { + // if prevent is enabled, and the dragon egg setting is toggled, cancel the "teleport" function, so no particles spawn + if (Prevent.INSTANCE.isEnabled() && Prevent.INSTANCE.getDragonEgg()) { + ci.cancel(); + } + } +} diff --git a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java index 2a9498ab5..e6eaabf8b 100644 --- a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java +++ b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java @@ -1,6 +1,6 @@ package com.lambda.mixin.world; -import com.lambda.client.module.modules.movement.Avoid; +import com.lambda.client.module.modules.movement.Prevent; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockCactus; @@ -23,11 +23,12 @@ public class MixinGetCollisionBB { @Inject(method = "getCollisionBoundingBox", at = @At("HEAD"), cancellable = true) private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable cir) { - if (mc.world != null && Avoid.INSTANCE.isEnabled()) { + if (mc.world != null && Prevent.INSTANCE.isEnabled()) { Block checkBlock = getBlock(pos); - if ((checkBlock.equals(Blocks.FIRE) && Avoid.INSTANCE.getFire()) || - (checkBlock.equals(Blocks.CACTUS) && Avoid.INSTANCE.getCactus()) || - ((!mc.world.isBlockLoaded(pos, false) || pos.getY() < 0) && Avoid.INSTANCE.getUnloaded())) { + if ((checkBlock.equals(Blocks.FIRE) && Prevent.INSTANCE.getFire()) || + (checkBlock.equals(Blocks.CACTUS) && Prevent.INSTANCE.getCactus()) || + (!mc.world.isBlockLoaded(pos, false) && Prevent.INSTANCE.getUnloaded()) || + (pos.getY() < 0 && Prevent.INSTANCE.getVoid())) { cir.cancel(); cir.setReturnValue(Block.FULL_BLOCK_AABB); } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt deleted file mode 100644 index 21a3ed55e..000000000 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.lambda.client.module.modules.movement - -import com.lambda.client.module.Category -import com.lambda.client.module.Module - -object Avoid : Module( - name = "Avoid", - description = "Prevents contact with certain objects", - category = Category.MOVEMENT -) { - val fire by setting("Fire", true) - val cactus by setting("Cactus", true) - val unloaded by setting("Unloaded Chunks", true) -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt new file mode 100644 index 000000000..c2218c7d8 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt @@ -0,0 +1,38 @@ +package com.lambda.client.module.modules.movement + +import com.lambda.client.event.events.PacketEvent +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.threads.safeListener +import net.minecraft.init.Blocks +import net.minecraft.network.play.client.CPacketPlayerDigging +import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock + +object Prevent : Module( + name = "Prevent", + description = "Prevents contact with certain objects", + category = Category.MOVEMENT +) { + val fire by setting("Fire", true, description = "Prevents you from touching fire by making the hitbox solid") + val cactus by setting("Cactus", true, description = "Prevents you from taking cactus damage by slightly expanding its hitbox") + val unloaded by setting("Unloaded Chunks", true, description = "Prevents you from entering unloaded chunks") + val void by setting("Void", true, description = "Prevents you from entering Y levels below zero") + val dragonEgg by setting("Dragon Egg", true, description = "Prevents you from teleporting dragon eggs") + + init { + safeListener { + if (dragonEgg) { + when (it.packet) { + is CPacketPlayerTryUseItemOnBlock -> { + if (world.getBlockState(it.packet.pos).block == Blocks.DRAGON_EGG) it.cancel() + } + + is CPacketPlayerDigging -> { + if (world.getBlockState(it.packet.position).block == Blocks.DRAGON_EGG) it.cancel() + } + } + } + + } + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index 08b385b45..a5b0880b3 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -75,6 +75,7 @@ "render.MixinViewFrustum", "render.MixinVisGraph", "world.MixinBlock", + "world.MixinBlockDragonEgg", "world.MixinBlockFluidRenderer", "world.MixinBlockLiquid", "world.MixinBlockModelRenderer", From 099b0ec9a682316a71a22e0f6d1e71a6b5199450 Mon Sep 17 00:00:00 2001 From: minecraft-simon <101961452+minecraft-simon@users.noreply.github.com> Date: Wed, 21 Dec 2022 20:26:25 +0100 Subject: [PATCH 47/85] Window resize handle indication and scroll fix (#441) * set rubberbanding speed default value to be equal to lambda 3.2.1 * added dots to the module window resize handles * restored scroll responsiveness * Remove the line that broke scrolling Co-authored-by: Constructor --- .../lambda/client/gui/AbstractLambdaGui.kt | 5 ++-- .../client/gui/clickgui/LambdaClickGui.kt | 2 +- .../gui/clickgui/component/PluginWindow.kt | 2 +- .../client/gui/rgui/windows/ListWindow.kt | 28 +++++++++++++++---- .../client/module/modules/client/ClickGUI.kt | 2 +- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt index 70333af61..55b77b2d6 100644 --- a/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt @@ -45,7 +45,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { // Mouse private var lastEventButton = -1 - private var lastClickPos = Vec2f(0.0f, 0.0f) + private var lastClickPos = Vec2f.ZERO // Searching protected var typedString = "" @@ -198,6 +198,7 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { } } + hoveredWindow?.onMouseInput(mousePos) super.handleMouseInput() updateSettingWindow() } @@ -284,8 +285,6 @@ abstract class AbstractLambdaGui, E : Any> : GuiScreen() { drawTypedString() GlStateUtils.depth(false) - - hoveredWindow?.onMouseInput(getRealMousePos()) } private fun drawBackground(vertexHelper: VertexHelper, partialTicks: Float) { diff --git a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt index 7de0eef7f..693c7f78e 100644 --- a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt @@ -41,7 +41,7 @@ object LambdaClickGui : AbstractLambdaGui() var posX = 0.0f Category.values().forEach { category -> - val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI) + val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI, drawHandle = true) windows.add(window) posX += 90.0f diff --git a/src/main/kotlin/com/lambda/client/gui/clickgui/component/PluginWindow.kt b/src/main/kotlin/com/lambda/client/gui/clickgui/component/PluginWindow.kt index 22cf83fcc..2db6ef8d8 100644 --- a/src/main/kotlin/com/lambda/client/gui/clickgui/component/PluginWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/clickgui/component/PluginWindow.kt @@ -6,7 +6,7 @@ class PluginWindow( cname: String, cPosX: Float, cPosY: Float, -) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI) { +) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI, drawHandle = true) { override val minHeight: Float get() = 100.0f } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt index 026f6045a..6917c5444 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt @@ -5,9 +5,13 @@ import com.lambda.client.gui.AbstractLambdaGui import com.lambda.client.gui.rgui.Component import com.lambda.client.gui.rgui.InteractiveComponent import com.lambda.client.module.modules.client.ClickGUI +import com.lambda.client.module.modules.client.CustomFont +import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.util.TickTimer +import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper +import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f import org.lwjgl.input.Mouse import org.lwjgl.opengl.GL11.* @@ -21,7 +25,8 @@ open class ListWindow( width: Float, height: Float, saveToConfig: SettingGroup, - vararg childrenIn: Component + vararg childrenIn: Component, + val drawHandle: Boolean = false ) : TitledWindow(name, posX, posY, width, height, saveToConfig) { val children = ArrayList() @@ -147,6 +152,17 @@ open class ListWindow( override fun onRender(vertexHelper: VertexHelper, absolutePos: Vec2f) { super.onRender(vertexHelper, absolutePos) + if (drawHandle) { + val handleText = "....." + val scale = 0.75f + val posX = renderWidth / 2 - FontRenderAdapter.getStringWidth(handleText, scale) / 2 + val posY = renderHeight - 5 - FontRenderAdapter.getFontHeight(scale) / 2 + val color = with(GuiColors.text) { + ColorHolder(r, g, b, (a * 0.6f).toInt()) + } + FontRenderAdapter.drawString(handleText, posX, posY, CustomFont.shadow, color, scale) + } + synchronized(this) { renderChildren { it.onRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress)) @@ -171,14 +187,15 @@ open class ListWindow( ((renderPosX + ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(), mc.displayHeight - ((renderPosY + renderHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt(), ((renderWidth - ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(), - ((renderHeight - draggableHeight - ClickGUI.resizeBar)* ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0) + ((renderHeight - draggableHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0) ) glEnable(GL_SCISSOR_TEST) glTranslatef(0.0f, -renderScrollProgress, 0.0f) - children.filter { it.visible - && it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight - && it.renderPosY - renderScrollProgress < renderHeight + children.filter { + it.visible + && it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight + && it.renderPosY - renderScrollProgress < renderHeight }.forEach { glPushMatrix() glTranslatef(it.renderPosX, it.renderPosY, 0.0f) @@ -211,7 +228,6 @@ open class ListWindow( || relativeMousePos.x < ClickGUI.horizontalMargin || relativeMousePos.x > renderWidth - ClickGUI.horizontalMargin ) null - else children.firstOrNull { it.visible && relativeMousePos.y in it.posY..it.posY + it.height } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt index 3705939aa..17f97fea7 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt @@ -32,7 +32,7 @@ object ClickGUI : Module( val fadeInTime by setting("Fade In Time", 0.25f, 0.0f..1.0f, 0.05f, unit = "s") val fadeOutTime by setting("Fade Out Time", 0.1f, 0.0f..1.0f, 0.05f, unit = "s") val scrollRubberband by setting("Scroll Rubberband", false) - val scrollRubberbandSpeed by setting("Scroll Rubberband Speed", 0.5f, 0.01f..1.0f, 0.05f, { scrollRubberband }) + val scrollRubberbandSpeed by setting("Scroll Rubberband Speed", 0.25f, 0.01f..1.0f, 0.05f, { scrollRubberband }) val showModifiedInBold by setting("Show Modified In Bold", false, description = "Display modified settings in a bold font") private val resetComponents = setting("Reset Positions", false) private val resetScale = setting("Reset Scale", false) From 272172a1e15a6210dd83673002b6946bda7fddc9 Mon Sep 17 00:00:00 2001 From: minecraft-simon <101961452+minecraft-simon@users.noreply.github.com> Date: Wed, 21 Dec 2022 22:42:33 +0100 Subject: [PATCH 48/85] Fixed problems with locked plugin-jars on windows (#439) --- src/main/kotlin/com/lambda/client/LambdaCoreMod.kt | 2 +- .../kotlin/com/lambda/client/plugin/PluginError.kt | 14 +++++++++++++- .../com/lambda/client/plugin/PluginManager.kt | 10 ++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/LambdaCoreMod.kt b/src/main/kotlin/com/lambda/client/LambdaCoreMod.kt index a5468f79b..29de461cb 100644 --- a/src/main/kotlin/com/lambda/client/LambdaCoreMod.kt +++ b/src/main/kotlin/com/lambda/client/LambdaCoreMod.kt @@ -34,7 +34,7 @@ class LambdaCoreMod : IFMLLoadingPlugin { MixinBootstrap.init() Mixins.addConfigurations("mixins.lambda.json", "mixins.baritone.json") - PluginManager.getLoaders() + PluginManager.checkPluginLoaders(PluginManager.getLoaders()) .filter { it.info.mixins.isNotEmpty() } .forEach { logger.info("Initialised mixins of ${it.info.name}.") diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginError.kt b/src/main/kotlin/com/lambda/client/plugin/PluginError.kt index 995099e3c..7c1638021 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginError.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginError.kt @@ -7,6 +7,7 @@ import java.io.File internal enum class PluginError { HOT_RELOAD, DUPLICATE, + DEPRECATED, UNSUPPORTED, REQUIRED_PLUGIN, OUTDATED_PLUGIN, @@ -23,6 +24,9 @@ internal enum class PluginError { DUPLICATE -> { log("Duplicate plugin $loader.") } + DEPRECATED -> { + log("Plugin $loader is deprecated due to the presence of a newer version: $message") + } UNSUPPORTED -> { log("Unsupported plugin $loader. Minimum required Lambda version: ${loader.info.minApiVersion}") } @@ -46,7 +50,15 @@ internal enum class PluginError { } } - loader.file.renameTo(File("${loader.file.path}.disabled")) + // append .disabled to the file name + // if a file with the same name exists, append a number to the end + var disabledFile = File("${loader.file.path}.disabled") + var i = 1 + while (disabledFile.exists()) { + disabledFile = File("${loader.file.path}.disabled$i") + i++ + } + loader.file.renameTo(disabledFile) } fun log(message: String?, throwable: Throwable? = null) { diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt index 19c65c3d1..739d074f0 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt @@ -9,10 +9,12 @@ import com.lambda.client.plugin.api.Plugin import com.lambda.client.util.FolderUtils import com.lambda.client.util.text.MessageSendHelper import kotlinx.coroutines.Deferred +import net.minecraft.launchwrapper.Launch import net.minecraft.util.text.TextFormatting import org.apache.maven.artifact.versioning.DefaultArtifactVersion import java.io.File import java.io.FileNotFoundException +import java.util.jar.JarFile internal object PluginManager : AsyncLoader> { override var deferred: Deferred>? = null @@ -79,6 +81,8 @@ internal object PluginManager : AsyncLoader> { invalids.add(loader) } + if (invalids.contains(loader)) continue + // Duplicate check if (loadedPluginLoader.contains(loader)) { loadedPlugins.firstOrNull { loader.name == it.name }?.let { plugin -> @@ -107,11 +111,15 @@ internal object PluginManager : AsyncLoader> { PluginError.DUPLICATE.handleError(it) invalids.add(it) } + nowVersion > thenVersion -> { upgradeLoader = true + PluginError.DEPRECATED.handleError(it, loader.toString()) invalids.add(it) } + else -> { + PluginError.DEPRECATED.handleError(loader, it.toString()) invalids.add(loader) } } @@ -162,9 +170,11 @@ internal object PluginManager : AsyncLoader> { is ClassNotFoundException -> { PluginError.CLASS_NOT_FOUND.handleError(loader, throwable = it) } + is IllegalAccessException -> { PluginError.ILLEGAL_ACCESS.handleError(loader, throwable = it) } + else -> { PluginError.OTHERS.handleError(loader, throwable = it) } From 577397910defd2620294a2805ec6257c03b8ca35 Mon Sep 17 00:00:00 2001 From: minecraft-simon <101961452+minecraft-simon@users.noreply.github.com> Date: Thu, 29 Dec 2022 01:03:09 +0100 Subject: [PATCH 49/85] Improved packet logging for entity movement and player list (#444) * added option to ignore player position * added logging of entityID for entity moving packets * added SPacketPlayerListItem to packet logger * added SPacketSpawnPlayer to packet logger --- .../network/AccessorSPacketEntity.java | 17 +++ .../AccessorSPacketEntityHeadLook.java | 16 +++ .../lambda/client/mixin/extension/Network.kt | 17 ++- .../module/modules/player/PacketLogger.kt | 133 +++++++++++++----- src/main/resources/mixins.lambda.json | 2 + 5 files changed, 147 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntity.java create mode 100644 src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntityHeadLook.java diff --git a/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntity.java b/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntity.java new file mode 100644 index 000000000..890f5a951 --- /dev/null +++ b/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntity.java @@ -0,0 +1,17 @@ +package com.lambda.mixin.accessor.network; + +import net.minecraft.network.play.server.SPacketEntity; +import net.minecraft.network.play.server.SPacketEntityVelocity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SPacketEntity.class) +public interface AccessorSPacketEntity { + + @Accessor("entityId") + int getEntityId(); + + @Accessor("entityId") + void setEntityId(int value); + +} diff --git a/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntityHeadLook.java b/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntityHeadLook.java new file mode 100644 index 000000000..109341907 --- /dev/null +++ b/src/main/java/com/lambda/mixin/accessor/network/AccessorSPacketEntityHeadLook.java @@ -0,0 +1,16 @@ +package com.lambda.mixin.accessor.network; + +import net.minecraft.network.play.server.SPacketEntityHeadLook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SPacketEntityHeadLook.class) +public interface AccessorSPacketEntityHeadLook { + + @Accessor("entityId") + int getEntityId(); + + @Accessor("entityId") + void setEntityId(int value); + +} diff --git a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt index ac73b536d..b03bccdc3 100644 --- a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt +++ b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt @@ -5,10 +5,7 @@ import net.minecraft.network.play.client.CPacketChatMessage import net.minecraft.network.play.client.CPacketCloseWindow import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.network.play.client.CPacketUseEntity -import net.minecraft.network.play.server.SPacketChat -import net.minecraft.network.play.server.SPacketEntityVelocity -import net.minecraft.network.play.server.SPacketExplosion -import net.minecraft.network.play.server.SPacketPlayerPosLook +import net.minecraft.network.play.server.* import net.minecraft.util.text.ITextComponent var CPacketChatMessage.chatMessage: String @@ -113,4 +110,16 @@ var SPacketPlayerPosLook.playerPosLookPitch: Float get() = this.pitch set(value) { (this as AccessorSPacketPosLook).setPitch(value) + } + +var SPacketEntity.entityId: Int + get() = (this as AccessorSPacketEntity).entityId + set(value) { + (this as AccessorSPacketEntity).entityId = value + } + +var SPacketEntityHeadLook.entityHeadLookEntityId: Int + get() = (this as AccessorSPacketEntityHeadLook).entityId + set(value) { + (this as AccessorSPacketEntityHeadLook).entityId = value } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt index 29b484993..cbe6f3f9b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt @@ -8,7 +8,6 @@ import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.* import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.misc.MapDownloader.setting import com.lambda.client.util.FolderUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit @@ -43,6 +42,8 @@ object PacketLogger : Module( private val ignoreUnknown by setting("Ignore Unknown Packets", false, description = "Ignore packets that aren't explicitly handled.") private val ignoreChat by setting("Ignore Chat", true, description = "Ignore chat packets.") private val ignoreCancelled by setting("Ignore Cancelled", true, description = "Ignore cancelled packets.") + private val ignorePlayerPosition by setting("Ignore Player Position", false, description = "Ignore sent position & rotation packets.") + private val ignoreTimeUpdates by setting("Ignore Time Updates", false, description = "Ignore time update packets.") private val openLogFolder by setting("Open Log Folder...", false, consumer = { _, _ -> FolderUtils.openFolder(FolderUtils.packetLogFolder) true @@ -308,8 +309,39 @@ object PacketLogger : Module( "isSoundServerwide" to packet.isSoundServerwide } } + is SPacketEntity.S15PacketEntityRelMove -> { + logServer(packet) { + "entityId" to packet.entityId + "x" to packet.x + "y" to packet.y + "z" to packet.z + "onGround" to packet.onGround + } + } + is SPacketEntity.S16PacketEntityLook -> { + logServer(packet) { + "entityId" to packet.entityId + "yaw" to packet.yaw + "pitch" to packet.pitch + "isRotating" to packet.isRotating + "onGround" to packet.onGround + } + } + is SPacketEntity.S17PacketEntityLookMove -> { + logServer(packet) { + "entityId" to packet.entityId + "x" to packet.x + "y" to packet.y + "z" to packet.z + "yaw" to packet.yaw + "pitch" to packet.pitch + "isRotating" to packet.isRotating + "onGround" to packet.onGround + } + } is SPacketEntity -> { logServer(packet) { + "entityId" to packet.entityId "x" to packet.x "y" to packet.y "z" to packet.z @@ -344,6 +376,7 @@ object PacketLogger : Module( } is SPacketEntityHeadLook -> { logServer(packet) { + "entityId" to packet.entityHeadLookEntityId "yaw" to packet.yaw } } @@ -378,12 +411,12 @@ object PacketLogger : Module( } is SPacketEntityTeleport -> { logServer(packet) { + "entityID" to packet.entityId "x" to packet.x "y" to packet.y "z" to packet.z "yaw" to packet.yaw "pitch" to packet.pitch - "entityID" to packet.entityId } } is SPacketEntityVelocity -> { @@ -517,6 +550,28 @@ object PacketLogger : Module( } } } + is SPacketPlayerListItem -> { + logServer(packet) { + "action" to packet.action.name + "entries" to buildString { + for (entry in packet.entries) { + append("> displayName: ") + append(entry.displayName) + append(" gameMode: ") + append(entry.gameMode?.name) + append(" ping: ") + append(entry.ping) + append(" profile.id: ") + append(entry.profile?.id) + append(" profile.name: ") + append(entry.profile?.name) + append(" profile.properties: ") + append(entry.profile?.properties) + append(' ') + } + } + } + } is SPacketSoundEffect -> { logServer(packet) { "sound" to packet.sound.soundName @@ -534,6 +589,17 @@ object PacketLogger : Module( "data" to packet.data } } + is SPacketSpawnPlayer -> { + logServer(packet) { + "entityID" to packet.entityID + "uniqueID" to packet.uniqueId + "x" to packet.x + "y" to packet.y + "z" to packet.z + "yaw" to packet.yaw + "pitch" to packet.pitch + } + } is SPacketTeams -> { logServer(packet) { "action" to packet.action @@ -542,9 +608,11 @@ object PacketLogger : Module( } } is SPacketTimeUpdate -> { - logServer(packet) { - "totalWorldTime" to packet.totalWorldTime - "worldTime" to packet.worldTime + if (!ignoreTimeUpdates) { + logServer(packet) { + "totalWorldTime" to packet.totalWorldTime + "worldTime" to packet.worldTime + } } } is SPacketUnloadChunk -> { @@ -581,17 +649,6 @@ object PacketLogger : Module( "windowId" to packet.windowId } } - is SPacketEntity.S15PacketEntityRelMove -> { - logServer(packet) { - "x" to packet.x - "y" to packet.y - "z" to packet.z - "yaw" to packet.yaw - "pitch" to packet.pitch - "isRotating" to packet.isRotating - "onGround" to packet.onGround - } - } else -> { if (!ignoreUnknown) { logServer(packet) { @@ -652,33 +709,41 @@ object PacketLogger : Module( } } is CPacketPlayer.Rotation -> { - logClient(packet) { - "yaw" to packet.playerYaw - "pitch" to packet.playerPitch - "onGround" to packet.isOnGround + if (!ignorePlayerPosition) { + logClient(packet) { + "yaw" to packet.playerYaw + "pitch" to packet.playerPitch + "onGround" to packet.isOnGround + } } } is CPacketPlayer.Position -> { - logClient(packet) { - "x" to packet.playerX - "y" to packet.playerY - "z" to packet.playerZ - "onGround" to packet.isOnGround + if (!ignorePlayerPosition) { + logClient(packet) { + "x" to packet.playerX + "y" to packet.playerY + "z" to packet.playerZ + "onGround" to packet.isOnGround + } } } is CPacketPlayer.PositionRotation -> { - logClient(packet) { - "x" to packet.playerX - "y" to packet.playerY - "z" to packet.playerZ - "yaw" to packet.playerYaw - "pitch" to packet.playerPitch - "onGround" to packet.isOnGround + if (!ignorePlayerPosition) { + logClient(packet) { + "x" to packet.playerX + "y" to packet.playerY + "z" to packet.playerZ + "yaw" to packet.playerYaw + "pitch" to packet.playerPitch + "onGround" to packet.isOnGround + } } } is CPacketPlayer -> { - logClient(packet) { - "onGround" to packet.isOnGround + if (!ignorePlayerPosition) { + logClient(packet) { + "onGround" to packet.isOnGround + } } } is CPacketPlayerDigging -> { diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index a5b0880b3..2ea5d021b 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -27,6 +27,8 @@ "accessor.network.AccessorSPacketEntityVelocity", "accessor.network.AccessorSPacketExplosion", "accessor.network.AccessorSPacketPosLook", + "accessor.network.AccessorSPacketEntity", + "accessor.network.AccessorSPacketEntityHeadLook", "accessor.player.AccessorEntityPlayerSP", "accessor.player.AccessorPlayerControllerMP", "accessor.render.AccessorRenderGlobal", From d34311f5ccc5c87dbe935c558b11ec1c0c6de370 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sat, 31 Dec 2022 03:34:30 +0100 Subject: [PATCH 50/85] Fix empty hud elements --- .../kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt index 56f721f0e..486c7655e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt @@ -2,6 +2,7 @@ package com.lambda.client.gui.hudgui import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.SafeClientEvent +import com.lambda.client.module.modules.client.HudEditor import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.TextComponent @@ -29,6 +30,8 @@ abstract class AbstractLabelHud( if (it.phase != TickEvent.Phase.END) return@safeAsyncListener displayText.clear() updateText() + + if (displayText.isEmpty() && HudEditor.isEnabled) displayText.addLine(name, primaryColor) } } From c819baab238009a4fc19b9d1ca366fba5cd7f1d2 Mon Sep 17 00:00:00 2001 From: RewardedIvan <67065165+RewardedIvan@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:22:54 -0800 Subject: [PATCH 51/85] Update github workflow status (#446) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 505a07d6a..f2519ac38 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![GitHub all releases](https://img.shields.io/github/downloads/lambda-client/lambda/total?color=seagreen) ![CodeFactor grade](https://img.shields.io/codefactor/grade/github/lambda-client/lambda?color=royalblue) -![GitHub workflow status](https://img.shields.io/github/workflow/status/lambda-client/lambda/gradle_build?logo=gradle) +![GitHub workflow status](https://img.shields.io/github/actions/workflow/status/lambda-client/lambda/nightly_build.yml?branch=master&logo=gradle) [![Discord](https://img.shields.io/discord/834570721070022687?color=skyblue&logo=discord&logoColor=white)](https://discord.gg/QjfBxJzE5x) ![GitHub repo size](https://img.shields.io/github/repo-size/lambda-client/lambda) ![Lines of code](https://img.shields.io/tokei/lines/github/lambda-client/lambda?color=lightcoral&label=lines%20of%20code) From c6cc08b81fdd295b0811e3e45f9c66252fc66f5d Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 8 Jan 2023 08:50:16 -0800 Subject: [PATCH 52/85] ChestStealer Rusherhack compat (#447) * ChestStealer Rusherhack compat * Reduce nesting and this calls Co-authored-by: Constructor --- .../lambda/mixin/gui/MixinGuiContainer.java | 50 ++++++++++--------- .../module/modules/player/ChestStealer.kt | 16 ++---- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiContainer.java b/src/main/java/com/lambda/mixin/gui/MixinGuiContainer.java index de1f01712..d3b7b938f 100644 --- a/src/main/java/com/lambda/mixin/gui/MixinGuiContainer.java +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiContainer.java @@ -12,43 +12,45 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.io.IOException; - @Mixin(GuiContainer.class) public class MixinGuiContainer extends GuiScreen { @Shadow protected int guiLeft; @Shadow protected int guiTop; @Shadow protected int xSize; + private final GuiButton stealButton = new LambdaGuiStealButton(guiLeft + xSize + 2, guiTop + 2); + private final GuiButton storeButton = new LambdaGuiStoreButton(guiLeft + xSize + 2, guiTop + 4 + stealButton.height); - private final GuiButton stealButton = new LambdaGuiStealButton(this.guiLeft + this.xSize + 2, this.guiTop + 2); - private final GuiButton storeButton = new LambdaGuiStoreButton(this.guiLeft + this.xSize + 2, this.guiTop + 4 + stealButton.height); - - @Inject(method = "initGui", at = @At("HEAD")) - public void initGui(CallbackInfo ci) { - if (ChestStealer.INSTANCE.isValidGui()) { - this.buttonList.add(stealButton); - this.buttonList.add(storeButton); - ChestStealer.updateButton(stealButton, this.guiLeft, this.xSize, this.guiTop); - ChestStealer.updateButton(storeButton, this.guiLeft, this.xSize, this.guiTop); - } - } + @Inject(method = "mouseClicked", at = @At("TAIL")) + public void mouseClicked(int x, int y, int button, CallbackInfo ci) { + if (button != 0) return; - @Override - protected void actionPerformed(GuiButton button) throws IOException { - if (button.id == 696969) { - ChestStealer.INSTANCE.setStealing(!ChestStealer.INSTANCE.getStealing()); - } else if (button.id == 420420) { + if (storeButton.mousePressed(mc, x, y)) { ChestStealer.INSTANCE.setStoring(!ChestStealer.INSTANCE.getStoring()); - } else { - super.actionPerformed(button); + } else if (stealButton.mousePressed(mc, x, y)) { + ChestStealer.INSTANCE.setStealing(!ChestStealer.INSTANCE.getStealing()); } } - @Inject(method = "updateScreen", at = @At("HEAD")) + @Inject(method = "updateScreen", at = @At("TAIL")) public void updateScreen(CallbackInfo ci) { - ChestStealer.updateButton(stealButton, this.guiLeft, this.xSize, this.guiTop); - ChestStealer.updateButton(storeButton, this.guiLeft, this.xSize, this.guiTop); + if (!ChestStealer.INSTANCE.isValidGui()) return; + + if (ChestStealer.INSTANCE.isDisabled()) { + buttonList.remove(storeButton); + buttonList.remove(storeButton); + return; + } + + if (!buttonList.contains(stealButton)) { + buttonList.add(stealButton); + } + if (!buttonList.contains(storeButton)) { + buttonList.add(storeButton); + } + + ChestStealer.updateButton(stealButton, guiLeft, xSize, guiTop); + ChestStealer.updateButton(storeButton, guiLeft, xSize, guiTop); } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt index f7834216e..404e62dba 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt @@ -89,29 +89,21 @@ object ChestStealer : Module( runSafe { if (isEnabled && isContainerOpen()) { if (button.id == 696969) { - val str = if (stealing) { - "Stop" - } else { - "Steal" - } + val name = if (stealing) "Stop" else "Steal" button.x = left + size + 2 button.y = top + 2 button.enabled = canSteal() and !storing button.visible = true - button.displayString = str + button.displayString = name } else if (button.id == 420420) { - val str = if (storing) { - "Stop" - } else { - "Store" - } + val name = if (storing) "Stop" else "Store" button.x = left + size + 2 button.y = top + 24 button.enabled = canStore() and !stealing button.visible = true - button.displayString = str + button.displayString = name } } else { button.visible = false From aede6c7f80ca5c87e0a87aa98bf6e317855ebcbf Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Sun, 8 Jan 2023 17:23:06 +0000 Subject: [PATCH 53/85] Added Criticals -> Edit mode (#442) * Added Criticals -> Edit mode for 2b2t * Cleanup Co-authored-by: Constructor --- .../network/AccessorCPacketPlayer.java | 6 ++ .../player/AccessorEntityPlayerSP.java | 3 + .../mixin/player/MixinEntityPlayerSP.java | 5 ++ .../events/CriticalsUpdateWalkingEvent.kt | 9 +++ .../events/OnUpdateWalkingPlayerEvent.kt | 1 - .../lambda/client/mixin/extension/Network.kt | 24 +++++- .../client/module/modules/combat/Criticals.kt | 75 ++++++++++++++----- 7 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/event/events/CriticalsUpdateWalkingEvent.kt diff --git a/src/main/java/com/lambda/mixin/accessor/network/AccessorCPacketPlayer.java b/src/main/java/com/lambda/mixin/accessor/network/AccessorCPacketPlayer.java index cb9d01d6d..bce8f2e7e 100644 --- a/src/main/java/com/lambda/mixin/accessor/network/AccessorCPacketPlayer.java +++ b/src/main/java/com/lambda/mixin/accessor/network/AccessorCPacketPlayer.java @@ -28,7 +28,13 @@ public interface AccessorCPacketPlayer { @Accessor("moving") boolean getMoving(); + @Accessor("moving") + void setMoving(boolean value); + @Accessor("rotating") boolean getRotating(); + @Accessor("rotating") + void setRotating(boolean value); + } diff --git a/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java b/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java index 9d1e069de..aef8cb6ba 100644 --- a/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/accessor/player/AccessorEntityPlayerSP.java @@ -10,4 +10,7 @@ public interface AccessorEntityPlayerSP { @Accessor("handActive") void kbSetHandActive(boolean value); + @Accessor("lastReportedPosY") + void lcSetLastReportedPosY(double value); + } diff --git a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java index 683eaa206..488b10976 100644 --- a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java @@ -1,6 +1,7 @@ package com.lambda.mixin.player; import com.lambda.client.event.LambdaEventBus; +import com.lambda.client.event.events.CriticalsUpdateWalkingEvent; import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent; import com.lambda.client.event.events.PlayerMoveEvent; import com.lambda.client.event.events.PushOutOfBlocksEvent; @@ -150,6 +151,10 @@ private void onUpdateInvokeOnUpdateWalkingPlayer(CallbackInfo ci) { @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) private void onUpdateWalkingPlayerHead(CallbackInfo ci) { + + CriticalsUpdateWalkingEvent criticalsEditEvent = new CriticalsUpdateWalkingEvent(); + LambdaEventBus.INSTANCE.post(criticalsEditEvent); + // Setup flags Vec3d position = new Vec3d(this.posX, this.getEntityBoundingBox().minY, this.posZ); Vec2f rotation = new Vec2f(this.rotationYaw, this.rotationPitch); diff --git a/src/main/kotlin/com/lambda/client/event/events/CriticalsUpdateWalkingEvent.kt b/src/main/kotlin/com/lambda/client/event/events/CriticalsUpdateWalkingEvent.kt new file mode 100644 index 000000000..54d7d4422 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/events/CriticalsUpdateWalkingEvent.kt @@ -0,0 +1,9 @@ +package com.lambda.client.event.events + +import com.lambda.client.event.Event + +/** + * @author Doogie13 + * @since 20/12/2022 + */ +class CriticalsUpdateWalkingEvent : Event \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt index 7c6d782dd..d28ea0d05 100644 --- a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt @@ -22,7 +22,6 @@ class OnUpdateWalkingPlayerEvent private constructor( var moving = moving @JvmName("isMoving") get - private set var rotating = rotating @JvmName("isRotating") get diff --git a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt index b03bccdc3..bc3b843a5 100644 --- a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt +++ b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt @@ -23,33 +23,48 @@ var CPacketPlayer.playerX: Double set(value) { (this as AccessorCPacketPlayer).setX(value) } + var CPacketPlayer.playerY: Double get() = this.getY(0.0) set(value) { (this as AccessorCPacketPlayer).setY(value) } + var CPacketPlayer.playerZ: Double get() = this.getZ(0.0) set(value) { (this as AccessorCPacketPlayer).setZ(value) } + var CPacketPlayer.playerYaw: Float get() = this.getYaw(0.0f) set(value) { (this as AccessorCPacketPlayer).setYaw(value) } + var CPacketPlayer.playerPitch: Float get() = this.getPitch(0.0f) set(value) { (this as AccessorCPacketPlayer).setPitch(value) } + var CPacketPlayer.playerIsOnGround: Boolean get() = this.isOnGround set(value) { (this as AccessorCPacketPlayer).setOnGround(value) } -val CPacketPlayer.playerMoving: Boolean get() = (this as AccessorCPacketPlayer).moving -val CPacketPlayer.playerRotating: Boolean get() = (this as AccessorCPacketPlayer).rotating + +var CPacketPlayer.playerMoving: Boolean + get() = (this as AccessorCPacketPlayer).moving + set(value) { + (this as AccessorCPacketPlayer).moving = value + } + +var CPacketPlayer.playerRotating: Boolean + get() = (this as AccessorCPacketPlayer).rotating + set(value) { + (this as AccessorCPacketPlayer).rotating = value + } var CPacketUseEntity.useEntityId: Int get() = (this as AccessorCPacketUseEntity).id @@ -74,11 +89,13 @@ var SPacketEntityVelocity.entityVelocityMotionX: Int set(value) { (this as AccessorSPacketEntityVelocity).setMotionX(value) } + var SPacketEntityVelocity.entityVelocityMotionY: Int get() = this.motionY set(value) { (this as AccessorSPacketEntityVelocity).setMotionY(value) } + var SPacketEntityVelocity.entityVelocityMotionZ: Int get() = this.motionZ set(value) { @@ -90,11 +107,13 @@ var SPacketExplosion.explosionMotionX: Float set(value) { (this as AccessorSPacketExplosion).setMotionX(value) } + var SPacketExplosion.explosionMotionY: Float get() = this.motionY set(value) { (this as AccessorSPacketExplosion).setMotionY(value) } + var SPacketExplosion.explosionMotionZ: Float get() = this.motionZ set(value) { @@ -106,6 +125,7 @@ var SPacketPlayerPosLook.playerPosLookYaw: Float set(value) { (this as AccessorSPacketPosLook).setYaw(value) } + var SPacketPlayerPosLook.playerPosLookPitch: Float get() = this.pitch set(value) { diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt index 117ded8d5..d1b8473ae 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt @@ -2,14 +2,18 @@ package com.lambda.client.module.modules.combat import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.SafeClientEvent +import com.lambda.client.event.events.CriticalsUpdateWalkingEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerAttackEvent -import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.isInWeb +import com.lambda.client.mixin.extension.playerIsOnGround +import com.lambda.client.mixin.extension.playerMoving +import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.init.MobEffects @@ -25,19 +29,20 @@ object Criticals : Module( description = "Always do critical attacks", category = Category.COMBAT ) { - private val mode by setting("Mode", Mode.PACKET) + private val mode by setting("Mode", Mode.EDIT) private val jumpMotion by setting("Jump Motion", 0.25, 0.1..0.5, 0.01, { mode == Mode.MINI_JUMP }, fineStep = 0.001) - private val attackFallDistance by setting("Attack Fall Distance", 0.1, 0.05..1.0, 0.05, { mode != Mode.PACKET }) + private val attackFallDistance by setting("Attack Fall Distance", 0.1, 0.05..1.0, 0.05, { mode == Mode.MINI_JUMP || mode == Mode.JUMP }) private enum class Mode(override val displayName: String) : DisplayEnum { PACKET("Packet"), + EDIT("Edit"), JUMP("Jump"), MINI_JUMP("Mini Jump") } private var delayTick = -1 private var target: Entity? = null - private var attacking = false + private var spoofedY = -1337.0 override fun isActive(): Boolean { return isEnabled && !delaying() @@ -52,23 +57,54 @@ object Criticals : Module( reset() } - listener { - if (it.packet is CPacketAnimation && mode != Mode.PACKET && delayTick > -1) { + safeListener { + if (mode != Mode.EDIT) return@safeListener + + // we need to ensure we are always sending packets as not to flag NCP for fight.critical + (player as AccessorEntityPlayerSP).lcSetLastReportedPosY(-1337.0) + } + + safeListener { + if (it.packet is CPacketAnimation + && mode != Mode.PACKET + && delayTick > -1 + ) { it.cancel() + return@safeListener + } + + if (it.packet is CPacketPlayer + && mode == Mode.EDIT + ) { + // the advantage of this is that it doesn't delay anything and doesn't send extra packets + if (player.onGround) { + if (spoofedY <= 0) { + spoofedY = .01 + } else { + spoofedY -= .00001 + } + } else spoofedY = -1337.0 + + it.packet.playerMoving = true + it.packet.playerIsOnGround = false + + if (spoofedY >= 0) { + it.packet.playerY += spoofedY + } } } safeListener(0) { - if (it.cancelled || attacking || it.entity !is EntityLivingBase || !canDoCriticals(true)) return@safeListener + if (it.cancelled|| it.entity !is EntityLivingBase || !canDoCriticals(true)) return@safeListener val cooldownReady = player.onGround && player.getCooledAttackStrength(0.5f) > 0.9f when (mode) { Mode.PACKET -> { - if (cooldownReady) { - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.1, player.posZ, false)) - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY, player.posZ, false)) - } + if (!cooldownReady) return@safeListener + + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.1, player.posZ, false)) + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY, player.posZ, false)) } Mode.JUMP -> { jumpAndCancel(it, cooldownReady, null) @@ -76,23 +112,26 @@ object Criticals : Module( Mode.MINI_JUMP -> { jumpAndCancel(it, cooldownReady, jumpMotion) } + else -> { } } } safeListener { event -> - if (event.phase != TickEvent.Phase.END || mode == Mode.PACKET || delayTick <= -1) return@safeListener + if (event.phase != TickEvent.Phase.END + || mode == Mode.PACKET + || delayTick <= -1 + ) return@safeListener delayTick-- - if (target != null && player.fallDistance >= attackFallDistance && canDoCriticals(!player.onGround)) { - val target = target - reset() + target?.let{ target -> + if (player.fallDistance >= attackFallDistance + && canDoCriticals(!player.onGround) + ) { + reset() - if (target != null) { - attacking = true connection.sendPacket(CPacketUseEntity(target)) connection.sendPacket(CPacketAnimation(EnumHand.MAIN_HAND)) - attacking = false } } } From 7b85616a8a94ebf7b9fe407b5b777303c2513f2b Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 8 Jan 2023 09:30:24 -0800 Subject: [PATCH 54/85] Radar: Improve FPS at high zooms (#448) * Radar: Improve FPS at high zooms Reduces amount of GL calls to improve FPS. Also added an option to disable rendering the chunk border lines. At high zooms these are not helpful visually and further reduce FPS. * bring back color settings --- .../client/event/events/RenderRadarEvent.kt | 3 +- .../client/gui/hudgui/elements/world/Radar.kt | 3 +- .../client/module/modules/render/NewChunks.kt | 17 ++++--- .../client/util/graphics/RenderUtils2D.kt | 47 +++++++++++++++++++ 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/event/events/RenderRadarEvent.kt b/src/main/kotlin/com/lambda/client/event/events/RenderRadarEvent.kt index 2fb170275..1b8925024 100644 --- a/src/main/kotlin/com/lambda/client/event/events/RenderRadarEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/RenderRadarEvent.kt @@ -6,5 +6,6 @@ import com.lambda.client.util.graphics.VertexHelper class RenderRadarEvent( val vertexHelper: VertexHelper, val radius: Float, - val scale: Float + val scale: Float, + val chunkLines: Boolean ) : Event \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt index f5703e4d4..08bb4f8b6 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/Radar.kt @@ -28,6 +28,7 @@ internal object Radar : HudElement( description = "Shows entities and new chunks" ) { private val zoom by setting("Zoom", 3f, 1f..10f, 0.1f) + private val chunkLines by setting("Chunk Lines", true) private val players = setting("Players", true) private val passive = setting("Passive Mobs", false) @@ -45,7 +46,7 @@ internal object Radar : HudElement( runSafe { drawBorder(vertexHelper) - post(RenderRadarEvent(vertexHelper, radius, zoom)) // Let other modules display radar elements + post(RenderRadarEvent(vertexHelper, radius, zoom, chunkLines)) // Let other modules display radar elements drawEntities(vertexHelper) drawLabels() } diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 701bdcc59..1ea57074d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -118,11 +118,12 @@ object NewChunks : Module( } safeListener { - if (renderMode == RenderMode.WORLD) return@safeListener - val playerOffset = Vec2d((player.posX - (player.chunkCoordX shl 4)), (player.posZ - (player.chunkCoordZ shl 4))) val chunkDist = (it.radius * it.scale).toInt() shr 4 - + // at high zooms (further zoomed out) there will be thousands of rects being rendered + // buffering rects here to reduce GL calls and improve FPS + val distantChunkRects: MutableList> = mutableListOf() + val chunkGridRects: MutableList> = mutableListOf() for (chunkX in -chunkDist..chunkDist) { for (chunkZ in -chunkDist..chunkDist) { val pos0 = getChunkPos(chunkX, chunkZ, playerOffset, it.scale) @@ -136,21 +137,25 @@ object NewChunks : Module( ) ?: false if (!chunk.isLoaded && !isCachedChunk) { - RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, distantChunkColor) + distantChunkRects.add(Pair(pos0, pos1)) } - RenderUtils2D.drawRectOutline(it.vertexHelper, pos0, pos1, 0.3f, chunkGridColor) + chunkGridRects.add(Pair(pos0, pos1)) } } } + if (distantChunkRects.isNotEmpty()) RenderUtils2D.drawRectFilledList(it.vertexHelper, distantChunkRects, distantChunkColor) + if (it.chunkLines && chunkGridRects.isNotEmpty()) RenderUtils2D.drawRectOutlineList(it.vertexHelper, chunkGridRects, 0.3f, chunkGridColor) + val newChunkRects: MutableList> = mutableListOf() chunks.keys.forEach { chunk -> val pos0 = getChunkPos(chunk.x - player.chunkCoordX, chunk.z - player.chunkCoordZ, playerOffset, it.scale) val pos1 = getChunkPos(chunk.x - player.chunkCoordX + 1, chunk.z - player.chunkCoordZ + 1, playerOffset, it.scale) if (isSquareInRadius(pos0, pos1, it.radius)) { - RenderUtils2D.drawRectFilled(it.vertexHelper, pos0, pos1, newChunkColor) + newChunkRects.add(Pair(pos0, pos1)) } } + if (newChunkRects.isNotEmpty()) RenderUtils2D.drawRectFilledList(it.vertexHelper, newChunkRects, newChunkColor) } safeListener { event -> diff --git a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt index b3b32634f..5a86fb8c6 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt @@ -87,12 +87,59 @@ object RenderUtils2D { drawLineLoop(vertexHelper, vertices, lineWidth, color) } + fun drawRectOutlineList(vertexHelper: VertexHelper, + rects: List>, + lineWidth: Float = 1f, + color: ColorHolder) { + prepareGl() + glLineWidth(lineWidth) + vertexHelper.begin(GL_LINES) + rects.forEach { + val pos1 = it.first // Top left + val pos2 = Vec2d(it.second.x, it.first.y) // Top right + val pos3 = it.second // Bottom right + val pos4 = Vec2d(it.first.x, it.second.y) // Bottom left + vertexHelper.put(pos1, color) + vertexHelper.put(pos2, color) + vertexHelper.put(pos2, color) + vertexHelper.put(pos3, color) + vertexHelper.put(pos3, color) + vertexHelper.put(pos4, color) + vertexHelper.put(pos4, color) + vertexHelper.put(pos1, color) + } + vertexHelper.end() + releaseGl() + glLineWidth(1f) + } + fun drawRectFilled(vertexHelper: VertexHelper, posBegin: Vec2d = Vec2d(0.0, 0.0), posEnd: Vec2d, color: ColorHolder) { val pos2 = Vec2d(posEnd.x, posBegin.y) // Top right val pos4 = Vec2d(posBegin.x, posEnd.y) // Bottom left drawQuad(vertexHelper, posBegin, pos2, posEnd, pos4, color) } + fun drawRectFilledList(vertexHelper: VertexHelper, + rects: List>, + color: ColorHolder) { + prepareGl() + vertexHelper.begin(GL_TRIANGLES) + rects.forEach { + val pos1 = it.first // Top left + val pos2 = Vec2d(it.second.x, it.first.y) // Top right + val pos3 = it.second // Bottom right + val pos4 = Vec2d(it.first.x, it.second.y) // Bottom left + vertexHelper.put(pos1, color) + vertexHelper.put(pos2, color) + vertexHelper.put(pos4, color) + vertexHelper.put(pos4, color) + vertexHelper.put(pos3, color) + vertexHelper.put(pos2, color) + } + vertexHelper.end() + releaseGl() + } + private fun drawQuad(vertexHelper: VertexHelper, pos1: Vec2d, pos2: Vec2d, pos3: Vec2d, pos4: Vec2d, color: ColorHolder) { val vertices = arrayOf(pos1, pos2, pos4, pos3) drawTriangleStrip(vertexHelper, vertices, color) From 8d12545e26ad53a0f2c7dee35010c13d4f1c39d7 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sun, 8 Jan 2023 09:38:31 -0800 Subject: [PATCH 55/85] Update to FG5 and fix refmap build cache bricks (#449) * fix missing refmap troll in cached builds * comment and move to task config section * forgegradle 5.+ * remove unnecessary shadow alias --- build.gradle | 8 ++++++-- gradle/wrapper/gradle-wrapper.jar | Bin 59821 -> 60756 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 6 ++++++ gradlew.bat | 14 ++++++++------ .../java/com/lambda/mixin/MixinMinecraft.java | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6b3d24552..106eeb94c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { maven { url = 'https://repo.spongepowered.org/maven/' } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' + classpath 'net.minecraftforge.gradle:ForgeGradle:5.+' classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0' } @@ -25,6 +25,9 @@ group project.modGroup compileJava { sourceCompatibility = targetCompatibility = '1.8' options.encoding = 'UTF-8' + // Disables Gradle build caching for this task + // If build caching is enabled this can cause the refmap to not be built and included + outputs.upToDateWhen { false } } compileKotlin.kotlinOptions { @@ -184,7 +187,8 @@ shadowJar { configurations = [project.configurations.jarLibs] relocate 'kotlin', 'com.lambda.shadow.kotlin' relocate 'kotlinx', 'com.lambda.shadow.kotlinx' - finalizedBy 'reobfShadowJar' + finalizedBy 'configureReobfTaskForReobfShadowJar', 'reobfShadowJar' + mustRunAfter 'jar' } reobf { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4d4fb3f96a785543079b8df6723c946b..249e5832f090a2944b7473328c07c9755baa3196 100644 GIT binary patch delta 10197 zcmaKS1ymhDwk=#NxVyW%y9U<)A-Dv)xI0|j{UX8L-JRg>5ZnnKAh;%chM6~S-g^K4 z>eZ{yK4;gd>gwvXs=Id8Jk-J}R4pT911;+{Jp9@aiz6!p1Oz9z&_kGLA%J5%3Ih@0 zQ|U}%$)3u|G`jIfPzMVfcWs?jV2BO^*3+q2><~>3j+Z`^Z%=;19VWg0XndJ zwJ~;f4$;t6pBKaWn}UNO-wLCFHBd^1)^v%$P)fJk1PbK5<;Z1K&>k~MUod6d%@Bq9 z>(44uiaK&sdhwTTxFJvC$JDnl;f}*Q-^01T508(8{+!WyquuyB7R!d!J)8Ni0p!cV6$CHsLLy6}7C zYv_$eD;)@L)tLj0GkGpBoa727hs%wH$>EhfuFy{_8Q8@1HI%ZAjlpX$ob{=%g6`Ox zLzM!d^zy`VV1dT9U9(^}YvlTO9Bf8v^wMK37`4wFNFzW?HWDY(U(k6@tp(crHD)X5>8S-# zW1qgdaZa*Sh6i%60e1+hty}34dD%vKgb?QmQiZ=-j+isA4={V_*R$oGN#j|#ia@n6 zuZx4e2Xx?^lUwYFn2&Tmbx0qA3Z8;y+zKoeQu;~k~FZGy!FU_TFxYd!Ck;5QvMx9gj5fI2@BLNp~Ps@ zf@k<&Q2GS5Ia9?_D?v~$I%_CLA4x~eiKIZ>9w^c#r|vB?wXxZ(vXd*vH(Fd%Me8p( z=_0)k=iRh%8i`FYRF>E97uOFTBfajv{IOz(7CU zv0Gd84+o&ciHlVtY)wn6yhZTQQO*4Mvc#dxa>h}82mEKKy7arOqU$enb9sgh#E=Lq zU;_RVm{)30{bw+|056%jMVcZRGEBSJ+JZ@jH#~DvaDQm92^TyUq=bY*+AkEakpK>8 zB{)CkK48&nE5AzTqT;WysOG|!y}5fshxR8Ek(^H6i>|Fd&wu?c&Q@N9ZrJ=?ABHI! z`*z8D`w=~AJ!P-9M=T}f`;76$qZRllB&8#9WgbuO$P7lVqdX1=g*t=7z6!0AQ^ux_ z9rcfUv^t}o_l-ZE+TqvqFsA*~W<^78!k;~!i8(eS+(+@u8FxK+Q7;mHZ<1}|4m<}vh@p`t%|@eM_J(P% zI>M7C)Ir{l|J;$G_EGGEhbP4?6{sYzMqBv+x95N&YWFH6UcE@b}B?q)G*4<4mR@sy1#vPnLMK51tb#ED(8TA1nE zYfhK7bo1!R5WJF$5Y?zG21)6+_(_5oSX9sGIW;(O&S?Rh(nydNQYzKjjJ54aDJ-1F zrJ=np8LsN?%?Rt7f~3aAX!2E{`fh_pb?2(;HOB3W+I*~A>W%iY+v45+^e$cE10fA} zXPvw9=Bd+(;+!rl)pkYj0HGB}+3Z!Mr;zr%gz~c-hFMv8b2VRE2R$8V=_XE zq$3=|Yg05(fmwrJ)QK2ptB4no`Y8Dg_vK2QDc6-6sXRQ5k78-+cPi-fH}vpgs|Ive zE=m*XNVs?EWgiNI!5AcD*3QMW)R`EqT!f0e1%hERO&?AT7HWnSf5@#AR{OGuXG3Zb zCnVWg7h|61lGV3k+>L<#d>)InG>ETn1DbOHCfztqzQ_fBiaUt@q6VMy={Fe-w#~2- z0?*f|z$zgjI9>+JVICObBaK=pU}AEOd@q(8d?j7zQFD@=6t`|KmolTr2MfBI$;EGh zD%W0cA_d#V6Lb$us5yIG(|d>r-QleC4;%hEu5W9hyY zY#+ESY&v`8(&mC~?*|e5WEhC!YU2>m_}`K+q9)a(d$bsS<=YkyZGp}YA%TXw>@abA zS_poVPoN+?<6?DAuCNt&5SHV(hp56PJ})swwVFZFXM->F zc|0c8<$H_OV%DR|y7e+s$12@Ac8SUClPg8_O9sTUjpv%6Jsn5vsZCg>wL+db4c+{+ zsg<#wOuV4jeOq`veckdi-1`dz;gvL)bZeH|D*x=8UwRU5&8W1@l>3$)8WzET0%;1J zM3(X<7tKK&9~kWRI{&FmwY5Gg!b5f4kI_vSm)H1#>l6M+OiReDXC{kPy!`%Ecq-+3yZTk=<` zm)pE6xum5q0Qkd#iny0Q-S}@I0;mDhxf>sX)Oiv)FdsAMnpx%oe8OQ`m%Xeozdzx!C1rQR>m1c_}+J4x)K}k{G zo68;oGG&Ox7w^-m7{g4a7NJu-B|~M;oIH~~#`RyUNm##feZH;E?pf}nshmoiIY52n z%pc%lnU4Q#C=RUz)RU6}E_j4#)jh<&a%JyJj$Fufc#&COaxFHtl}zJUGNLBu3~_@1 zn9F^JO9);Duxo&i@>X(kbYga1i>6p1fca8FzQ0>((Lb-aPUbC*d~a03V$y;*RBY!R ziEJ2IF^FjrvO}0Uy{cMn%u<+P5U!UO>pm9#ZYL5i6|xSC+np7IH$GfXs&uI;y4as@ z&AzJh>(S2?3PKKgab3Z(`xbx(C#46XIvVcW8eG_DjT~}Yz_8PWZ`uf6^Xr=vkvL_` zqmvfgJL+Zc`;iq~iP?%@G7}~fal-zqxa0yNyHBJJ5M)9bI>7S_cg?Ya&p(I)C5Ef4 zZ>YAF6x|U=?ec?g*|f2g5Tw3PgxaM_bi_5Az9MO$;_Byw(2d}2%-|bg4ShdQ;)Z|M z4K|tFv)qx*kKGKoyh!DQY<{n&UmAChq@DJrQP>EY7g1JF(ih*D8wCVWyQ z5Jj^|-NVFSh5T0vd1>hUvPV6?=`90^_)t(L9)XOW7jeP45NyA2lzOn&QAPTl&d#6P zSv%36uaN(9i9WlpcH#}rmiP#=L0q(dfhdxvFVaOwM;pY;KvNQ9wMyUKs6{d}29DZQ z{H3&Sosr6)9Z+C>Q5)iHSW~gGoWGgK-0;k~&dyr-bA3O|3PCNzgC?UKS_B=^i8Ri^ zd_*_qI4B07Cayq|p4{`U_E_P=K`N_~{F|+-+`sCgcNxs`%X!$=(?l2aAW}0M=~COb zf19oe^iuAUuDEf)4tgv<=WRPpK@IjToNNC*#&Ykw!)aqWU4h#|U@(cG_=Qx+&xt~a zvCz~Ds3F71dsjNLkfM%TqdVNu=RNMOzh7?b+%hICbFlOAPphrYy>7D-e7{%o_kPFn z;T!?ilE-LcKM0P(GKMseEeW57Vs`=FF}(y@^pQl;rL3fHs8icmA+!6YJt&8 ztSF?%Un35qkv>drkks&BNTJv~xK?vD;aBkp7eIkDYqn+G0%;sT4FcwAoO+vke{8CO z0d76sgg$CannW5T#q`z~L4id)9BCKRU0A!Z-{HpXr)QJrd9@iJB+l32Ql)Z}*v(St zE)Vp=BB=DDB4Pr}B(UHNe31<@!6d{U?XDoxJ@S)9QM)2L%SA0x^~^fb=bdsBy!uh& zU?M_^kvnt%FZzm+>~bEH{2o?v&Iogs`1t-b+Ml`J!ZPS(46YQJKxWE81O$HE5w;** z|8zM%bp`M7J8)4;%DqH`wVTmM0V@D}xd%tRE3_6>ioMJxyi5Hkb>85muF81&EY!73ei zA3e<#ug||EZJ=1GLXNJ)A z791&ge#lF;GVX6IU?iw0jX^1bYaU?+x{zPlpyX6zijyn*nEdZ$fxxkl!a-~*P3bkf zPd*pzu~3GBYkR_>ET`5UM^>>zTV>5m>)f=az{d0sg6a8VzUtXy$ZS?h#Gk-CA?7)c zI%Vu9DN6XSDQn6;?n9`>l$q&>s?K)R8*OsmI+$L_m z_~E`}w694Z*`Xk3Ne=497Si~=RWRqCM?6=88smrxle#s*W znwhTRsMRmg?37GLJ-)%nDZA7r$YG849j8mJWir1bWBy& zZPneYojSbooC8U@tkO`bWx4%E5*;p#Q^1^S3lsfy7(6A{jL0`A__0vm?>xC%1y8_m z57FfWr^@YG2I1K7MGYuYd>JC}@sT2n^rkrY3w%~$J$Y~HSoOHn?zpR$ zjLj_bq@Yj8kd~DXHh30KVbz@K)0S;hPKm+S&-o%IG+@x@MEcrxW2KFh;z^4dJDZix zGRGe&lQD$p)0JVF4NRgGYuh0bYLy)BCy~sbS3^b3 zHixT<%-Vwbht|25T{3^Hk;qZ^3s!OOgljHs+EIf~C%=_>R5%vQI4mQR9qOXThMXlU zS|oSH>0PjnCakb*js2{ObN`}%HYsT6=%(xA| znpUtG_TJ08kHgm5l@G|t?4E3tG2fq?wNtIp*Vqrb{9@bo^~Rx7+J&OnayrX`LDcF~ zd@0m0ZJ#Z@=T>4kTa5e2FjI&5c(F7S{gnRPoGpu9eIqrtSvnT_tk$8T)r%YwZw!gK zj*k@cG)V&@t+mtDi37#>LhVGTfRA^p%x0d#_P|Mktz3*KOoLIqFm`~KGoDDD4OOxe z?}ag_c08u%vu=5Vx=~uoS8Q;}+R2~?Uh|m-+`-2kDo$d6T!nD*hc#dB(*R{LXV=zo z`PJP0V=O!@3l-bw+d`X6(=@fq=4O#ETa8M^fOvO4qja9o3e8ANc9$sI=A4$zUut~w z4+JryRkI{9qWxU1CCMM$@Aj=6)P+z?vqa=UCv_4XyVNoBD{Xb~Oi4cjjhm8fRD!*U z2)zaS;AI78^Wq+5mDInKiMz|z#K`2emQfNH*U;{9^{NqSMVoq?RSo43<8YpJM^+W$ zxy!A5>5Zl16Vi#?nAYywu3w_=KWnd3*QetocWt`3pK67>)ZVwnT3h zbPdD&MZkD?q=-N`MpCCwpM74L+Tr1aa)zJ)8G;(Pg51@U&5W>aNu9rA`bh{vgfE={ zdJ>aKc|2Ayw_bop+dK?Y5$q--WM*+$9&3Q9BBiwU8L<-`T6E?ZC`mT0b}%HR*LPK} z!MCd_Azd{36?Y_>yN{U1w5yrN8q`z(Vh^RnEF+;4b|2+~lfAvPT!`*{MPiDioiix8 zY*GdCwJ{S(5(HId*I%8XF=pHFz<9tAe;!D5$Z(iN#jzSql4sqX5!7Y?q4_%$lH zz8ehZuyl0K=E&gYhlfFWabnSiGty$>md|PpU1VfaC5~kskDnZX&Yu}?-h;OSav=8u z=e3Yq=mi$4A|sB-J00;1d{Sd1+!v0NtU((Nz2;PFFlC}V{@p&4wGcVhU&nI($RAS! zwXn7)?8~1J3*4+VccRSg5JS<(bBhBM&{ELMD4C_NTpvzboH!{Zr*%HP;{UqxI#g&7 zOAqPSW5Qus$8-xtTvD%h{Tw<2!XR(lU54LZG{)Cah*LZbpJkA=PMawg!O>X@&%+5XiyeIf91n2E*hl$k-Y(3iW*E}Mz-h~H~7S9I1I zR#-j`|Hk?$MqFhE4C@=n!hN*o5+M%NxRqP+aLxDdt=wS6rAu6ECK*;AB%Nyg0uyAv zO^DnbVZZo*|Ef{nsYN>cjZC$OHzR_*g%T#oF zCky9HJS;NCi=7(07tQXq?V8I&OA&kPlJ_dfSRdL2bRUt;tA3yKZRMHMXH&#W@$l%-{vQd7y@~i*^qnj^`Z{)V$6@l&!qP_y zg2oOd!Wit#)2A~w-eqw3*Mbe)U?N|q6sXw~E~&$!!@QYX4b@%;3=>)@Z#K^`8~Aki z+LYKJu~Y$;F5%_0aF9$MsbGS9Bz2~VUG@i@3Fi2q(hG^+Ia44LrfSfqtg$4{%qBDM z_9-O#3V+2~W$dW0G)R7l_R_vw(KSkC--u&%Rs^Io&*?R=`)6BN64>6>)`TxyT_(Rd zUn+aIl1mPa#Jse9B3`!T=|e!pIp$(8ZOe0ao?nS7o?oKlj zypC-fMj1DHIDrh1unUI1vp=-Fln;I9e7Jvs3wj*^_1&W|X} zZSL|S|Bb@CV*YC_-T&2!Ht3b6?)d`tHOP?rA;;t#zaXa0Sc;vGnV0BLIf8f-r{QHh z*Zp`4_ItlOR7{u(K+!p_oLDmaAkNag*l4#29F2b_A*0oz0T|#-&f*;c#<`^)(W@gm z#k9k=t%u8<+C1fNUA{Fh7~wgPrEZZ#(6aBI%6bR4RO(e1(ZocjoDek4#MTgZD>1NG zy9~yoZfWYfwe&S-(zk4o6q6o?2*~DOrJ(%5wSnEJMVOKCzHd z=Yhm+HLzoDl{P*Ybro7@sk1!Ez3`hE+&qr7Rw^2glw^M(b(NS2!F|Q!mi|l~lF94o z!QiV)Q{Z>GO5;l1y!$O)=)got;^)%@v#B!ZEVQy1(BJApHr5%Zh&W|gweD+%Ky%CO ztr45vR*y(@*Dg_Qw5v~PJtm^@Lyh*zRuT6~(K+^HWEF{;R#L$vL2!_ndBxCtUvZ(_ zauI7Qq}ERUWjr&XW9SwMbU>*@p)(cuWXCxRK&?ZoOy>2VESII53iPDP64S1pl{NsC zD;@EGPxs&}$W1;P6BB9THF%xfoLX|4?S;cu@$)9OdFst-!A7T{(LXtdNQSx!*GUSIS_lyI`da8>!y_tpJb3Zuf0O*;2y?HCfH z5QT6@nL|%l3&u4;F!~XG9E%1YwF*Fgs5V&uFsx52*iag(?6O|gYCBY3R{qhxT-Etb zq(E%V=MgQnuDGEKOGsmBj9T0-nmI%zys8NSO>gfJT4bP>tI>|ol@ zDt(&SUKrg%cz>AmqtJKEMUM;f47FEOFc%Bbmh~|*#E zDd!Tl(wa)ZZIFwe^*)4>{T+zuRykc3^-=P1aI%0Mh}*x7%SP6wD{_? zisraq`Las#y-6{`y@CU3Ta$tOl|@>4qXcB;1bb)oH9kD6 zKym@d$ zv&PZSSAV1Gwwzqrc?^_1+-ZGY+3_7~a(L+`-WdcJMo>EWZN3%z4y6JyF4NR^urk`c z?osO|J#V}k_6*9*n2?j+`F{B<%?9cdTQyVNm8D}H~T}?HOCXt%r7#2hz97Gx#X%62hyaLbU z_ZepP0<`<;eABrHrJAc!_m?kmu#7j}{empH@iUIEk^jk}^EFwO)vd7NZB=&uk6JG^ zC>xad8X$h|eCAOX&MaX<$tA1~r|hW?-0{t4PkVygTc`yh39c;&efwY(-#;$W)+4Xb z$XFsdG&;@^X`aynAMxsq)J#KZXX!sI@g~YiJdHI~r z$4mj_?S29sIa4c$z)19JmJ;Uj?>Kq=0XuH#k#};I&-6zZ_&>)j>UR0XetRO!-sjF< zd_6b1A2vfi++?>cf}s{@#BvTD|a%{9si7G}T+8ZnwuA z1k8c%lgE<-7f~H`cqgF;qZ|$>R-xNPA$25N1WI3#n%gj}4Ix}vj|e=x)B^roGQpB) zO+^#nO2 zjzJ9kHI6nI5ni&V_#5> z!?<7Qd9{|xwIf4b0bRc;zb}V4>snRg6*wl$Xz`hRDN8laL5tg&+@Dv>U^IjGQ}*=XBnXWrwTy;2nX?<1rkvOs#u(#qJ=A zBy>W`N!?%@Ay=upXFI}%LS9bjw?$h)7Dry0%d}=v0YcCSXf9nnp0tBKT1eqZ-4LU` zyiXglKRX)gtT0VbX1}w0f2ce8{$WH?BQm@$`ua%YP8G@<$n13D#*(Yd5-bHfI8!on zf5q4CPdgJLl;BqIo#>CIkX)G;rh|bzGuz1N%rr+5seP${mEg$;uQ3jC$;TsR&{IX< z;}7j3LnV+xNn^$F1;QarDf6rNYj7He+VsjJk6R@0MAkcwrsq4?(~`GKy|mgkfkd1msc2>%B!HpZ~HOzj}kl|ZF(IqB=D6ZTVcKe=I7)LlAI=!XU?J*i#9VXeKeaG zwx_l@Z(w`)5Cclw`6kQKlS<;_Knj)^Dh2pL`hQo!=GPOMR0iqEtx12ORLpN(KBOm5 zontAH5X5!9WHS_=tJfbACz@Dnkuw|^7t=l&x8yb2a~q|aqE_W&0M|tI7@ilGXqE)MONI8p67OiQGqKEQWw;LGga=ZM1;{pSw1jJK_y$vhY6 ztFrV7-xf>lbeKH1U)j3R=?w*>(Yh~NNEPVmeQ8n}0x01$-o z2Jyjn+sXhgOz>AzcZ zAbJZ@f}MBS0lLKR=IE{z;Fav%tcb+`Yi*!`HTDPqSCsFr>;yt^^&SI2mhKJ8f*%ji zz%JkZGvOn{JFn;)5jf^21AvO-9nRzsg0&CPz;OEn07`CfT@gK4abFBT$Mu?8fCcscmRkK+ zbAVJZ~#_a z{|(FFX}~8d3;DW8zuY9?r#Dt>!aD>} zlYw>D7y#eDy+PLZ&XKIY&Df0hsLDDi(Yrq8O==d30RchrUw8a=Eex>Dd?)3+k=}Q> z-b85lun-V$I}86Vg#l1S@1%=$2BQD5_waAZKQfJ${3{b2SZ#w1u+jMr{dJMvI|Og= zpQ9D={XK|ggbe04zTUd}iF{`GO1dV%zWK~?sM9OM(= zVK9&y4F^w1WFW{$qi|xQk0F`@HG8oLI5|5$j~ci9xTMT69v5KS-Yym--raU5kn2#C z<~5q^Bf0rTXVhctG2%&MG(cUGaz(gC(rcG~>qgO$W6>!#NOVQJ;pIYe-lLy(S=HgI zPh;lkL$l+FfMHItHnw_^bj8}CKM19t(C_2vSrhX2$K@-gFlH};#C?1;kk&U1L%4S~ zR^h%h+O1WE7DI$~dly?-_C7>(!E`~#REJ~Xa7lyrB$T!`&qYV5QreAa^aKr%toUJR zPWh)J3iD`(P6BI5k$oE$us#%!4$>`iH2p-88?WV0M$-K)JDibvA4 zpef%_*txN$Ei3=Lt(BBxZ&mhl|mUz-z*OD1=r9nfN zc5vOMFWpi>K=!$6f{eb?5Ru4M3o;t9xLpry|C%j~`@$f)OFB5+xo8XM8g&US@UU-sB|dAoc20y(F@=-2Ggp_`SWjEb#>IG^@j zuQK}e^>So#W2%|-)~K!+)wdU#6l>w5wnZt2pRL5Dz#~N`*UyC9tYechBTc2`@(OI# zNvcE*+zZZjU-H`QOITK^tZwOyLo)ZCLk>>Wm+flMsr5X{A<|m`Y281n?8H_2Fkz5}X?i%Rfm5s+n`J zDB&->=U+LtOIJ|jdYXjQWSQZFEs>Rm{`knop4Sq)(}O_@gk{14y51)iOcGQ5J=b#e z2Yx^6^*F^F7q_m-AGFFgx5uqyw6_4w?yKCJKDGGprWyekr;X(!4CnM5_5?KgN=3qCm03 z##6k%kIU5%g!cCL(+aK>`Wd;dZ4h$h_jb7n?nqx5&o9cUJfr%h#m4+Bh)>HodKcDcsXDXwzJ3jR(sSFqWV(OKHC*cV8;;&bH=ZI0YbW3PgIHwTjiWy z?2MXWO2u0RAEEq(zv9e%Rsz|0(OKB?_3*kkXwHxEuazIZ7=JhaNV*P~hv57q55LoebmJpfHXA@yuS{Esg+ z*C}0V-`x^=0nOa@SPUJek>td~tJ{U1T&m)~`FLp*4DF77S^{|0g%|JIqd-=5)p6a` zpJOsEkKT(FPS@t^80V!I-YJbLE@{5KmVXjEq{QbCnir%}3 zB)-J379=wrBNK6rbUL7Mh^tVmQYn-BJJP=n?P&m-7)P#OZjQoK0{5?}XqJScV6>QX zPR>G{xvU_P;q!;S9Y7*07=Z!=wxIUorMQP(m?te~6&Z0PXQ@I=EYhD*XomZ^z;`Os z4>Uh4)Cg2_##mUa>i1Dxi+R~g#!!i{?SMj%9rfaBPlWj_Yk)lCV--e^&3INB>I?lu z9YXCY5(9U`3o?w2Xa5ErMbl5+pDVpu8v+KJzI9{KFk1H?(1`_W>Cu903Hg81vEX32l{nP2vROa1Fi!Wou0+ZX7Rp`g;B$*Ni3MC-vZ`f zFTi7}c+D)!4hz6NH2e%%t_;tkA0nfkmhLtRW%){TpIqD_ev>}#mVc)<$-1GKO_oK8 zy$CF^aV#x7>F4-J;P@tqWKG0|D1+7h+{ZHU5OVjh>#aa8+V;6BQ)8L5k9t`>)>7zr zfIlv77^`Fvm<)_+^z@ac%D&hnlUAFt8!x=jdaUo{)M9Ar;Tz5Dcd_|~Hl6CaRnK3R zYn${wZe8_BZ0l0c%qbP}>($jsNDay>8+JG@F!uV4F;#zGsBP0f$f3HqEHDz_sCr^q z1;1}7KJ9&`AX2Qdav1(nNzz+GPdEk5K3;hGXe{Hq13{)c zZy%fFEEH#nlJoG{f*M^#8yXuW%!9svN8ry-Vi7AOFnN~r&D`%6d#lvMXBgZkX^vFj z;tkent^62jUr$Cc^@y31Lka6hS>F?1tE8JW$iXO*n9CQMk}D*At3U(-W1E~z>tG?> z5f`5R5LbrhRNR8kv&5d9SL7ke2a*Xr)Qp#75 z6?-p035n2<7hK;sb>t9GAwG4{9v~iEIG>}7B5zcCgZhu$M0-z8?eUO^E?g)md^XT_ z2^~-u$yak>LBy(=*GsTj6p<>b5PO&un@5hGCxpBQlOB3DpsItKZRC*oXq-r{u}Wb; z&ko>#fbnl2Z;o@KqS-d6DTeCG?m1 z&E>p}SEc*)SD&QjZbs!Csjx~0+$@ekuzV_wAalnQvX3a^n~3ui)|rDO+9HW|JPEeBGP4 z)?zcZ<8qv47`EWA*_X~H^vr(lP|f%=%cWFM;u)OFHruKT<~?>5Y8l?56>&;=WdZU# zZEK4-C8s-3zPMA^&y~e*9z)!ZJghr3N^pJa2A$??Xqx-BR*TytGYor&l8Q+^^r%Yq02xay^f#;;wO6K7G!v>wRd6531WnDI~h$PN( z+4#08uX?r&zVKsQ;?5eBX=FxsXaGyH4Gth4a&L|{8LnNCHFr1M{KjJ!BfBS_aiy-E zxtmNcXq3}WTwQ7Dq-9YS5o758sT(5b`Sg-NcH>M9OH1oW6&sZ@|GYk|cJI`vm zO<$~q!3_$&GfWetudRc*mp8)M)q7DEY-#@8w=ItkApfq3sa)*GRqofuL7)dafznKf zLuembr#8gm*lIqKH)KMxSDqbik*B(1bFt%3Vv|ypehXLCa&wc7#u!cJNlUfWs8iQ` z$66(F=1fkxwg745-8_eqV>nWGY3DjB9gE23$R5g&w|C{|xvT@7j*@aZNB199scGchI7pINb5iyqYn)O=yJJX)Ca3&Ca+{n<=1w|(|f0)h<9gs$pVSV<<9Og-V z8ki@nKwE)x)^wmHBMk?mpMT=g{S#^8W|>&rI#Ceh;9za}io0k@0JxiCqi-jHlxbt3 zjJA?RihhRvhk6%G5-D{ePh1jare*fQS<328P-DcVAxPTrw=n6k?C6EV75f}cnBRPT zMYDqqKu(ND&aOtc!QRV`vzJSVxx8i~WB#5Ml{b#eQqNnSi7l-bS-`ITW<^zyYQA(b zbj4SuRK>q9o`_v%+C=S?h>2e4!66Ij(P5{7Uz$3u6YJJC$W%EoBa{-(=tQ|y1vov%ZkXVOV z##_UVg4V^4ne#4~<-1DkJqkKqgT+E_=&4Ue&eQ-JC+gi?7G@d6= zximz{zE)WW{b@QCJ!7l&N5x=dXS?$5RBU-VvN4Uec-GHK&jPa&P2z+qDdLhIB+HU) zu0CW&uLvE^4I5xtK-$+oe|58)7m6*PO%Xt<+-XEA%jG_BEachkF3e@pn?tl!`8lOF zbi2QOuNXX)YT*MCYflILO{VZ*9GiC%R4FO20zMK?p+&aCMm2oeMK7(aW=UDzr=AO0 z$5mJ%=qRsR8rZ>_YsL+vi{3*J_9Kzq(;ZwRj+4_f0-*wbkSMPWahX#Fj_a8BnrhJ6 zo^ZZ?Vah1@&6#r=JkuaYDBdp;J3@ii+CHM&@9*er&#P}$@wI$bfrH)&c!*|nkvhf%^*Y6b%dKz%QBSIo@U z{?V^qEs4`q<8@n+u8YiB^sc@6g>TncG<|GsmC3egwE6aO=EwLr~3-2 zNr`+)`i+-83?|1Xy0^8ps&pb}YT?w1eWVnC9Ps1=KM;Rw)bH6O!7Did1NwpnqVPZc z*%Qo~qkDL>@^<^fmIBtx$WUWQiNtAB2x-LO^BB=|w~-zTnJNEdm1Ou(?8PF&U88X@ z#8rdaTd||)dG^uJw~N_-%!XNbuAyh4`>Shea=pSj0TqP+w4!`nxsmVSv02kb`DBr% zyX=e>5IJ3JYPtdbCHvKMdhXUO_*E9jc_?se7%VJF#&ZaBD;7+eFN3x+hER7!u&`Wz z7zMvBPR4y`*$a250KYjFhAKS%*XG&c;R-kS0wNY1=836wL6q02mqx;IPcH(6ThA@2 zXKQF|9H>6AW$KUF#^A%l6y5{fel77_+cR_zZ0(7=6bmNXABv}R!B-{(E^O6Y?ZS)n zs1QEmh_Fm7p}oRyT3zxUNr4UV8NGs+2b8|4shO$OGFj3D&7_e?#yDi=TTe%$2QbG5 zk<;q7aQ;p!M-Osm{vFdmXZ@!z9uWh!;*%>(vTRggufuUGP9Hols@vhx z73pn$3u2;vzRvnXuT&$Os7J@6y12*j!{ix%3B4YU1466ItmJs0NsU(4ZYRYh7wEA6q{b*Hs6@k~ zi7Yq@Ax!et0cUMTvk7P%ym){MHpcliHEI~e3HP0NV=}7;xFv#IC?a<=`>~j_sk{e> z7vg-tK*p83HZ0=QK@ zRIHo^r{D8&Ms-^WZp+6US_Quqjh$Q66W^1}=Uz&XJ8AQE9&2}P zY|FXZzZ|0IiaBd2qdt6dIjQr(ZMIOU%NG1F&fu6Po9m^?BvLhI6T0R!H2d8;U(&p2 zYA|MFscMqcO(ye~Jp?F;0>Ke+5hzVr?aBNe>GsGgr$XrpS9uajN2kNQ3o$V5rp0T( z0$6TJC;3)26SNG#XcX7l^MKTn$ga?6r4Jzfb%ZgA(Zbwit0$kY=avSnI$@Gk%+^pu zS5mHrcRS8LFPC*uVWH4DDD1pY$H8N>X?KIJZuZ2SvTqc5Nr0GHdD8TCJcd$zIhOdC zZX0ErnsozQh;t^==4zTfrZO421AL?)O)l#GSxU#|LTTg4#&yeK=^w#;q63!Nv~1(@ zs^-RNRuF&qgcr+bIzc@7$h9L;_yjdifE*$j0Q&Np=1AuHL--zdkv@}`1 zo~LlDl_YAq*z?vmr4M`GjDkl9?p|-tl(DtX76oZv25_DtZutLS9Ez!5~p?th@4 zyc_uax4W#<(#)LMkvo)yp|5tKsC2=p#6PyhpH|449T<9Zdk|%CAb5cw?fhvQtBO&7 zpQ9$24yLqPHP;$N&fe2wm%8qdctwIna<3SwGtQA3{C77s%CW%LYxtK(SBGustL0<( zu~U9r0UOkr(c{OJxZS0Ntu3+cJlF7R`7k-Bsa&q?9Ae5{{|o~?cM+T7{lB1^#vT8R z?>c9fNWey`1dKDY%F3d2O*8^qYhjlB8*7HMKE<*=(A`{>=1%s1}Pm&#_t1xy!FkPk@%SMEka2@*= zxDuM|vJJ5s+xgDls{>*o!7eOcs|xuVBPWX&+y5vEiADK%hi`#Dbd>;;Pbk2H4*-X&R?_-6ZEutSd8hC+sSjhIo z;D(j4P;2EVpEj#UF7IjM6PC+X$C5T&=nL`*!*hm9U)#O?>wqOgC>jXKN3Slk_yaQX zLf|4D8T4k|wHW`;#ZQVocNF|3izi0sOqXzi7@KlYC3CXBG`94wD;tMI1bj|8Vm zY}9`VI9!plSfhAal$M_HlaYOVNU?9Z#0<$o?lXXbX3O(l_?f)i3_~r+GcO-x#+x^X zfsZl0>Rj2iP1rsT;+b;Mr? z4Vu&O)Q5ru4j;qaSP5gA{az@XTS1NpT0d9Xhl_FkkRpcEGA0(QQ~YMh#&zwDUkNzm z6cgkdgl9W{iL6ArJ1TQHqnQ^SQ1WGu?FT|93$Ba}mPCH~!$3}0Y0g zcoG%bdTd$bmBx9Y<`Jc+=Cp4}c@EUfjiz;Rcz101p z=?#i$wo>gBE9|szaZMt-d4nUIhBnYRuBVyx+p?5#aZQgUe(!ah`J#l1$%bl5avL27 zU2~@V`3Ic&!?FhDX@Cw!R4%xtWark#p8DLT)HCZ?VJxf^yr@AD*!ERK3#L$E^*Yr? zzN&uF9Roh4rP+r`Z#7U$tzl6>k!b~HgM$C<_crP=vC>6=q{j?(I}!9>g3rJU(&){o z`R^E*9%+kEa8H_fkD9VT7(Fks&Y-RcHaUJYf-|B+eMXMaRM;{FKRiTB>1(=Iij4k1(X__|WqAd-~t#2@UQ}Z&<1Th0azdXfoll!dd)6>1miA z!&=6sDJm=e$?L&06+Q3`D-HNSkK-3$3DdZMX-6Xjn;wd#9A{~ur!2NcX>(qY_oZL0~H7dnQ9sgLe!W>~2|RSW7|hWn<({Pg*xF$%B-!rKe^_R_vc z(LO!0agxxP;FWPV({8#lEv$&&GVakGus=@!3YVG`y^AO1m{2%Np;>HNA1e{=?ra1C}H zAwT0sbwG|!am;fl?*_t^^#yLDXZ*Nx)_FqueZi0c-G~omtpHW0Cu)mEJ`Z1X8brq$ z%vK##b~o*^b&Hz!hgrD=^6P8}aW40lhzMLB5T5*v`1QH?+L~-@CDi3+C@nRf2{7UE zyDIe{@LKw`Eu=Z%6<<_=#V|yxJIKiq_N?ZJ_v0$c)N4l07ZV_mIXG}glfBSPivOhw z-~+9GdckSpMBNR9eR`Y|9_)sXS+u_OiQ%!9rE(2AFjoxN8lk16Sb~^Sq6kRoEp3yD(mm`HsYIXcag_EAB8MHc}nahxVVUTts~U9P|f;7Ul$_` zStR4v&P4q_$KXOEni$lkxy8=9w8G&47VY0oDb^+jT+>ARe3NHUg~St`$RDxY)?;_F znqTujR&chZd2qHF7y8D$4&E3+e@J~!X3&BW4BF(Ebp#TEjrd+9SU!)j;qH+ZkL@AW z?J6Mj}v0_+D zH0qlbzCkHf|EZ`6c>5ig5NAFF%|La%M-}g(7&}Vx8K)qg30YD;H!S!??{;YivzrH0 z(M%2*b_S-)yh&Aiqai)GF^c!<1Xemj|13>dZ_M#)41SrP;OEMaRJ)bCeX*ZT7W`4Y zQ|8L@NHpD@Tf(5>1U(s5iW~Zdf7$@pAL`a3X@YUv1J>q-uJ_(Dy5nYTCUHC}1(dlI zt;5>DLcHh&jbysqt?G01MhXI3!8wgf){Hv}=0N|L$t8M#L7d6WscO8Om2|NBz2Ga^ zs86y%x$H18)~akOWD7@em7)ldlWgb?_sRN>-EcYQO_}aX@+b$dR{146>{kXWP4$nN{V0_+|3{Lt|8uX_fhKh~i{(x%cj*PU$i{PO(5$uA? zQzO>a6oPj-TUk&{zq?JD2MNb6Mf~V3g$ra+PB;ujLJ2JM(a7N*b`y{MX--!fAd}5C zF$D_b8S;+Np(!cW)(hnv5b@@|EMt*RLKF*wy>ykFhEhlPN~n_Bj>LT9B^_yj>z#fx z3JuE4H&?Cc!;G@}E*3k`HK#8ag`yE3Z1)5JUlSua%qkF zkTu|<9{w9OSi$qr)WD#7EzITnch=xnR63E*d~WGvi*Co9BBE?ETHud;!Z)7&wz+l6 zuKODYG1>I1U#a%&(GNJ`AqRfg=H!BtSl+_;CEeufF-#+*2EMMz-22@>18=8PH{PHd z);mN=aR0MPF>eutLiS#-AOX>#2%+pTGEOj!j4L(m0~&xR=0+g#HNpno6@veLhJp}e zyNVC$a>4;!9&iGvU_dj&xbKt@^t6r%f^)+}eV^suRTLP52+BVs0kOLwg6n`=NUv50E7My8XQUh?y%mW62OT1pMrKI3Q(r`7vU&@93=G~A?b(^pvC-8x=bSk zZ60BQR96WB1Z@9Df(M1IQh+YrU8sEjB=Tc2;(zBn-pete*icZE|M&Uc+oHg`|1o`g zH~m+k=D$o);{Rs)b<9Zo|9_Z6L6QHLNki(N>Dw^^i1LITprZeeqIaT#+)fw)PlllU zldphHC)t!0Gf(i9zgVm>`*TbmITF zH1FZ4{wrjRCx{t^26VK_2srZuWuY*EMAsMrJYFFCH35Ky7bq8<0K|ey2wHnrFMZyr z&^yEgX{{3i@&iE5>xKZ{Ads36G3a!i50D!C4?^~cLB<<|fc1!XN(HJRM)H^21sEs%vv+Mu0h*HkLHaEffMwc0n6)JhNXY#M5w@iO@dfXY z0c6dM2a4Hd1SA*#qYj@jK}uVgAZdaBj8t6uuhUNe>)ne9vfd#C6qLV9+@Q7{MnF#0 zJ7fd-ivG_~u3bVvOzpcw1u~ZSp8-kl(sunnX>L~*K-ByWDM2E8>;Si6kn^58AZQxI xVa^It*?521mj4+UJO?7%w*+`EfEcU=@KhDx-s^WzP+ae~{CgHDE&XryzW}Nww%-5% diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3ab0b725e..ae04661ee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c78733..a69d9cb6c 100755 --- a/gradlew +++ b/gradlew @@ -205,6 +205,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f93..53a6b238d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/java/com/lambda/mixin/MixinMinecraft.java b/src/main/java/com/lambda/mixin/MixinMinecraft.java index 6a9fbc4ef..73c865b2b 100644 --- a/src/main/java/com/lambda/mixin/MixinMinecraft.java +++ b/src/main/java/com/lambda/mixin/MixinMinecraft.java @@ -43,7 +43,7 @@ public abstract class MixinMinecraft { private boolean handActive = false; private boolean isHittingBlock = false; - @Shadow(aliases = "func_147116_af") // Fixes weird prod meme in some cases?? + @Shadow protected abstract void clickMouse(); @ModifyVariable(method = "displayGuiScreen", at = @At("HEAD"), argsOnly = true) From 2b22f518ef29e9cd7bf07dee23320730ed25981c Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Sun, 8 Jan 2023 18:53:08 +0100 Subject: [PATCH 56/85] EntitySpeed: Add MaxJump setting (#452) * EntitySpeed: Add MaxJump setting This patch adds the MaxJump setting to the EntitySpeed module. This works by setting the maximum jump value (90) to the entity if its of type AbstractHorse and the user is pressing down the jump key. * Cleanup Co-authored-by: Constructor --- .../module/modules/movement/EntitySpeed.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/EntitySpeed.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/EntitySpeed.kt index cfeea6baa..e0423fed2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/EntitySpeed.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/EntitySpeed.kt @@ -18,21 +18,29 @@ object EntitySpeed : Module( private val abstractHorseSpeed by setting("Horse Types Speed", 0.7f, 0.1f..10.0f, 0.05f) private val pigSpeed by setting("Pig Speed", 1.0f, 0.1f..10.0f, 0.05f) private val antiStuck by setting("Anti Stuck", true) + private val maxJump by setting("Max Jump", true) init { safeListener { player.ridingEntity?.let { entity -> var tamper = false + val speed = when { entity is AbstractHorse && entity.controllingPassenger == player -> abstractHorseSpeed.also { tamper = true } entity is EntityBoat && entity.controllingPassenger == player -> boatSpeed.also { tamper = true } entity is EntityPig -> pigSpeed.also { tamper = true } else -> .0f } - if (tamper) { - steerEntity(entity, speed, antiStuck) - entity.rotationYaw = player.rotationYaw - } + + if (!tamper) return@safeListener + + steerEntity(entity, speed, antiStuck) + entity.rotationYaw = player.rotationYaw + + if (maxJump + && entity is AbstractHorse + && mc.gameSettings.keyBindJump.isKeyDown + ) entity.setJumpPower(90) } } } From 58020a46e7232678da0cd3c5cddeaee42bb48deb Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Sun, 8 Jan 2023 19:12:19 +0100 Subject: [PATCH 57/85] AutoOffhand: Show remaining items (#453) * AutoOffhand: Add "Show Remaining" option This option shows the remaining number of items of type AutoOffhandType in the inventory next to the module name in the HUD. * Cleanup Co-authored-by: Constructor --- .../com/lambda/client/module/modules/combat/AutoOffhand.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 1d027b275..8e75e5a81 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -67,6 +67,9 @@ object AutoOffhand : Module( private val priority by setting("Priority", Priority.HOTBAR) private val switchMessage by setting("Switch Message", true) + // Represents the remaining number of items of type AutoOffhandType in the inventory + private var hudInfo = "" + private enum class Type(val filter: (ItemStack) -> Boolean) { TOTEM({ it.item.id == 449 }), GAPPLE({ it.item is ItemAppleGold }), @@ -98,9 +101,13 @@ object AutoOffhand : Module( updateDamage() switchToType(getType(), true) + + hudInfo = player.allSlots.countByStack { type.filter(it) }.toString() } } + override fun getHudInfo() = hudInfo + private fun SafeClientEvent.getType() = when { checkTotem() -> Type.TOTEM checkStrength() -> Type.STRENGTH From 94296983b4c7b9b3803fbba248b2c867fc0ef612 Mon Sep 17 00:00:00 2001 From: kaz2700 <113390987+kaz2700@users.noreply.github.com> Date: Sun, 8 Jan 2023 19:25:11 +0100 Subject: [PATCH 58/85] Rename AutoLog module to AutoDisconnect (#450) * Rename AutoLog module to AutoDisconnect In most clients this module is called AutoDisconnect so as to avoid confusion I think renaming it would be very good :) * Cleanup Co-authored-by: KazutoXD Co-authored-by: Constructor --- .../client/gui/mc/LambdaGuiDisconnected.kt | 30 ++++++++++++------- .../combat/{AutoLog.kt => AutoDisconnect.kt} | 8 ++--- 2 files changed, 23 insertions(+), 15 deletions(-) rename src/main/kotlin/com/lambda/client/module/modules/combat/{AutoLog.kt => AutoDisconnect.kt} (96%) diff --git a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiDisconnected.kt b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiDisconnected.kt index 6ee09046f..ca9981c4b 100644 --- a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiDisconnected.kt +++ b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiDisconnected.kt @@ -1,6 +1,6 @@ package com.lambda.client.gui.mc -import com.lambda.client.module.modules.combat.AutoLog +import com.lambda.client.module.modules.combat.AutoDisconnect import com.lambda.client.util.threads.mainScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -8,14 +8,19 @@ import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiScreen import java.time.LocalTime -class LambdaGuiDisconnected(private val reason: Array, private val screen: GuiScreen, private val disable: Boolean, private val logoutTime: LocalTime) : GuiScreen() { +class LambdaGuiDisconnected( + private val reason: Array, + private val screen: GuiScreen, + private val disable: Boolean, + private val logoutTime: LocalTime +) : GuiScreen() { override fun initGui() { super.initGui() buttonList.add(GuiButton(0, width / 2 - 100, 200, "Okay")) if (!disable) { - buttonList.add(GuiButton(1, width / 2 - 100, 220, "Disable AutoLog")) + buttonList.add(GuiButton(1, width / 2 - 100, 220, "Disable AutoDisconnect")) } else { disable() } @@ -23,31 +28,34 @@ class LambdaGuiDisconnected(private val reason: Array, private val scree override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { drawBackground(0) - drawCenteredString(fontRenderer, "[AutoLog] Logged because:", width / 2, 80, 0x9B90FF) - for ((index, reason) in reason.withIndex()) { + drawCenteredString(fontRenderer, "[AutoDisconnect] Disconnected because:", width / 2, 80, 0x9B90FF) + + reason.forEachIndexed { index, reason -> drawCenteredString(fontRenderer, reason, width / 2, 94 + (14 * index), 0xFFFFFF) } drawCenteredString(fontRenderer, "Logged out at: $logoutTime", width / 2, 140, 0xFFFFFFF) - if (!disable) drawCenteredString(fontRenderer, "Disabled AutoLog", width / 2, 224, 0xDE413C) + if (!disable) drawCenteredString(fontRenderer, "Disabled AutoDisconnect", width / 2, 224, 0xDE413C) super.drawScreen(mouseX, mouseY, partialTicks) } override fun keyTyped(typedChar: Char, keyCode: Int) {} override fun actionPerformed(button: GuiButton) { - if (button.id == 0) mc.displayGuiScreen(screen) - if (button.id == 1) { - disable() - buttonList.remove(button) + when (button.id) { + 0 -> mc.displayGuiScreen(screen) + 1 -> { + disable() + buttonList.remove(button) + } } } private fun disable() { mainScope.launch { delay(250L) - AutoLog.disable() + AutoDisconnect.disable() } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoDisconnect.kt similarity index 96% rename from src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt rename to src/main/kotlin/com/lambda/client/module/modules/combat/AutoDisconnect.kt index ebc75a412..1a9de12ec 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoDisconnect.kt @@ -7,7 +7,7 @@ import com.lambda.client.manager.managers.CombatManager import com.lambda.client.manager.managers.FriendManager import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.combat.AutoLog.Reasons.* +import com.lambda.client.module.modules.combat.AutoDisconnect.Reasons.* import com.lambda.client.util.EntityUtils.isFakeOrSelf import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.allSlots @@ -25,9 +25,9 @@ import net.minecraft.util.text.TextComponentString import net.minecraftforge.fml.common.gameevent.TickEvent import java.time.LocalTime -object AutoLog : Module( - name = "AutoLog", - description = "Automatically log when in danger or on low health", +object AutoDisconnect : Module( + name = "AutoDisconnect", + description = "Automatically disconnects when in danger or on low health", category = Category.COMBAT, alwaysListening = true ) { From 87f26b749c46eaa2802c52cad50a39bfaa8e00c8 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Sun, 8 Jan 2023 19:54:04 +0100 Subject: [PATCH 59/85] Nametags: Add TOTEM_POP_COUNT ContentType (#454) * Nametags: Add TOTEM_POP_COUNT ContentType This patch allows for the popped totems to be able to be shown in the nametags. The totem pop counting functionality is embedded in the TotemPopCounter module, hence, it needs to be active in order for this to work. As to ensure this is the case, this patch adds some logic preventing this feature to be enabled when the TotemPopCounter module is inactive, and also re-enables the TotemPopCounter module if this feature is enabled and the user tries to disable the TotemPopCounter module. * Cleanup Co-authored-by: Constructor --- .../module/modules/combat/TotemPopCounter.kt | 2 +- .../client/module/modules/render/Nametags.kt | 49 ++++++++++++------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 94a761232..71ca05d76 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -35,7 +35,7 @@ object TotemPopCounter : Module( CLIENT, EVERYONE } - private val popCountMap = WeakHashMap().synchronized() + val popCountMap = WeakHashMap().synchronized() private var wasSent = false init { diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt index 7ae701a7f..da3fe6386 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.commons.extension.ceilToInt import com.lambda.client.commons.extension.floorToInt import com.lambda.client.commons.utils.MathUtils +import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.RenderOverlayEvent import com.lambda.client.event.listener.listener import com.lambda.client.module.Category @@ -11,6 +12,7 @@ import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.CustomFont import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.module.modules.client.Hud +import com.lambda.client.module.modules.combat.TotemPopCounter import com.lambda.client.module.modules.misc.LogoutLogger import com.lambda.client.util.EnchantmentUtils import com.lambda.client.util.EntityUtils @@ -60,7 +62,6 @@ object Nametags : Module( private val invisible by setting("Invisible", true, { page == Page.ENTITY_TYPE }) private val range by setting("Range", 64, 0..256, 4, { page == Page.ENTITY_TYPE }) - /* Content */ private val line1left = setting("Line 1 Left", ContentType.NONE, { page == Page.CONTENT }) private val line1center = setting("Line 1 Center", ContentType.NONE, { page == Page.CONTENT }) private val line1right = setting("Line 1 Right", ContentType.NONE, { page == Page.CONTENT }) @@ -95,7 +96,7 @@ object Nametags : Module( } private enum class ContentType { - NONE, NAME, TYPE, TOTAL_HP, HP, ABSORPTION, PING, DISTANCE, ENTITY_ID + NONE, NAME, TYPE, TOTAL_HP, HP, ABSORPTION, PING, DISTANCE, ENTITY_ID, TOTEM_POP_COUNT } private val pingColorGradient = ColorGradient( @@ -114,7 +115,7 @@ object Nametags : Module( private val line1Settings = arrayOf(line1left, line1center, line1right) private val line2Settings = arrayOf(line2left, line2center, line2right) - val entityMap = TreeMap(compareByDescending { mc.player.getPositionEyes(1f).distanceTo(it.getPositionEyes(1f)) }) + private val entityMap = TreeMap(compareByDescending { mc.player.getPositionEyes(1f).distanceTo(it.getPositionEyes(1f)) }) private val itemMap = TreeSet(compareByDescending { mc.player.getPositionEyes(1f).distanceTo(it.getCenter(1f)) }) private var updateTick = 0 @@ -403,7 +404,7 @@ object Nametags : Module( } } - private fun getContent(contentType: ContentType, entity: Entity) = when (contentType) { + private fun SafeClientEvent.getContent(contentType: ContentType, entity: Entity) = when (contentType) { ContentType.NONE -> { null } @@ -415,44 +416,56 @@ object Nametags : Module( TextComponent.TextElement(getEntityType(entity), GuiColors.text) } ContentType.TOTAL_HP -> { - if (entity !is EntityLivingBase) { - null - } else { + if (entity is EntityLivingBase) { val totalHp = MathUtils.round(entity.health + entity.absorptionAmount, 1).toString() TextComponent.TextElement(totalHp, getHpColor(entity)) + } else { + null } } ContentType.HP -> { - if (entity !is EntityLivingBase) { - null - } else { + if (entity is EntityLivingBase) { val hp = MathUtils.round(entity.health, 1).toString() TextComponent.TextElement(hp, getHpColor(entity)) + } else { + null } } ContentType.ABSORPTION -> { - if (entity !is EntityLivingBase || entity.absorptionAmount == 0f) { - null - } else { + if (entity is EntityLivingBase && entity.absorptionAmount != 0f) { val absorption = MathUtils.round(entity.absorptionAmount, 1).toString() TextComponent.TextElement(absorption, ColorHolder(234, 204, 32, GuiColors.text.a)) + } else { + null } } ContentType.PING -> { - if (entity !is EntityOtherPlayerMP) { - null + if (entity is EntityOtherPlayerMP) { + connection.getPlayerInfo(entity.uniqueID)?.responseTime?.let { + TextComponent.TextElement("${it}ms", pingColorGradient.get(it.toFloat()).apply { a = GuiColors.text.a }) + } } else { - val ping = mc.connection?.getPlayerInfo(entity.uniqueID)?.responseTime ?: 0 - TextComponent.TextElement("${ping}ms", pingColorGradient.get(ping.toFloat()).apply { a = GuiColors.text.a }) + null } } ContentType.DISTANCE -> { - val dist = MathUtils.round(mc.player.getDistance(entity), 1).toString() + val dist = MathUtils.round(player.getDistance(entity), 1).toString() TextComponent.TextElement("${dist}m", GuiColors.text) } ContentType.ENTITY_ID -> { TextComponent.TextElement("ID: ${entity.entityId}", GuiColors.text) } + ContentType.TOTEM_POP_COUNT -> { + // Note: The totem pop counting functionality is embedded in the TotemPopCounter module, + // hence, it needs to be active in order for this to work. + if (entity is EntityOtherPlayerMP) { + if (TotemPopCounter.isDisabled) TotemPopCounter.enable() + val count = TotemPopCounter.popCountMap.getOrDefault(entity, 0) + TextComponent.TextElement("PT: $count", GuiColors.text) + } else { + null + } + } } private fun getEntityType(entity: Entity) = entity.javaClass.simpleName.replace("Entity", "") From 889a6ed0ab64b266d4dc63bba42654550785c564 Mon Sep 17 00:00:00 2001 From: Maarten <50550545+mmvanheusden@users.noreply.github.com> Date: Sun, 8 Jan 2023 11:08:50 -0800 Subject: [PATCH 60/85] Slightly refactor and fix AntiLevitation (#431) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve AntiLevitation * Additional improvements and fixes * 🔨 --- .../module/modules/movement/AntiLevitation.kt | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AntiLevitation.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AntiLevitation.kt index b5c583210..63eefe459 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AntiLevitation.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AntiLevitation.kt @@ -18,24 +18,26 @@ import kotlin.math.sin object AntiLevitation : Module( name = "AntiLevitation", - description = "Removes levitation effect (boring) or abuse it (epic)", + description = "Abuses poor anticheat levitation checks", category = Category.MOVEMENT ) { private val mode by setting("Mode", Mode.LEGIT, description = "The AntiLevitation mode") /* Flight mode */ - private val vertical by setting("Only Vertical", false, { mode == Mode.FLIGHT }, description = "doesn't apply extra speed when enabled") - private val yMotion by setting("Y Motion", 0.002f, 0.0f..0.02f, 0.001f, { mode == Mode.FLIGHT }, description = "The Y Motion that is applied when moving to bypass the anticheat") - private val speed by setting("Speed", 0.28f, 0.15f..0.3f, 0.005f, { !vertical && mode == Mode.FLIGHT }, description = "The speed you fly at") - private val timer by setting("Timer Boost", true, { !vertical && mode == Mode.FLIGHT }, description = "Use timer for a slight speed boost") - private val timerSpeed by setting("Timer Speed", 1.15f, 1.1f..1.2f, 0.01f, { timer && !vertical && mode == Mode.FLIGHT }, description = "The timer modifier") + private val vertical by setting("No Speed Enhancements", false, { mode == Mode.FLIGHT }, description = "Only influences vertical movement") + private val yMotion by setting("Moving Motion UP", 0.002f, 0.0f..0.02f, 0.001f, { mode == Mode.FLIGHT }, description = "The Y motion that is applied when moving horizontally to bypass the anticheat") + private val sneakMotion by setting("Downward Motion", 0.49f, 0.0f..0.7f, 0.01f, { mode == Mode.FLIGHT }, description = "The downward motion that is applied when pressing sneak") + private val speed by setting("Flying Speed", 0.28f, 0.15f..0.3f, 0.005f, { !vertical && mode == Mode.FLIGHT }, description = "The speed you fly at") + private val timer by setting("Timer Boost", true, { !vertical && mode == Mode.FLIGHT }, description = "Use timer for slightly faster speeds") + private val timerSpeed by setting("Timer Speed", 1.088f, 1.1f..1.2f, 0.01f, { timer && !vertical && mode == Mode.FLIGHT }, description = "The timer modifier") /* Legit mode */ - private val legitYMotion by setting("Motion Up", 0.018f, 0.001f..0.1f, 0.001f, { mode == Mode.LEGIT }, description = "The Y Motion that is applied when moving to bypass the anticheat") - private val boost by setting("Sprint Boost", true, { mode == Mode.LEGIT }, description = "Gives you extra motion when control is pressed") + private val legitYMotion by setting("Legit Constant Motion UP", 0.018f, 0.001f..0.1f, 0.001f, { mode == Mode.LEGIT }, description = "The Y motion that is applied when moving horizontally to bypass the anticheat") + private val boost by setting("Sprint Strafe", true, { mode == Mode.LEGIT }, description = "Removes air friction when holding sprint") + private val legitSneakMotion by setting("Legit Sneak Motion", 0.005f, 0.001f..0.01f, 0.001f, { mode == Mode.LEGIT }, description = "The upward motion that is applied when pressing sneak") /* Jump motion (used by flight mode and legit mode) */ - private val jumpMotion by setting("Jump Motion", 0.099f, 0.090f..0.10f, 0.001f, { mode == Mode.FLIGHT || mode == Mode.LEGIT }, description = "The Y Motion that is applied when you press space") + private val jumpMotion by setting("Jump Motion", 0.099f, 0.090f..0.20f, 0.001f, { mode == Mode.FLIGHT || mode == Mode.LEGIT }, description = "The upward motion that is applied when you press space") private var ready = false @@ -78,10 +80,13 @@ object AntiLevitation : Module( setSpeed(speed.toDouble()) if (timer && !vertical) modifyTimer(50.0f / timerSpeed) } else { + resetTimer() player.motionY = 0.0 - /* Make the motion slowly become 0, so it flattens out smooth */ - player.motionX *= 0.8 - player.motionZ *= 0.8 + if (!vertical) { + //TODO: figure out how to smooth out velocity equally + player.motionX = 0.0 + player.motionZ = 0.0 + } } if (MovementUtils.isInputting || player.isMoving) { @@ -89,13 +94,16 @@ object AntiLevitation : Module( } if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY = jumpMotion.toDouble() - if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = -0.49 + if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = -sneakMotion.toDouble() } else if (mode == Mode.LEGIT) { /* Override vanilla motion with our own motion */ - player.motionY = legitYMotion.toDouble() + if (mc.gameSettings.keyBindJump.isKeyDown) { + player.motionY = jumpMotion.toDouble() + } else { + player.motionY = legitYMotion.toDouble() + } - if (mc.gameSettings.keyBindJump.isKeyDown) player.motionY = jumpMotion.toDouble() - if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = 0.005 + if (mc.gameSettings.keyBindSneak.isKeyDown) player.motionY = legitSneakMotion.toDouble() if (mc.gameSettings.keyBindSprint.isKeyDown && player.isSprinting && boost) { //player must be sprinting so you can only boost when you press W val yaw = calcMoveYaw() From 7312d3c942c7eb1b85ea388987d742e53fc700f3 Mon Sep 17 00:00:00 2001 From: Snowshoe <20788786+SnowshoeIceboot@users.noreply.github.com> Date: Sun, 8 Jan 2023 13:24:45 -0700 Subject: [PATCH 61/85] Added AutoExcuse external file mode and more excuses (#409) * Make AutoExcuse external only * Changed var name in AutoExcuse.kt * In-Order option for AutoExcuse * Remove unused import * Brought back default excuses :) * More excuses Co-authored-by: Constructor --- .../client/module/modules/chat/AutoExcuse.kt | 98 +++++++++++++------ 1 file changed, 69 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt index 229d87665..0501eb9df 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.chat import com.lambda.client.LambdaMod +import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category @@ -10,11 +11,15 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage +import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.safeListener +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import net.minecraft.init.Items import net.minecraft.network.play.server.SPacketUpdateHealth import net.minecraft.util.EnumHand import java.io.File +import kotlin.random.Random object AutoExcuse : Module( name = "AutoExcuse", @@ -22,15 +27,27 @@ object AutoExcuse : Module( category = Category.CHAT, modulePriority = 500 ) { - private val mode by setting("Mode", Mode.INTERNAL) + private val modeSetting by setting("Order", Mode.RANDOM_ORDER) + private val modeSource by setting("Source", SourceMode.INTERNAL) + + private val file = File(FolderUtils.lambdaFolder + "excuses.txt") + private val loadedExcuses = ArrayList().synchronized() + private var currentLine = 0 + + private val timer = TickTimer(TimeUnit.SECONDS) private enum class Mode { + IN_ORDER, RANDOM_ORDER + } + + private enum class SourceMode { INTERNAL, EXTERNAL } private const val CLIENT_NAME = "%CLIENT%" + private val defaultExcuses = arrayOf( - "Sorry, im using $CLIENT_NAME client", + "Sorry, im using $CLIENT_NAME", "My ping is so bad", "I was changing my config :(", "Why did my AutoTotem break", @@ -39,10 +56,10 @@ object AutoExcuse : Module( "Wow, so many try hards", "Lagggg", "I wasn't trying", - "I'm not using $CLIENT_NAME client", + "I'm not using $CLIENT_NAME", "Thers to much lag", "My dog ate my pc", - "Sorry, $CLIENT_NAME Client is really bad", + "Sorry, $CLIENT_NAME is really bad", "I was lagging", "He was cheating!", "Your hacking!", @@ -52,48 +69,59 @@ object AutoExcuse : Module( "My wifi went down", "I'm playing vanila", "My optifine didn't work", - "The CPU cheated!" + "The CPU cheated!", + "I am using a cracked client", + "My brother was playing.", + "Phobos hacked my pc!!", + "I didn't have enough totems", + "I died for you <3", + "I was trying the popbob exploit!!", + "Sorry, let me relog with ${LambdaMod.NAME}", + "I was alt tabbing", + "I was trying out a new mod", ) - private val file = File(FolderUtils.lambdaFolder + "excuses.txt") - private var loadedExcuses = defaultExcuses - private val clients = arrayOf( - "Future", + "Future Client", "Salhack", "Pyro", "Impact" ) - private val timer = TickTimer(TimeUnit.SECONDS) - init { safeListener { if (loadedExcuses.isEmpty() || it.packet !is SPacketUpdateHealth) return@safeListener if (it.packet.health <= 0.0f && !isHoldingTotem && timer.tick(3L)) { - sendServerMessage(getExcuse()) + val message = if (modeSetting == Mode.IN_ORDER) getOrdered() else getRandom() + sendServerMessage(message.replace("%CLIENT%", clients.random())) } } onEnable { - loadedExcuses = if (mode == Mode.EXTERNAL) { - if (file.exists()) { - val cacheList = ArrayList() - try { - file.forEachLine { if (it.isNotBlank()) cacheList.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!") - } catch (e: Exception) { - LambdaMod.LOG.error("Failed loading excuses", e) + loadedExcuses.clear() + currentLine = 0 + + when (modeSource) { + SourceMode.INTERNAL -> loadedExcuses.addAll(defaultExcuses) + SourceMode.EXTERNAL -> { + defaultScope.launch(Dispatchers.IO) { + if (!file.exists()) { + file.createNewFile() + MessageSendHelper.sendErrorMessage("$chatName Excuses file is empty!" + + ", please add them in the &7excuses.txt&f under the &7.minecraft/lambda&f directory.") + disable() + return@launch + } + + try { + file.forEachLine { if (it.isNotBlank()) loadedExcuses.add(it.trim()) } + MessageSendHelper.sendChatMessage("$chatName Loaded excuse messages!") + } catch (e: Exception) { + MessageSendHelper.sendErrorMessage("$chatName Failed loading excuses, $e") + disable() + } } - cacheList.toTypedArray() - } else { - file.createNewFile() - MessageSendHelper.sendErrorMessage("$chatName Excuses file is empty!" + - ", please add them in the &7excuses.txt&f under the &7.minecraft/lambda&f directory.") - defaultExcuses } - } else { - defaultExcuses } } } @@ -101,5 +129,17 @@ object AutoExcuse : Module( private val SafeClientEvent.isHoldingTotem: Boolean get() = EnumHand.values().any { player.getHeldItem(it).item == Items.TOTEM_OF_UNDYING } - private fun getExcuse() = loadedExcuses.random().replace(CLIENT_NAME, clients.random()) + private fun getOrdered(): String { + currentLine %= loadedExcuses.size + return loadedExcuses[currentLine++] + } + + private fun getRandom(): String { + val prevLine = currentLine + // Avoids sending the same message + while (loadedExcuses.size != 1 && currentLine == prevLine) { + currentLine = Random.nextInt(loadedExcuses.size) + } + return loadedExcuses[currentLine] + } } From b252f97ab150d640f38f3bd2e88b627d9dcd2684 Mon Sep 17 00:00:00 2001 From: Constructor Date: Tue, 10 Jan 2023 08:30:19 +0100 Subject: [PATCH 62/85] Upgrade Kotlin 1.7.21 -> 1.8.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bd25efc90..f6230a5dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,5 +10,5 @@ forgeVersion=14.23.5.2860 mappingsChannel=stable mappingsVersion=39-1.12 -kotlinVersion=1.7.21 +kotlinVersion=1.8.0 kotlinxCoroutinesVersion=1.6.4 From 97da101961e20a6930db61e3fe6dd054a3a0c698 Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Mon, 16 Jan 2023 02:47:57 +0000 Subject: [PATCH 63/85] Added Criticals -> Strict setting for packet crits (#461) * Added Criticals -> Strict setting for packet crits * Sorry Doogie but i dont like so many empty lines :D Co-authored-by: Constructor --- .../client/module/modules/combat/Criticals.kt | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt index d1b8473ae..e1dcb85f4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt @@ -5,6 +5,7 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.CriticalsUpdateWalkingEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerAttackEvent +import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.mixin.extension.isInWeb import com.lambda.client.mixin.extension.playerIsOnGround import com.lambda.client.mixin.extension.playerMoving @@ -32,6 +33,7 @@ object Criticals : Module( private val mode by setting("Mode", Mode.EDIT) private val jumpMotion by setting("Jump Motion", 0.25, 0.1..0.5, 0.01, { mode == Mode.MINI_JUMP }, fineStep = 0.001) private val attackFallDistance by setting("Attack Fall Distance", 0.1, 0.05..1.0, 0.05, { mode == Mode.MINI_JUMP || mode == Mode.JUMP }) + private val strict by setting("Strict", true, visibility = { mode == Mode.PACKET }) private enum class Mode(override val displayName: String) : DisplayEnum { PACKET("Packet"), @@ -43,6 +45,7 @@ object Criticals : Module( private var delayTick = -1 private var target: Entity? = null private var spoofedY = -1337.0 + private var moveTick = 69 override fun isActive(): Boolean { return isEnabled && !delaying() @@ -66,30 +69,32 @@ object Criticals : Module( safeListener { if (it.packet is CPacketAnimation - && mode != Mode.PACKET + && mode == Mode.MINI_JUMP || mode == Mode.JUMP && delayTick > -1 ) { it.cancel() return@safeListener } - if (it.packet is CPacketPlayer - && mode == Mode.EDIT - ) { - // the advantage of this is that it doesn't delay anything and doesn't send extra packets - if (player.onGround) { - if (spoofedY <= 0) { - spoofedY = .01 - } else { - spoofedY -= .00001 + if (it.packet is CPacketPlayer) { + if (mode == Mode.EDIT) { + // the advantage of this is that it doesn't delay anything and doesn't send extra packets + if (player.onGround) { + if (spoofedY <= 0) { + spoofedY = .01 + } else { + spoofedY -= .00001 + } + } else spoofedY = -1337.0 + + it.packet.playerMoving = true + it.packet.playerIsOnGround = false + + if (spoofedY >= 0) { + it.packet.playerY += spoofedY } - } else spoofedY = -1337.0 - - it.packet.playerMoving = true - it.packet.playerIsOnGround = false - - if (spoofedY >= 0) { - it.packet.playerY += spoofedY + } else if (mode == Mode.PACKET && strict && moveTick < 0) { + it.cancel() } } } @@ -103,8 +108,19 @@ object Criticals : Module( Mode.PACKET -> { if (!cooldownReady) return@safeListener - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.1, player.posZ, false)) - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY, player.posZ, false)) + if (strict) { + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.11, player.posZ, false)) + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.1100013579, player.posZ, false)) + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 1.3579E-6, player.posZ, false)) + + player.motionX = .0 + player.motionZ = .0 + + moveTick = -3 + } else { + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + 0.1, player.posZ, false)) + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY, player.posZ, false)) + } } Mode.JUMP -> { jumpAndCancel(it, cooldownReady, null) @@ -116,6 +132,14 @@ object Criticals : Module( } } + safeListener { + if (++moveTick < 0) { + player.motionX = .0 + player.motionY = .0 + player.motionZ = .0 + } + } + safeListener { event -> if (event.phase != TickEvent.Phase.END || mode == Mode.PACKET @@ -139,6 +163,7 @@ object Criticals : Module( private fun reset() { delayTick = -1 + moveTick = 69 target = null } From b9220e772733e5ba8082cb1fa938f925d33fdc0a Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Mon, 16 Jan 2023 04:43:04 +0000 Subject: [PATCH 64/85] Refactor Jesus (#402) * Rewrite the old KAMI Jesus * Refactor * Fix build * Fix jump prevention not working Co-authored-by: Constructor --- .../mixin/MixinStateImplementation.java | 8 +- .../events/AddCollisionBoxToListEvent.kt | 10 + .../client/module/modules/movement/Jesus.kt | 217 +++++++++++++----- 3 files changed, 182 insertions(+), 53 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt diff --git a/src/main/java/com/lambda/mixin/MixinStateImplementation.java b/src/main/java/com/lambda/mixin/MixinStateImplementation.java index 209588a58..9272b984b 100644 --- a/src/main/java/com/lambda/mixin/MixinStateImplementation.java +++ b/src/main/java/com/lambda/mixin/MixinStateImplementation.java @@ -1,9 +1,12 @@ package com.lambda.mixin; +import com.lambda.client.event.LambdaEventBus; +import com.lambda.client.event.events.AddCollisionBoxToListEvent; import com.lambda.client.module.modules.movement.Jesus; import com.lambda.client.module.modules.render.Xray; import net.minecraft.block.Block; import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; @@ -26,7 +29,10 @@ public class MixinStateImplementation { @Inject(method = "addCollisionBoxToList", at = @At("HEAD")) public void addCollisionBoxToList(World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn, boolean isActualState, CallbackInfo ci) { - Jesus.handleAddCollisionBoxToList(pos, block, entityIn, collidingBoxes); + + if (entityIn instanceof EntityPlayerSP) + LambdaEventBus.INSTANCE.post(new AddCollisionBoxToListEvent(collidingBoxes)); + } @Inject(method = "shouldSideBeRendered", at = @At("HEAD"), cancellable = true) diff --git a/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt b/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt new file mode 100644 index 000000000..ba9f3eaa6 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/events/AddCollisionBoxToListEvent.kt @@ -0,0 +1,10 @@ +package com.lambda.client.event.events + +import com.lambda.client.event.Event +import net.minecraft.util.math.AxisAlignedBB + +/** + * @author Doogie13 + * @since 06/10/2022 + */ +class AddCollisionBoxToListEvent(val collisionBoxList : MutableList) : Event \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 659f3263b..fb8f2fbad 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -1,98 +1,211 @@ package com.lambda.client.module.modules.movement -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.event.SafeClientEvent +import com.lambda.client.event.events.AddCollisionBoxToListEvent import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent -import com.lambda.client.mixin.extension.playerMoving +import com.lambda.client.event.events.PlayerMoveEvent +import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.EntityUtils +import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP import net.minecraft.block.Block -import net.minecraft.block.BlockLiquid -import net.minecraft.entity.Entity -import net.minecraft.entity.item.EntityBoat +import net.minecraft.init.Blocks import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.AxisAlignedBB import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.BlockPos.PooledMutableBlockPos +import net.minecraftforge.client.event.InputUpdateEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import kotlin.math.ceil +import kotlin.math.floor +import kotlin.math.hypot + object Jesus : Module( name = "Jesus", description = "Allows you to walk on water", category = Category.MOVEMENT ) { - private val mode by setting("Mode", Mode.SOLID) - private enum class Mode { - SOLID, DOLPHIN + private val mode by setting("Mode", Mode.STRICT) + + enum class Mode { + SOLID, + STRICT, + DOLPHIN } - private val waterWalkBox = AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.99, 1.0) + private val preventJump by setting("Prevent Jumping", false, { mode == Mode.SOLID || mode == Mode.STRICT }, description = "Prevent jumping when using Jesus") + + private val bb = AxisAlignedBB(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0) + private val liquids = listOf(Blocks.WATER, Blocks.FLOWING_WATER, Blocks.LAVA, Blocks.FLOWING_LAVA) + + private var ticksEnabled = 0 + private var fakeY = 0.0 init { - onToggle { - BaritoneUtils.settings?.assumeWalkOnWater?.value = it + onDisable { + ticksEnabled = 0 + fakeY = .0 } - safeListener { - if (mc.gameSettings.keyBindSneak.isKeyDown || player.fallDistance > 3.0f || !isInWater(player)) return@safeListener + safeListener { + if (it.phase != TickEvent.Phase.START) return@safeListener - if (mode == Mode.DOLPHIN) { - player.motionY += 0.03999999910593033 // regular jump speed - } else { - player.motionY = 0.1 + ticksEnabled++ + } - player.ridingEntity?.let { - if (it !is EntityBoat) it.motionY = 0.3 - } + safeListener { + if (mc.gameSettings.keyBindSneak.isKeyDown) + return@safeListener + + if ((mode == Mode.SOLID || mode == Mode.STRICT) + && world.getBlockState(BlockPos(player.positionVector.add(.0, -.1 + player.motionY, .0))).material.isLiquid + ) { + it.collisionBoxList.add(bb.offset(player.posX, floor(player.posY), player.posZ)) } } - safeListener { - if (it.packet !is CPacketPlayer || !it.packet.playerMoving) return@safeListener - if (mc.gameSettings.keyBindSneak.isKeyDown || player.ticksExisted % 2 != 0) return@safeListener + safeListener { event -> + (player as AccessorEntityPlayerSP).lcSetLastReportedPosY(-99.9) + + if (mc.gameSettings.keyBindSneak.isKeyDown) return@safeListener - val entity = player.ridingEntity ?: player + (player as AccessorEntityPlayerSP).lcSetLastReportedPosY(-999.0) - if (EntityUtils.isAboveLiquid(entity, true) && !isInWater(entity)) { - it.packet.playerY += 0.02 + if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { + event.y = (.11.also { player.motionY = it }) + } + + if (player.onGround && + !checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, -.01, .0), + liquids + Blocks.AIR + ) + ) { + when (mode) { + Mode.DOLPHIN -> { + if (hypot(event.x, event.y) > .2873 * .9) { + event.x *= .95 + event.z *= .95 + } + } + Mode.STRICT -> { + val lava = !checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, -.01, .0), + listOf(Blocks.AIR, Blocks.LAVA, Blocks.FLOWING_LAVA) + ) + // .38 is from lava liquid speed at max speed, 1.24 is from water liquid speed at max speed + // because of the way "Lambda Client" handled its "PlayerMoveEvent" I have to use "magic numbers" to compensate + event.x *= if (lava) .57 else 1.09 + event.z *= if (lava) .57 else 1.09 + } + + else -> {} + } } } - } - @JvmStatic - fun handleAddCollisionBoxToList(pos: BlockPos, block: Block, entity: Entity?, collidingBoxes: MutableList) { - if (isDisabled || mode == Mode.DOLPHIN) return - if (mc.gameSettings.keyBindSneak.isKeyDown) return - if (block !is BlockLiquid) return - if (entity == null || entity is EntityBoat) return + safeListener { + if (preventJump && + fakeY != .0 + ) it.movementInput.jump = false + } - val player = mc.player ?: return - if (player.fallDistance > 3.0f) return + safeListener { event -> + if (event.packet !is CPacketPlayer) return@safeListener - if (entity != player && entity != player.ridingEntity) return - if (isInWater(entity) || entity.posY < pos.y) return - if (!EntityUtils.isAboveLiquid(entity)) return + if (mc.gameSettings.keyBindSneak.isKeyDown) { + if (mode == Mode.STRICT) { + player.posY -= fakeY + } - collidingBoxes.add(waterWalkBox.offset(pos)) - } + fakeY = 0.0 + return@safeListener + } + + val playerBB = player.entityBoundingBox + if (player.isInWater + || !world.getBlockState(BlockPos(player.positionVector.add(.0, -.1 + player.motionY, .0))).material.isLiquid + || world.getCollisionBoxes(player, playerBB.offset(0.0, -.0001, 0.0)).isEmpty() + ) { + fakeY = 0.0 + return@safeListener + } + + val packet = event.packet + + when (mode) { + Mode.STRICT -> { + if ((-.4).coerceAtLeast(fakeY).also { fakeY = it } > -.4) { + fakeY -= .08 + fakeY *= .98 + packet.playerY += fakeY + } else { + packet.playerY += fakeY - if (ticksEnabled % 2 == 0) .0 else -.00001 + } + + if (checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), + liquids + Blocks.AIR + )) { + packet.playerY = player.posY + } + } + Mode.SOLID -> { + fakeY = 0.0 - private fun isInWater(entity: Entity): Boolean { - mc.world?.let { - val y = (entity.posY + 0.01).floorToInt() + if (ticksEnabled % 2 == 0) packet.playerY -= .001 - for (x in entity.posX.floorToInt() until entity.posX.ceilToInt()) { - for (z in entity.posZ.floorToInt() until entity.posZ.ceilToInt()) { - val pos = BlockPos(x, y, z) - if (it.getBlockState(pos).block is BlockLiquid) return true + if (checkBlockCollisionNoLiquid( + player.entityBoundingBox.offset(.0, packet.playerY - player.posY, .0), + liquids + Blocks.AIR + )) { + packet.playerY = player.posY + } } + + else -> {} } } - return false + safeListener { + if (it.packet !is SPacketPlayerPosLook) return@safeListener + + fakeY = player.posY - it.packet.y + } } + private fun SafeClientEvent.checkBlockCollisionNoLiquid(bb: AxisAlignedBB, allowed: List): Boolean { + val minX = floor(bb.minX).toInt() + val maxX = ceil(bb.maxX).toInt() + val minY = floor(bb.minY).toInt() + val maxY = ceil(bb.maxY).toInt() + val minZ = floor(bb.minZ).toInt() + val maxZ = ceil(bb.maxZ).toInt() + + val mutableBlockPos = PooledMutableBlockPos.retain() + + for (x in minX until maxX) { + for (y in minY until maxY) { + for (z in minZ until maxZ) { + val blockState = world.getBlockState(mutableBlockPos.setPos(x, y, z)) + + if (!allowed.contains(blockState.block)) { + mutableBlockPos.release() + return true + } + } + } + } + + mutableBlockPos.release() + return false + } } \ No newline at end of file From b2921f6dde0879b3a86bb9b7803d399ff9f9bca7 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Tue, 17 Jan 2023 00:30:11 +0100 Subject: [PATCH 65/85] AutoArmor: Add "Allow Elytra" setting (#460) * AutoArmor: Add "Allow Elytra" setting This patch introduces the "Allow Elytra" setting in the AutoArmor module, which lets the user chose whether AutoArmor will replace their equipped elytra with a chestplate (allowElytra = false) or not (allowElytra = true) :^) * Fix grammar Co-authored-by: Constructor --- .../com/lambda/client/module/modules/combat/AutoArmor.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt index 752943522..13b6743d9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt @@ -19,10 +19,12 @@ import net.minecraftforge.fml.common.gameevent.TickEvent object AutoArmor : Module( name = "AutoArmor", - description = "Automatically equips armour", + description = "Automatically equips armor", category = Category.COMBAT, modulePriority = 500 ) { + private val allowElytra by setting("Allow Elytra", false, description = "If activated it will not replace an equipped elytra with a chestplate") + init { safeListener { // store slots and values of best armor pieces, initialize with currently equipped armor @@ -37,8 +39,8 @@ object AutoArmor : Module( val armorType = item.armorType.index - // Skip if item is chestplate and we have elytra equipped - if (armorType == 2 && player.inventory.armorInventory[2].item == Items.ELYTRA) continue + // Skip if allowElytra is activated, item is chestplate, and we have elytra equipped + if (allowElytra && armorType == 2 && player.inventory.armorInventory[2].item == Items.ELYTRA) continue val armorValue = getArmorValue(itemStack) if (armorValue > bestArmors[armorType].second) { From c9e2045478bbdfd17c2bed286c5266c86a11fa40 Mon Sep 17 00:00:00 2001 From: Blade <98755526+INotBLADE@users.noreply.github.com> Date: Tue, 17 Jan 2023 20:36:12 +0200 Subject: [PATCH 66/85] Add NoPush setting check for noblockpush (#465) --- .../com/lambda/client/module/modules/movement/Velocity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt index ad7c49538..1651ee380 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt @@ -61,7 +61,7 @@ object Velocity : Module( } safeListener { - if (block) it.cancel() + if (noPush && block) it.cancel() } } From c408288b4b7dcbe7d4c091535881ad50b8a2516b Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Tue, 17 Jan 2023 18:36:57 +0000 Subject: [PATCH 67/85] Flight -> Static patch (#464) --- .../com/lambda/client/module/modules/movement/Flight.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt index 3d5802147..83818de2e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt @@ -232,8 +232,8 @@ object Flight : Module( return@safeListener val yaw = calcMoveYaw() - player.motionX -= sin(yaw) * speed - player.motionZ += cos(yaw) * speed + player.motionX = -sin(yaw) * speed + player.motionZ = cos(yaw) * speed } FlightMode.VANILLA -> { From 85bcf1516e07a3414a93a246c491b44bb038401b Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Tue, 17 Jan 2023 19:40:21 +0100 Subject: [PATCH 68/85] HUD: Show time using primary and secondary colors (#463) * Allow for custom separators in the TextComponent * HUD: Show time using primary and secondary colors Before this patch the time was always shown as white. Now we show the time/date's numeric characters in the primary color and the non numeric characters in the secondary color :) --- .../lambda/client/gui/hudgui/AbstractLabelHud.kt | 3 ++- .../com/lambda/client/gui/hudgui/LabelHud.kt | 5 +++-- .../lambda/client/gui/hudgui/elements/misc/Time.kt | 14 +++++++++++--- .../client/util/graphics/font/TextComponent.kt | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt index 486c7655e..c3659ea21 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt @@ -18,12 +18,13 @@ abstract class AbstractLabelHud( alwaysListening: Boolean, enabledByDefault: Boolean, config: AbstractConfig, + separator: String = " ", ) : AbstractHudElement(name, alias, category, description, alwaysListening, enabledByDefault, config) { override val hudWidth: Float get() = displayText.getWidth() + 2.0f override val hudHeight: Float get() = displayText.getHeight(2) - protected val displayText = TextComponent() + protected val displayText = TextComponent(separator) init { safeAsyncListener { diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/LabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/LabelHud.kt index f0346ebdd..0af258316 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/LabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/LabelHud.kt @@ -10,6 +10,7 @@ internal abstract class LabelHud( category: Category, description: String, alwaysListening: Boolean = false, - enabledByDefault: Boolean = false -) : AbstractLabelHud(name, alias, category, description, alwaysListening, enabledByDefault, GuiConfig), + enabledByDefault: Boolean = false, + separator: String = " ", +) : AbstractLabelHud(name, alias, category, description, alwaysListening, enabledByDefault, GuiConfig, separator), SettingRegister by GuiConfig \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt index c8253a905..3ee127185 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Time.kt @@ -7,7 +7,8 @@ import com.lambda.client.util.TimeUtils internal object Time : LabelHud( name = "Time", category = Category.MISC, - description = "System date and time" + description = "System date and time", + separator = "", ) { private val showDate = setting("Show Date", true) @@ -17,8 +18,15 @@ internal object Time : LabelHud( private val timeUnit = setting("Time Unit", TimeUtils.TimeUnit.H12, { showTime.value }) override fun SafeClientEvent.updateText() { - if (showDate.value) displayText.addLine(TimeUtils.getDate(dateFormat.value)) - if (showTime.value) displayText.addLine(TimeUtils.getTime(timeFormat.value, timeUnit.value)) + if (showDate.value) { + val date = TimeUtils.getDate(dateFormat.value) + date.forEach { displayText.add(it.toString(), if (it.isDigit()) primaryColor else secondaryColor) } + displayText.addLine("") + } + if (showTime.value) { + val time = TimeUtils.getTime(timeFormat.value, timeUnit.value) + time.forEach { displayText.add(it.toString(), if (it.isDigit()) primaryColor else secondaryColor) } + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/graphics/font/TextComponent.kt b/src/main/kotlin/com/lambda/client/util/graphics/font/TextComponent.kt index 521af6eac..03728517c 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/font/TextComponent.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/font/TextComponent.kt @@ -147,7 +147,7 @@ class TextComponent(private val separator: String = " ") { val color = textElement.color.clone() color.a = (color.a * alpha).toInt() FontRenderAdapter.drawString(textElement.text, drawShadow = drawShadow, color = color, customFont = customFont, scale = textElement.scale) - val adjustedSeparator = if (separator == " " && customFont) " " else " " + val adjustedSeparator = " ".repeat(if (customFont && separator != "") max(separator.length * 1, 1) else separator.length) glTranslatef(FontRenderAdapter.getStringWidth(textElement.text + adjustedSeparator, customFont = customFont), 0f, 0f) } @@ -155,7 +155,7 @@ class TextComponent(private val separator: String = " ") { } fun getWidth(customFont: Boolean = FontRenderAdapter.useCustomFont): Float { - val adjustedSeparator = if (separator == " " && customFont) " " else " " + val adjustedSeparator = " ".repeat(if (customFont && separator != "") max(separator.length * 1, 1) else separator.length) val string = textElementList.joinToString(separator = adjustedSeparator) return FontRenderAdapter.getStringWidth(string, customFont = customFont) } From 414581bbe2047aa3637b0c1671585ff8ff2b3003 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Wed, 18 Jan 2023 01:37:17 +0100 Subject: [PATCH 69/85] StashLogger: Show the time and date when a stash is found (#466) * StashLogger: Show the time and date when a stash is found After this patch we now show the date and time at which the "stash" was found. This is information which could be useful for the users to better identify the stash after afk hunting. * Remove unnecessary imports Co-authored-by: Constructor --- .../com/lambda/client/module/modules/misc/StashLogger.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt index cefd60fd3..042e5684f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt @@ -25,6 +25,8 @@ import net.minecraft.tileentity.* import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos import net.minecraftforge.fml.common.gameevent.TickEvent +import java.text.SimpleDateFormat +import java.util.* import kotlin.math.roundToInt object StashLogger : Module( @@ -96,7 +98,8 @@ object StashLogger : Module( if (logToChat) { val positionString = center.asString() - MessageSendHelper.sendChatMessage("$chatName Found $string at ($positionString) ") + val timeStr = SimpleDateFormat.getDateTimeInstance().format(Calendar.getInstance().time) + MessageSendHelper.sendChatMessage("$chatName Found $string at ($positionString) [$timeStr]") } found = true From 24746e4822329517342b93a868b77f8ee1c7a491 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Sun, 22 Jan 2023 04:54:28 +0100 Subject: [PATCH 70/85] InventoryManager: Mending help mode (#458) * InventoryManager: Add "helpMend" setting This setting helps you mend items while being AFK (made thinking about AFK fishing) by replacing the offhand item with low HP items of the same type that have the mending enchantment. * Cleanup Co-authored-by: Constructor --- .../module/modules/player/InventoryManager.kt | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt index 4d84f6168..c4cf875d4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt @@ -12,8 +12,11 @@ import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.items.* +import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.enchantment.EnchantmentHelper +import net.minecraft.init.Enchantments import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.gameevent.TickEvent @@ -43,10 +46,11 @@ object InventoryManager : Module( private val fullOnly by setting("Only At Full", false, { autoEject }) private val pauseMovement by setting("Pause Movement", true) private val delay by setting("Delay Ticks", 1, 0..20, 1, unit = " ticks") + private val helpMend by setting("Help Mend", false, description = "Helps mending items by replacing the offhand item with low HP items of the same type") val ejectList = setting(CollectionSetting("Eject List", defaultEjectList)) enum class State { - IDLE, SAVING_ITEM, REFILLING_BUILDING, REFILLING, EJECTING + IDLE, SAVING_ITEM, HELPING_MEND, REFILLING_BUILDING, REFILLING, EJECTING } private var currentState = State.IDLE @@ -78,6 +82,7 @@ object InventoryManager : Module( when (currentState) { State.SAVING_ITEM -> saveItem() + State.HELPING_MEND -> helpMend() State.REFILLING_BUILDING -> refillBuilding() State.REFILLING -> refill() State.EJECTING -> eject() @@ -91,6 +96,7 @@ object InventoryManager : Module( private fun SafeClientEvent.setState() { currentState = when { saveItemCheck() -> State.SAVING_ITEM + helpMendCheck() -> State.HELPING_MEND refillBuildingCheck() -> State.REFILLING_BUILDING refillCheck() -> State.REFILLING ejectCheck() -> State.EJECTING @@ -111,6 +117,12 @@ object InventoryManager : Module( return itemSaver && checkDamage(player.heldItemMainhand) } + private fun SafeClientEvent.helpMendCheck() : Boolean { + return helpMend + && (player.heldItemOffhand.itemDamage == 0 + || EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, player.heldItemOffhand) == 0) + } + private fun SafeClientEvent.refillBuildingCheck(): Boolean { if (!autoRefill || !buildingMode || buildingBlockID == 0) return false @@ -154,6 +166,17 @@ object InventoryManager : Module( } } + private fun SafeClientEvent.helpMend() { + player.inventorySlots.filterByStack { + it.item == player.heldItemOffhand.item + && EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, it) != 0 + && it.itemDamage != 0 + }.firstOrNull()?.let { + MessageSendHelper.sendChatMessage("$chatName Switching offhand to another item (Help Mend).") + moveToSlot(this@InventoryManager, it, player.offhandSlot) + } + } + private fun SafeClientEvent.refillBuilding() { player.storageSlots.firstID(buildingBlockID)?.let { quickMoveSlot(this@InventoryManager, it) From 81e9f30dcbd389658ab3a7cdd3b29eef51d42fda Mon Sep 17 00:00:00 2001 From: Constructor Date: Mon, 23 Jan 2023 04:37:17 +0100 Subject: [PATCH 71/85] Increase cohesion for ElytraFix --- .../EntityLivingBaseFireworkHelper.java | 33 ------------------- .../mixin/entity/MixinEntityLivingBase.java | 12 +++---- .../lambda/mixin/render/MixinViewFrustum.java | 1 - .../client/module/modules/misc/ElytraFix.kt | 15 +++++++++ 4 files changed, 21 insertions(+), 40 deletions(-) delete mode 100644 src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java diff --git a/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java b/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java deleted file mode 100644 index 21112abde..000000000 --- a/src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.lambda; - -import com.lambda.client.module.modules.movement.ElytraFlight; -import com.lambda.mixin.accessor.AccessorEntityFireworkRocket; -import com.lambda.mixin.entity.MixinEntityLivingBase; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.entity.EntityLivingBase; - -/** - * Using {@link AccessorEntityFireworkRocket} in {@link MixinEntityLivingBase} causes a crash on older - * Mixin versions (like the one Impact uses). Putting the methods using AccessorEntityFireworkRocket outside - * the MixinEntityLivingBase seems to fix the issue. - */ -public class EntityLivingBaseFireworkHelper { - public static boolean shouldWork(EntityLivingBase entity) { - return EntityPlayerSP.class.isAssignableFrom(entity.getClass()) - && ElytraFlight.INSTANCE.isEnabled() - && ElytraFlight.INSTANCE.getMode().getValue() == ElytraFlight.ElytraFlightMode.VANILLA; - } - - public static boolean shouldModify(EntityLivingBase entity) { - return shouldWork(entity) && entity.world.loadedEntityList.stream().anyMatch(firework -> { - if (firework instanceof AccessorEntityFireworkRocket) { - EntityLivingBase boosted = ((AccessorEntityFireworkRocket) firework).getBoostedEntity(); - return boosted != null && boosted.equals(entity); - } - - return false; - } - ); - } - -} diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java b/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java index 285031014..69f2f4743 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java @@ -1,6 +1,6 @@ package com.lambda.mixin.entity; -import com.lambda.EntityLivingBaseFireworkHelper; +import com.lambda.client.module.modules.misc.ElytraFix; import com.lambda.client.module.modules.movement.ElytraFlight; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -31,7 +31,7 @@ public MixinEntityLivingBase(World worldIn) { at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/EntityLivingBase;getLookVec()Lnet/minecraft/util/math/Vec3d;", ordinal = 0) ) private Vec3d vec3d(Vec3d original) { - if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) { + if (ElytraFix.INSTANCE.shouldWork(EntityLivingBase.class.cast(this))) { float negPacketPitch = -ElytraFlight.INSTANCE.getPacketPitch(); float f0 = MathHelper.cos((float) (-this.rotationYaw * 0.017453292f - Math.PI)); float f1 = MathHelper.sin((float) (-this.rotationYaw * 0.017453292f - Math.PI)); @@ -49,7 +49,7 @@ private Vec3d vec3d(Vec3d original) { ordinal = 3 ) private float f(float original) { - if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) { + if (ElytraFix.INSTANCE.shouldWork(EntityLivingBase.class.cast(this))) { return ElytraFlight.INSTANCE.getPacketPitch() * 0.017453292f; } return original; @@ -76,7 +76,7 @@ private void getVec( at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionX:D", ordinal = 7) ) public double motionX(EntityLivingBase it) { - if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { + if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) { it.motionX += modifiedVec.x * 0.1 + (modifiedVec.x * 1.5 - this.motionX) * 0.5; } return it.motionX; @@ -87,7 +87,7 @@ public double motionX(EntityLivingBase it) { at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionY:D", ordinal = 7) ) public double motionY(EntityLivingBase it) { - if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { + if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) { it.motionY += modifiedVec.y * 0.1 + (modifiedVec.y * 1.5 - this.motionY) * 0.5; } return it.motionY; @@ -98,7 +98,7 @@ public double motionY(EntityLivingBase it) { at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionZ:D", ordinal = 7) ) public double motionZ(EntityLivingBase it) { - if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) { + if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) { it.motionZ += modifiedVec.z * 0.1 + (modifiedVec.z * 1.5 - this.motionZ) * 0.5; } return it.motionZ; diff --git a/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java b/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java index cbc69c5c6..74cc187af 100644 --- a/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java +++ b/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java @@ -12,7 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// TODO: Find a working fix of this for optifine @Mixin(ViewFrustum.class) public abstract class MixinViewFrustum { @Shadow public RenderChunk[] renderChunks; diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt index 3aa3e6836..fe53767c9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt @@ -4,7 +4,11 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.mixin.extension.boostedEntity import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.module.modules.movement.ElytraFlight import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.accessor.AccessorEntityFireworkRocket +import net.minecraft.client.entity.EntityPlayerSP +import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityFireworkRocket import net.minecraft.network.play.server.SPacketPlayerPosLook @@ -22,4 +26,15 @@ object ElytraFix : Module( } } } + + fun shouldWork(entity: EntityLivingBase) = EntityPlayerSP::class.java.isAssignableFrom(entity.javaClass) + && ElytraFlight.isEnabled + && ElytraFlight.mode.value == ElytraFlight.ElytraFlightMode.VANILLA + + fun shouldModify(entity: EntityLivingBase) = shouldWork(entity) + && entity.world.loadedEntityList + .filterIsInstance() + .any { + it.boostedEntity.equals(entity) + } } \ No newline at end of file From 5d2f7debdc5587f68f678216fbdb1ccae1b92afc Mon Sep 17 00:00:00 2001 From: CozyMeli-gitv2 <110065125+CozyMeli-gitv2@users.noreply.github.com> Date: Mon, 23 Jan 2023 02:26:57 -0500 Subject: [PATCH 72/85] Updated a bundle of module descriptions (#473) * Updated BedAura module description Just updated the wording a little * Updated MidClickPearl module description Shortened the description a little bit, removed automatically entirely from the sentence as I believe it is self explanatory without it. * Updated module description Just changed Modify to Modifies as that is a better word to use in this scenario, being the correct word used to refer to another person, or in this scenario a program/module! * Updated module description Extremely minor, just swapped when to from. Just a better word overall to use in this context * Updated module description Auto remount allows you to automatically remount not just a horse, but a boat, donkey, pig, and a few more entities, so I changed horse to rideable entities to better describe the function of the module. --- .../kotlin/com/lambda/client/module/modules/combat/BedAura.kt | 4 ++-- .../com/lambda/client/module/modules/combat/MidClickPearl.kt | 4 ++-- .../com/lambda/client/module/modules/movement/AntiHunger.kt | 4 ++-- .../com/lambda/client/module/modules/movement/AutoRemount.kt | 4 ++-- .../com/lambda/client/module/modules/render/BossStack.kt | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt index 924e75596..4eb7b146b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt @@ -38,7 +38,7 @@ import java.util.* @CombatManager.CombatModule object BedAura : Module( name = "BedAura", - description = "Place bed and kills enemies", + description = "Places beds to kill enemies", category = Category.COMBAT, modulePriority = 70 ) { @@ -231,4 +231,4 @@ object BedAura : Module( private fun SafeClientEvent.resetRotation() { lastRotation = Vec2f(RotationUtils.normalizeAngle(player.rotationYaw), player.rotationPitch) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/MidClickPearl.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/MidClickPearl.kt index 4a5d758ee..c20a8bb79 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/MidClickPearl.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/MidClickPearl.kt @@ -16,7 +16,7 @@ import org.lwjgl.input.Mouse object MidClickPearl : Module( name = "MidClickPearl", - description = "Throws a pearl automatically when you middle click in air", + description = "Throws a pearl upon middle clicking in the air", category = Category.COMBAT ) { private var prevSlot = -1 @@ -54,4 +54,4 @@ object MidClickPearl : Module( } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AntiHunger.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AntiHunger.kt index bbca6e3be..752d3f295 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AntiHunger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AntiHunger.kt @@ -14,7 +14,7 @@ import net.minecraft.network.play.client.CPacketPlayer */ object AntiHunger : Module( name = "AntiHunger", - description = "Reduces hunger lost when moving around", + description = "Reduces hunger lost from moving around", category = Category.MOVEMENT ) { private val cancelMovementState by setting("Cancel Movement State", true) @@ -35,4 +35,4 @@ object AntiHunger : Module( } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt index 1d67e1664..54f5093c5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoRemount.kt @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent object AutoRemount : Module( name = "AutoRemount", - description = "Automatically remounts your horse", + description = "Automatically remounts your ridable entity", category = Category.MOVEMENT ) { private val boat by setting("Boats", true) @@ -59,4 +59,4 @@ object AutoRemount : Module( || pig && entity is EntityPig && entity.saddled || llama && entity is EntityLlama) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt index 24b2b2961..3161c6a42 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt @@ -19,7 +19,7 @@ import kotlin.math.roundToInt object BossStack : Module( name = "BossStack", - description = "Modify the boss health GUI to take up less space", + description = "Modifies the boss health GUI to take up less space", category = Category.RENDER ) { private val mode by setting("Mode", BossStackMode.STACK) @@ -132,4 +132,4 @@ object BossStack : Module( glColor4f(1.0f, 1.0f, 1.0f, 1.0f) mc.profiler.endSection() } -} \ No newline at end of file +} From fbeab41c5af8303fc1fd4b6819acf570ca37dad2 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Wed, 25 Jan 2023 03:26:59 +0100 Subject: [PATCH 73/85] Add "Server List" button in the Minecraft ESC GUI (#472) * Add "Server List" button in the Minecraft pause GUI This patch adds a new "Server List" button replacing the disabled "Open To Lan" button in the multiplayer pause menu :) * Optimize imports Co-authored-by: Constructor --- .../lambda/mixin/gui/MixinGuiIngameMenu.java | 26 +++++++++++++++---- .../lambda/mixin/gui/MixinGuiMultiplayer.java | 22 ++++++++++++++++ src/main/resources/mixins.lambda.json | 1 + 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java b/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java index 5eebdcffe..9f05b7ca7 100644 --- a/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiIngameMenu.java @@ -5,6 +5,7 @@ import com.lambda.client.util.Wrapper; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiIngameMenu; +import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.client.gui.GuiScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,11 +16,26 @@ public class MixinGuiIngameMenu extends GuiScreen { @Inject(method = "actionPerformed", at = @At("HEAD"), cancellable = true) public void actionPerformed(GuiButton button, CallbackInfo callbackInfo) { - if (button.id == 1) { - if (AntiDisconnect.INSTANCE.isEnabled()) { - Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect()); - callbackInfo.cancel(); - } + switch (button.id) { + case 1: + if (AntiDisconnect.INSTANCE.isEnabled()) { + Wrapper.getMinecraft().displayGuiScreen(new LambdaGuiAntiDisconnect()); + callbackInfo.cancel(); + } + break; + case Integer.MIN_VALUE: + Wrapper.getMinecraft().displayGuiScreen(new GuiMultiplayer(this)); + break; + default: + break; + } + } + + @Inject(method = "initGui", at = @At("RETURN")) + public void initGui(CallbackInfo ci) { + if (!mc.isSingleplayer()) { + GuiButton openToLanButton = buttonList.remove(4); + buttonList.add(new GuiButton(Integer.MIN_VALUE, openToLanButton.x, openToLanButton.y, openToLanButton.width, openToLanButton.height, "Server List")); } } } diff --git a/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java b/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java new file mode 100644 index 000000000..6c259edbf --- /dev/null +++ b/src/main/java/com/lambda/mixin/gui/MixinGuiMultiplayer.java @@ -0,0 +1,22 @@ +package com.lambda.mixin.gui; + +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.ServerData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiMultiplayer.class) +public class MixinGuiMultiplayer extends GuiScreen { + + @Inject(method = "connectToServer", at = @At("HEAD")) + public void connectToServer(ServerData serverData, CallbackInfo ci) { + if (mc.getCurrentServerData() != null && mc.world != null) { + mc.world.sendQuittingDisconnectingPacket(); + mc.loadWorld(null); + } + } + +} diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index 2ea5d021b..a67d4dceb 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -47,6 +47,7 @@ "gui.MixinGuiIngameMenu", "gui.MixinGuiInventory", "gui.MixinGuiMainMenu", + "gui.MixinGuiMultiplayer", "gui.MixinGuiNewChat", "gui.MixinGuiPlayerTabOverlay", "gui.MixinGuiScreen", From f974c6650b9e2d059ef1af741eaacc36587adae5 Mon Sep 17 00:00:00 2001 From: kaz2700 <113390987+kaz2700@users.noreply.github.com> Date: Wed, 25 Jan 2023 03:27:32 +0100 Subject: [PATCH 74/85] AutoOffhand: Set maximum hp threshold to 36 (#474) This is because when you eat a gapple you have 36 max health :P Co-authored-by: KazutoXD --- .../com/lambda/client/module/modules/combat/AutoOffhand.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 8e75e5a81..441782e46 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -37,7 +37,7 @@ object AutoOffhand : Module( private val type by setting("Type", Type.TOTEM) // Totem - private val hpThreshold by setting("Hp Threshold", 5f, 1f..20f, 0.5f, { type == Type.TOTEM }) + private val hpThreshold by setting("Hp Threshold", 5f, 1f..36f, 0.5f, { type == Type.TOTEM }) private val bindTotem by setting("Bind Totem", Bind(), { type == Type.TOTEM }) private val checkDamage by setting("Check Damage", true, { type == Type.TOTEM }) private val mob by setting("Mob", true, { type == Type.TOTEM && checkDamage }) From 9b5e4263c1f3003633fef7745c9717392fb11fd0 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 25 Jan 2023 12:07:45 -0800 Subject: [PATCH 75/85] Scaffold rewrite (#462) * Sketch * Working sketch * Better default settings * Fix rubberbanding * Fix previous block state and default settings * Fix placement selection * Scaffold rewrite Makes tower mode actually work and adds ghost blocks for increased placing speed tested working on 2b2t * Scaffold: don't swap to block if we already have one equipped * Scaffold: Whitelist/Blacklist/Any block selection modes * Fix tower teleports by moving back onto top block * merge rfresh+constructor scaffolds * Small changes * only tower when player is not moving * refactor block selection * Little cleanup * tower check hotbarspoof compat * in water tower check * water tower scaffold and place on water surface * small style * swap in blocks from inventory when not in hotbar * assign all settings to a page * Added NoFall enabler and boundary checks for placements * Build down mode * Missed this * tower: burrow check * improve water tower reliability * reset movement speed to slightly slower than normal during down scaffold * mc bingbong * Cleanup * prevent sneak place opening blacklisted blocks * barrier = undefined, prefer not sneaking ig * oneliner * Other defaults and prevent action on flight * Check for correct item * Use shulkerList * Ops i mean blacklist * Fix blockBlacklist * Seems to need both * Use utils * Revert unneeded code Co-authored-by: Constructor --- .../command/commands/ScaffoldCommand.kt | 109 ++++++ .../client/module/modules/player/NoFall.kt | 4 +- .../client/module/modules/player/Scaffold.kt | 315 +++++++++++++----- .../com/lambda/client/util/items/Block.kt | 50 ++- .../com/lambda/client/util/world/Check.kt | 4 +- .../com/lambda/client/util/world/Interact.kt | 25 +- 6 files changed, 398 insertions(+), 109 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt diff --git a/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt new file mode 100644 index 000000000..e4239b762 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/commands/ScaffoldCommand.kt @@ -0,0 +1,109 @@ +package com.lambda.client.command.commands + +import com.lambda.client.command.ClientCommand +import com.lambda.client.module.modules.player.Scaffold +import com.lambda.client.util.items.shulkerList +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.text.formatValue + +object ScaffoldCommand : ClientCommand( + name = "scaffold", + description = "Manage scaffold whitelist/blacklist" +) { + init { + literal("whitelist", "wl") { + literal("add", "+") { + literal("shulker_box") { + execute("Add all shulker box types to whitelist") { + Scaffold.blockSelectionWhitelist.editValue { whitelist -> shulkerList.forEach { whitelist.add(it.localizedName) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been added to whitelist") + } + } + block("block") { blockArg -> + execute("Add a block to Scaffold whitelist") { + val blockName = blockArg.value.registryName.toString() + if (Scaffold.blockSelectionWhitelist.contains(blockName)) { + MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold whitelist") + } else { + Scaffold.blockSelectionWhitelist.editValue { it.add(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold whitelist") + } + } + } + } + literal("del", "-") { + literal("shulker_box") { + execute("Remove all shulker box types from whitelist") { + Scaffold.blockSelectionWhitelist.editValue { whitelist -> shulkerList.forEach { whitelist.remove(it.localizedName) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been removed from whitelist") + } + } + block("block") { blockArg -> + execute("Removes a block from the Scaffold whitelist") { + val blockName = blockArg.value.registryName.toString() + Scaffold.blockSelectionWhitelist.editValue { it.remove(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold whitelist") + } + } + } + literal("clear", "c") { + execute { + Scaffold.blockSelectionWhitelist.editValue { it.clear() } + MessageSendHelper.sendChatMessage("Whitelist has been cleared") + } + } + literal("list") { + execute { + MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionWhitelist.joinToString()}") + } + } + } + literal("blacklist", "bl") { + literal("add", "+") { + literal("shulker_box") { + execute("Add all shulker box types to blacklist") { + Scaffold.blockSelectionBlacklist.editValue { blacklist -> shulkerList.forEach { blacklist.add(it.localizedName) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been added to blacklist") + } + } + block("block") { blockArg -> + execute("Add a block to Scaffold blacklist") { + val blockName = blockArg.value.registryName.toString() + if (Scaffold.blockSelectionBlacklist.contains(blockName)) { + MessageSendHelper.sendErrorMessage("${formatValue(blockName)} is already added to scaffold blacklist") + } else { + Scaffold.blockSelectionBlacklist.editValue { it.add(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been added to scaffold blacklist") + } + } + } + } + literal("del", "-") { + literal("shulker_box") { + execute("Remove all shulker box types from blacklist") { + Scaffold.blockSelectionBlacklist.editValue { blacklist -> shulkerList.forEach { blacklist.remove(it.localizedName) } } + MessageSendHelper.sendChatMessage("All shulker boxes have been removed from blacklist") + } + } + block("block") { blockArg -> + execute("Removes a block from the Scaffold blacklist") { + val blockName = blockArg.value.registryName.toString() + Scaffold.blockSelectionBlacklist.editValue { it.remove(blockName) } + MessageSendHelper.sendChatMessage("${formatValue(blockName)} has been removed from scaffold blacklist") + } + } + } + literal("clear", "c") { + execute { + Scaffold.blockSelectionBlacklist.editValue { it.clear() } + MessageSendHelper.sendChatMessage("Blacklist has been cleared") + } + } + literal("list") { + execute { + MessageSendHelper.sendChatMessage("Blocks: ${Scaffold.blockSelectionBlacklist.joinToString()}") + } + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt index d2debd413..13db8316a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoFall.kt @@ -27,12 +27,12 @@ object NoFall : Module( category = Category.PLAYER ) { private val distance by setting("Distance", 3, 1..10, 1) - private val mode by setting("Mode", Mode.CATCH) + var mode by setting("Mode", Mode.CATCH) private val fallModeSetting by setting("Fall", FallMode.PACKET, { mode == Mode.FALL }) private val catchModeSetting by setting("Catch", CatchMode.MOTION, { mode == Mode.CATCH }) private val voidOnly by setting("Void Only", false, { mode == Mode.CATCH }) - private enum class Mode { + enum class Mode { FALL, CATCH } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index f33e6d938..979610a49 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -1,41 +1,46 @@ package com.lambda.client.module.modules.player +import com.lambda.client.LambdaMod +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.Phase import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.events.* import com.lambda.client.event.listener.listener -import com.lambda.client.manager.managers.HotbarManager.resetHotbar import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.EntityUtils.prevPosVector +import com.lambda.client.module.modules.player.Scaffold.isUsableItem +import com.lambda.client.setting.settings.impl.collection.CollectionSetting +import com.lambda.client.util.EntityUtils.flooredPosition +import com.lambda.client.util.MovementUtils.speed import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.items.HotbarSlot -import com.lambda.client.util.items.firstItem -import com.lambda.client.util.items.hotbarSlots -import com.lambda.client.util.items.swapToSlot +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.ESPRenderer +import com.lambda.client.util.items.* import com.lambda.client.util.math.RotationUtils.getRotationTo -import com.lambda.client.util.math.VectorUtils.toBlockPos import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour +import com.lambda.client.util.world.isFullBox import com.lambda.client.util.world.placeBlock import com.lambda.mixin.entity.MixinEntity +import net.minecraft.block.Block +import net.minecraft.block.state.IBlockState +import net.minecraft.init.Blocks +import net.minecraft.item.Item import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction +import net.minecraft.network.play.server.SPacketBlockChange import net.minecraft.network.play.server.SPacketPlayerPosLook -import net.minecraft.util.EnumFacing import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.RayTraceResult -import net.minecraft.util.math.Vec3d -import kotlin.math.floor -import kotlin.math.roundToInt +import net.minecraftforge.client.event.InputUpdateEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent +import java.util.concurrent.ConcurrentHashMap /** * @see MixinEntity.moveInvokeIsSneakingPre @@ -47,44 +52,131 @@ object Scaffold : Module( category = Category.PLAYER, modulePriority = 500 ) { - private val tower by setting("Tower", true) - private val spoofHotbar by setting("Spoof Hotbar", true) - val safeWalk by setting("Safe Walk", true) - private val sneak by setting("Sneak", true) - private val strictDirection by setting("Strict Direction", false) - private val delay by setting("Delay", 2, 1..10, 1, unit = " ticks") - private val maxRange by setting("Max Range", 1, 0..3, 1) - - private var lastHitVec: Vec3d? = null + private val page by setting("Page", Page.GENERAL) + + private val blockSelectionMode by setting("Block Selection Mode", ScaffoldBlockSelectionMode.ANY, { page == Page.GENERAL }) + private val tower by setting("Tower", true, { page == Page.GENERAL }) + private val spoofHotbar by setting("Spoof Hotbar", true, { page == Page.GENERAL }) + val safeWalk by setting("Safe Walk", true, { page == Page.GENERAL }) + private val useNoFall by setting("No Fall", false, { page == Page.GENERAL }) + private val descendOnSneak by setting("Descend on sneak", true, { page == Page.GENERAL }) + private val visibleSideCheck by setting("Visible side check", true, { page == Page.GENERAL }) + private val delay by setting("Delay", 0, 0..10, 1, { page == Page.GENERAL }, unit = " ticks") + private val timeout by setting("Timeout", 15, 1..40, 1, { page == Page.GENERAL }, unit = " ticks") + private val attempts by setting("Placement Search Depth", 3, 0..7, 1, { page == Page.GENERAL }) + private val maxPending by setting("Max Pending", 3, 0..10, 1, { page == Page.GENERAL }) + private val below by setting("Max Tower Distance", 0.3, 0.0..2.0, 0.01, { page == Page.GENERAL }) + private val filled by setting("Filled", true, { page == Page.RENDER }, description = "Renders surfaces") + private val outline by setting("Outline", true, { page == Page.RENDER }, description = "Renders outline") + private val alphaFilled by setting("Alpha Filled", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Alpha for surfaces") + private val alphaOutline by setting("Alpha Outline", 26, 0..255, 1, { outline && page == Page.RENDER }, description = "Alpha for outline") + private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") + private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255), visibility = { page == Page.RENDER }) + + val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", blockBlacklist.map { it.registryName.toString() }.toMutableSet(), { false })) + + private enum class Page { + GENERAL, RENDER + } + + private enum class ScaffoldBlockSelectionMode( + override val displayName: String, + val filter: (Item) -> Boolean): DisplayEnum { + ANY("Any", { it.isUsableItem() }), + WHITELIST("Whitelist", { blockSelectionWhitelist.contains(it.registryName.toString()) && it.isUsableItem() }), + BLACKLIST("Blacklist", { !blockSelectionBlacklist.contains(it.registryName.toString()) && it.isUsableItem() }) + } + private var placeInfo: PlaceInfo? = null - private var inactiveTicks = 69 + private val renderer = ESPRenderer() private val placeTimer = TickTimer(TimeUnit.TICKS) - private val rubberBandTimer = TickTimer(TimeUnit.TICKS) + private val towerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private val waterTowerTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private val posLookTimer: TickTimer = TickTimer(TimeUnit.TICKS) + private var oldNoFall = false + private var oldFallMode = NoFall.Mode.CATCH + private var goDown = false - override fun isActive(): Boolean { - return isEnabled && inactiveTicks <= 5 - } + private val pendingBlocks = ConcurrentHashMap() init { + onEnable { + towerTimer.reset() + + if (!useNoFall) return@onEnable + + oldNoFall = NoFall.isEnabled + oldFallMode = NoFall.mode + + NoFall.mode = NoFall.Mode.CATCH + NoFall.enable() + } + onDisable { placeInfo = null - inactiveTicks = 69 + pendingBlocks.clear() + + if (!useNoFall) return@onDisable + if (!oldNoFall) NoFall.disable() + + NoFall.mode = oldFallMode + oldNoFall = false } - listener { - if (it.packet !is SPacketPlayerPosLook) return@listener - rubberBandTimer.reset() + safeListener { event -> + when (val packet = event.packet) { + is SPacketPlayerPosLook -> { + pendingBlocks.forEach { + world.setBlockState(it.key, it.value.blockState) + } + pendingBlocks.clear() + posLookTimer.reset() + } + is SPacketBlockChange -> { + pendingBlocks.remove(packet.blockPosition) + } + } } safeListener { - if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || inactiveTicks > 5 || !isHoldingBlock) return@safeListener - if (rubberBandTimer.tick(10, false)) { - if (shouldTower) player.motionY = 0.41999998688697815 - } else if (player.fallDistance <= 2.0f) { - player.motionY = -0.169 + if (!tower || !mc.gameSettings.keyBindJump.isKeyDown || !isHoldingBlock || !posLookTimer.tick(15, false)) { + towerTimer.reset() + return@safeListener + } + if (player.isInWater || world.getBlockState(player.flooredPosition).material.isLiquid) { + player.motionY = .11 + towerTimer.reset() + waterTowerTimer.reset() + } else if (shouldTower) { + if (waterTowerTimer.tick(5, false)) { + player.jump() + if (towerTimer.tick(30)) { + // reset pos back onto top block + player.motionY = -0.3 + } + } else { + towerTimer.reset() + } } } + + listener { + renderer.aFilled = if (filled) alphaFilled else 0 + renderer.aOutline = if (outline) alphaOutline else 0 + renderer.thickness = thickness + + pendingBlocks.keys.forEach { + renderer.add(it, pendingBlockColor) + } + + renderer.render(clear = true) + } + + safeListener { + if (tower) it.cancel() + } } private val SafeClientEvent.isHoldingBlock: Boolean @@ -92,80 +184,127 @@ object Scaffold : Module( private val SafeClientEvent.shouldTower: Boolean get() = !player.onGround - && player.posY - floor(player.posY) <= 0.1 + && world.getCollisionBoxes(player, player.entityBoundingBox.offset(0.0, -below, 0.0)).isNotEmpty() + && world.getCollisionBoxes(player, player.entityBoundingBox).isEmpty() + && !player.capabilities.isFlying + && player.speed < 0.1 + && (getHeldScaffoldBlock() != null || getBlockSlot() != null) init { - safeListener { event -> - if (event.phase != Phase.PRE) return@safeListener + safeListener { event -> + if (event.phase != TickEvent.Phase.START) return@safeListener - inactiveTicks++ - placeInfo = calcNextPos()?.let { - getNeighbour(it, 1, visibleSideCheck = strictDirection, sides = arrayOf(EnumFacing.DOWN)) - ?: getNeighbour(it, 3, visibleSideCheck = strictDirection, sides = EnumFacing.HORIZONTALS) - } - - placeInfo?.let { - lastHitVec = it.hitVec - swapAndPlace(it) - } + pendingBlocks.values + .filter { it.age > timeout * 50L } + .forEach { pendingBlock -> + LambdaMod.LOG.warn("$chatName Timeout: ${pendingBlock.blockPos}") + pendingBlocks.remove(pendingBlock.blockPos) + world.setBlockState(pendingBlock.blockPos, pendingBlock.blockState) + } - if (inactiveTicks > 5) { - resetHotbar() - } else if (isHoldingBlock) { - lastHitVec?.let { + placeInfo?.let { placeInfo -> + pendingBlocks[placeInfo.placedPos]?.let { + if (it.age < timeout * 50L) { + return@safeListener + } + } + swap()?.let { block -> + place(placeInfo, block) sendPlayerPacket { - rotate(getRotationTo(it)) + rotate(getRotationTo(placeInfo.hitVec)) } } } } - } - private fun SafeClientEvent.calcNextPos(): BlockPos? { - val posVec = player.positionVector - val blockPos = posVec.toBlockPos() - return checkPos(blockPos) - ?: run { - val realMotion = posVec.subtract(player.prevPosVector) - val nextPos = blockPos.add(roundToRange(realMotion.x), 0, roundToRange(realMotion.z)) - checkPos(nextPos) + safeListener { event -> + if (event.phase != Phase.PRE) return@safeListener + + val origin = if (goDown && descendOnSneak) { + goDown = false + player.flooredPosition.down(2) + } else { + player.flooredPosition.down() } - } - private fun SafeClientEvent.checkPos(blockPos: BlockPos): BlockPos? { - val center = Vec3d(blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) - val rayTraceResult = world.rayTraceBlocks( - center, - center.subtract(0.0, 0.5, 0.0), - false, - true, - false - ) - return blockPos.down().takeIf { rayTraceResult?.typeOfHit != RayTraceResult.Type.BLOCK } - } + placeInfo = getNeighbour( + BlockPos(origin.x, origin.y.coerceIn(0..256), origin.z), + attempts, + visibleSideCheck = visibleSideCheck + ) + } + + safeListener { + if (!descendOnSneak + || !it.movementInput.sneak + || player.capabilities.isFlying + ) return@safeListener - private fun roundToRange(value: Double) = - (value * 2.5 * maxRange).roundToInt().coerceAtMost(maxRange) + goDown = true + it.movementInput.sneak = false + it.movementInput.moveStrafe *= 5f + it.movementInput.moveForward *= 5f + } + } - private fun SafeClientEvent.swapAndPlace(placeInfo: PlaceInfo) { + private fun SafeClientEvent.swap(): Block? { + getHeldScaffoldBlock()?.let { return it } getBlockSlot()?.let { slot -> if (spoofHotbar) spoofHotbar(slot) else swapToSlot(slot) + return slot.stack.item.block + } + if (swapToBlockOrMove(this@Scaffold, { blockSelectionMode.filter(it.item) } )) { + getBlockSlot()?.let { slot -> + if (spoofHotbar) spoofHotbar(slot) + else swapToSlot(slot) + return slot.stack.item.block + } + } + return null + } - inactiveTicks = 0 + private fun SafeClientEvent.place(placeInfo: PlaceInfo, blockToPlace: Block) { + if (placeTimer.tick(delay.toLong()) + && pendingBlocks.size < maxPending + ) { + val isBlacklisted = world.getBlockState(placeInfo.pos).block in blockBlacklist || blockToPlace in blockBlacklist - if (placeTimer.tick(delay.toLong())) { - val shouldSneak = sneak && !player.isSneaking - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) - placeBlock(placeInfo) - if (shouldSneak) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) - } + if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.START_SNEAKING)) + + placeBlock(placeInfo) + + if (isBlacklisted) connection.sendPacket(CPacketEntityAction(player, CPacketEntityAction.Action.STOP_SNEAKING)) + + pendingBlocks[placeInfo.placedPos] = PendingBlock(placeInfo.placedPos, world.getBlockState(placeInfo.placedPos), blockToPlace) + world.setBlockState(placeInfo.placedPos, Blocks.BARRIER.defaultState) } } + private fun SafeClientEvent.getHeldScaffoldBlock(): Block? { + playerController.syncCurrentPlayItem() + if (blockSelectionMode.filter(player.heldItemMainhand.item)) { + return player.heldItemMainhand.item.block + } + if (blockSelectionMode.filter(player.heldItemOffhand.item)) { + return player.heldItemOffhand.item.block + } + return null + } + private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { playerController.syncCurrentPlayItem() - return player.hotbarSlots.firstItem() + return player.hotbarSlots.firstItem { blockSelectionMode.filter(it.item) } + } + + private data class PendingBlock( + val blockPos: BlockPos, + val blockState: IBlockState, + val block: Block, + val timestamp: Long = System.currentTimeMillis() + ) { + val age get() = System.currentTimeMillis() - timestamp } + private fun Item.isUsableItem() = this is ItemBlock && block.defaultState.isFullBox } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/items/Block.kt b/src/main/kotlin/com/lambda/client/util/items/Block.kt index b67e3ad22..cd9184b88 100644 --- a/src/main/kotlin/com/lambda/client/util/items/Block.kt +++ b/src/main/kotlin/com/lambda/client/util/items/Block.kt @@ -24,19 +24,53 @@ val shulkerList: Set = hashSetOf( ) val blockBlacklist: Set = hashSetOf( - Blocks.ENDER_CHEST, - Blocks.CHEST, - Blocks.TRAPPED_CHEST, - Blocks.CRAFTING_TABLE, Blocks.ANVIL, + Blocks.BEACON, + Blocks.BED, Blocks.BREWING_STAND, - Blocks.HOPPER, - Blocks.DROPPER, + Blocks.STONE_BUTTON, + Blocks.WOODEN_BUTTON, + Blocks.CAKE, + Blocks.CAULDRON, + Blocks.CHEST, + Blocks.TRAPPED_CHEST, + Blocks.COMMAND_BLOCK, + Blocks.CHAIN_COMMAND_BLOCK, + Blocks.REPEATING_COMMAND_BLOCK, + Blocks.DAYLIGHT_DETECTOR, + Blocks.DAYLIGHT_DETECTOR_INVERTED, Blocks.DISPENSER, - Blocks.TRAPDOOR, + Blocks.DROPPER, + Blocks.OAK_DOOR, + Blocks.DARK_OAK_DOOR, + Blocks.ACACIA_DOOR, + Blocks.BIRCH_DOOR, + Blocks.JUNGLE_DOOR, + Blocks.SPRUCE_DOOR, Blocks.ENCHANTING_TABLE, + Blocks.ENDER_CHEST, + Blocks.OAK_FENCE_GATE, + Blocks.ACACIA_FENCE_GATE, + Blocks.BIRCH_FENCE_GATE, + Blocks.DARK_OAK_FENCE_GATE, + Blocks.JUNGLE_FENCE_GATE, + Blocks.SPRUCE_FENCE_GATE, + Blocks.FLOWER_POT, + Blocks.FURNACE, + Blocks.HOPPER, + Blocks.JUKEBOX, + Blocks.LEVER, + Blocks.NOTEBLOCK, + Blocks.POWERED_COMPARATOR, + Blocks.UNPOWERED_COMPARATOR, + Blocks.REDSTONE_ORE, + Blocks.POWERED_REPEATER, + Blocks.UNPOWERED_REPEATER, Blocks.STANDING_SIGN, - Blocks.WALL_SIGN + Blocks.WALL_SIGN, + Blocks.STRUCTURE_BLOCK, + Blocks.TRAPDOOR, + Blocks.CRAFTING_TABLE, ).apply { addAll(shulkerList) } diff --git a/src/main/kotlin/com/lambda/client/util/world/Check.kt b/src/main/kotlin/com/lambda/client/util/world/Check.kt index 6225435fb..9e25de3d2 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Check.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Check.kt @@ -107,4 +107,6 @@ fun SafeClientEvent.hasNeighbour(pos: BlockPos): Boolean { */ fun World.isPlaceable(pos: BlockPos, ignoreSelfCollide: Boolean = false) = this.getBlockState(pos).isReplaceable - && this.checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) Wrapper.player else null) \ No newline at end of file + && checkNoEntityCollision(AxisAlignedBB(pos), if (ignoreSelfCollide) Wrapper.player else null) + && worldBorder.contains(pos) + && !isOutsideBuildHeight(pos) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/world/Interact.kt b/src/main/kotlin/com/lambda/client/util/world/Interact.kt index 30d10fe41..1b09e15ed 100644 --- a/src/main/kotlin/com/lambda/client/util/world/Interact.kt +++ b/src/main/kotlin/com/lambda/client/util/world/Interact.kt @@ -83,18 +83,23 @@ private fun SafeClientEvent.getNeighbour( sides: Array, toIgnore: HashSet> ): PlaceInfo? { - for (side in sides) { - val result = checkNeighbour(eyePos, pos, side, range, visibleSideCheck, true, toIgnore) - if (result != null) return result + if (!world.isPlaceable(pos)) return null + + sides.forEach { side -> + checkNeighbour(eyePos, pos, side, range, visibleSideCheck, true, toIgnore)?.let { + return it + } } - if (attempts > 1) { - for (side in sides) { - val newPos = pos.offset(side) - if (!world.isPlaceable(newPos)) continue + if (attempts < 2) return null + + sides.forEach { posSide -> + val newPos = pos.offset(posSide) + if (!world.isPlaceable(newPos)) return@forEach + if (eyePos.distanceTo(newPos.toVec3dCenter()) > range + 1) return@forEach - return getNeighbour(eyePos, newPos, attempts - 1, range, visibleSideCheck, sides, toIgnore) - ?: continue + getNeighbour(eyePos, newPos, attempts - 1, range, visibleSideCheck, sides, toIgnore)?.let { + return it } } @@ -286,4 +291,4 @@ fun SafeClientEvent.placeBlock( } private fun PlaceInfo.toPlacePacket(hand: EnumHand) = - CPacketPlayerTryUseItemOnBlock(this.pos, this.side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file + CPacketPlayerTryUseItemOnBlock(pos, side, hand, hitVecOffset.x.toFloat(), hitVecOffset.y.toFloat(), hitVecOffset.z.toFloat()) \ No newline at end of file From c593f8a6b55274522f815213c915bb1e0c04563f Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Tue, 31 Jan 2023 18:52:08 -0800 Subject: [PATCH 76/85] Freecam Schematica Compatibility (#481) --- .../mixin/render/MixinRenderGlobal.java | 16 ++++++ .../lambda/mixin/render/MixinViewFrustum.java | 53 ------------------- .../client/module/modules/player/Freecam.kt | 12 ++++- src/main/resources/mixins.lambda.json | 5 +- 4 files changed, 28 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/com/lambda/mixin/render/MixinViewFrustum.java diff --git a/src/main/java/com/lambda/mixin/render/MixinRenderGlobal.java b/src/main/java/com/lambda/mixin/render/MixinRenderGlobal.java index 08e69085b..9c87939c4 100644 --- a/src/main/java/com/lambda/mixin/render/MixinRenderGlobal.java +++ b/src/main/java/com/lambda/mixin/render/MixinRenderGlobal.java @@ -5,7 +5,10 @@ import com.lambda.client.event.events.RenderEntityEvent; import com.lambda.client.module.modules.player.Freecam; import com.lambda.client.module.modules.render.SelectionHighlight; +import com.lambda.client.util.Wrapper; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.ViewFrustum; import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -15,6 +18,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(RenderGlobal.class) @@ -50,4 +54,16 @@ public BlockPos setupTerrainStoreFlooredChunkPosition(BlockPos playerPos) { return playerPos; } + + @Redirect(method = "setupTerrain", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ViewFrustum;updateChunkPositions(DD)V")) + public void updateSetupTerrain(ViewFrustum viewFrustum, double viewEntityX, double viewEntityZ) { + if (Freecam.INSTANCE.isEnabled()) { + EntityPlayerSP player = Wrapper.getPlayer(); + if (player != null) { + viewEntityX = player.posX; + viewEntityZ = player.posZ; + } + } + viewFrustum.updateChunkPositions(viewEntityX, viewEntityZ); + } } diff --git a/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java b/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java deleted file mode 100644 index 74cc187af..000000000 --- a/src/main/java/com/lambda/mixin/render/MixinViewFrustum.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.lambda.mixin.render; - -import com.lambda.client.module.modules.player.Freecam; -import com.lambda.client.util.Wrapper; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.ViewFrustum; -import net.minecraft.client.renderer.chunk.RenderChunk; -import net.minecraft.util.math.MathHelper; -import org.spongepowered.asm.mixin.Mixin; -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; - -@Mixin(ViewFrustum.class) -public abstract class MixinViewFrustum { - @Shadow public RenderChunk[] renderChunks; - @Shadow protected int countChunksX; - @Shadow protected int countChunksY; - @Shadow protected int countChunksZ; - - @Shadow - protected abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_); - - @Inject(method = "updateChunkPositions", at = @At("HEAD"), cancellable = true) - public void updateChunkPositionsHead(double viewEntityX, double viewEntityZ, CallbackInfo ci) { - if (Freecam.INSTANCE.isDisabled()) return; - - EntityPlayerSP player = Wrapper.getPlayer(); - if (player == null) return; - - int centerX = MathHelper.floor(player.posX) - 8; - int centerZ = MathHelper.floor(player.posZ) - 8; - - int multipliedCountX = this.countChunksX * 16; - - for (int x = 0; x < this.countChunksX; ++x) { - int posX = this.getBaseCoordinate(centerX, multipliedCountX, x); - - for (int z = 0; z < this.countChunksZ; ++z) { - int poxZ = this.getBaseCoordinate(centerZ, multipliedCountX, z); - - for (int y = 0; y < this.countChunksY; ++y) { - int poxY = y * 16; - RenderChunk renderchunk = this.renderChunks[(z * this.countChunksY + y) * this.countChunksX + x]; - renderchunk.setPosition(posX, poxY, poxZ); - } - } - } - - ci.cancel(); - } -} diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt index 6b16ac72f..0cc763aa6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt @@ -23,12 +23,13 @@ import com.lambda.client.util.threads.onMainThreadSafe import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import kotlinx.coroutines.runBlocking -import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.multiplayer.WorldClient +import net.minecraft.client.network.NetHandlerPlayClient import net.minecraft.entity.Entity import net.minecraft.entity.MoverType import net.minecraft.entity.player.EntityPlayer +import net.minecraft.network.Packet import net.minecraft.network.play.client.CPacketUseEntity import net.minecraft.network.play.server.SPacketEntityHeadLook import net.minecraft.util.MovementInput @@ -265,7 +266,7 @@ object Freecam : Module( } } - private class FakeCamera(world: WorldClient, val player: EntityPlayerSP) : EntityOtherPlayerMP(world, mc.session.profile) { + private class FakeCamera(world: WorldClient, val player: EntityPlayerSP) : EntityPlayerSP(mc, world, NoOpNetHandlerPlayerClient(player.connection), player.statFileWriter, player.recipeBook) { init { copyLocationAndAnglesFrom(player) capabilities.allowFlying = true @@ -276,6 +277,7 @@ object Freecam : Module( // Update inventory inventory.copyInventory(player.inventory) + this.movementInput = MovementInput() // Update yaw head updateEntityActionState() @@ -331,6 +333,12 @@ object Freecam : Module( override fun isInvisibleToPlayer(player: EntityPlayer) = true } + private class NoOpNetHandlerPlayerClient(realNetHandler: NetHandlerPlayClient) : NetHandlerPlayClient(mc, null, realNetHandler.networkManager, realNetHandler.gameProfile) { + override fun sendPacket(packetIn: Packet<*>) { + // no packets from freecam player, thanks + } + } + /** * @param forward * @param strafe diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index a67d4dceb..13f8ec477 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -24,11 +24,11 @@ "accessor.network.AccessorCPacketPlayer", "accessor.network.AccessorCPacketUseEntity", "accessor.network.AccessorSPacketChat", + "accessor.network.AccessorSPacketEntity", + "accessor.network.AccessorSPacketEntityHeadLook", "accessor.network.AccessorSPacketEntityVelocity", "accessor.network.AccessorSPacketExplosion", "accessor.network.AccessorSPacketPosLook", - "accessor.network.AccessorSPacketEntity", - "accessor.network.AccessorSPacketEntityHeadLook", "accessor.player.AccessorEntityPlayerSP", "accessor.player.AccessorPlayerControllerMP", "accessor.render.AccessorRenderGlobal", @@ -75,7 +75,6 @@ "render.MixinTileEntityRendererDispatcher", "render.MixinTileEntitySignRenderer", "render.MixinTileRendererDispatcher", - "render.MixinViewFrustum", "render.MixinVisGraph", "world.MixinBlock", "world.MixinBlockDragonEgg", From 0bc8bdd3a6e1634ef89fdd38dec81f55d0132549 Mon Sep 17 00:00:00 2001 From: Blade <98755526+INotBLADE@users.noreply.github.com> Date: Wed, 1 Feb 2023 05:10:50 +0200 Subject: [PATCH 77/85] Update Flight.kt (#479) Added value listener to mode setting, check inside onEnable --- .../client/module/modules/movement/Flight.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt index 83818de2e..aed08412e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt @@ -33,7 +33,9 @@ object Flight : Module( modulePriority = 500 ) { // non packet - private val mode by setting("Mode", FlightMode.PACKET) + private val mode by setting("Mode", FlightMode.PACKET).also { + it.listeners.add { if (it.value == FlightMode.PACKET) sendRubberbandPacket() } + } private val speed by setting("Speed", 1.0f, 0f..10f, 0.1f, { mode != FlightMode.PACKET }) private val glideSpeed by setting("Glide Speed", 0.05, 0.0..0.3, 0.001, { mode != FlightMode.PACKET }) @@ -82,11 +84,8 @@ object Flight : Module( } onEnable { - runSafeR { - val position = CPacketPlayer.Position(.0, .0, .0, true) - filter.add(position) - connection.sendPacket(position) - } ?: disable() + if (mode != FlightMode.PACKET) return@onEnable + sendRubberbandPacket() } safeListener { @@ -297,4 +296,12 @@ object Flight : Module( } } + + private fun sendRubberbandPacket(){ + runSafeR { + val position = CPacketPlayer.Position(.0, .0, .0, true) + filter.add(position) + connection.sendPacket(position) + } ?: disable() + } } From efac3989f8f1e67f8210a99dc66a8b2a418cedad Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+Doogie13@users.noreply.github.com> Date: Wed, 1 Feb 2023 03:33:31 +0000 Subject: [PATCH 78/85] Step Rewrite (#477) * Rewrite Step entirely * Step * Some minor changes * Cleanup --------- Co-authored-by: Constructor --- .../com/lambda/mixin/entity/MixinEntity.java | 35 ++++ .../client/manager/managers/TimerManager.kt | 4 +- .../client/module/modules/movement/Step.kt | 170 +++++++----------- 3 files changed, 98 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index ef23be53d..06cc5bd0f 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -1,11 +1,15 @@ package com.lambda.mixin.entity; import com.lambda.client.module.modules.movement.SafeWalk; +import com.lambda.client.module.modules.movement.Step; import com.lambda.client.module.modules.movement.Velocity; import com.lambda.client.module.modules.player.Freecam; import com.lambda.client.module.modules.player.ViewLock; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.MoverType; +import net.minecraft.util.math.AxisAlignedBB; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,7 +21,9 @@ public abstract class MixinEntity { @Shadow private int entityId; + @Shadow private AxisAlignedBB boundingBox; private boolean modifiedSneaking = false; + float storedStepHeight = -1; @Inject(method = "applyEntityCollision", at = @At("HEAD"), cancellable = true) public void applyEntityCollisionHead(Entity entityIn, CallbackInfo ci) { @@ -48,4 +54,33 @@ public void turn(float yaw, float pitch, CallbackInfo ci) { if (Freecam.handleTurn(casted, yaw, pitch, ci)) return; ViewLock.handleTurn(casted, yaw, pitch, ci); } + + // these mixins are for step module before and after the step calculations are performed + @Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.stepHeight:F", ordinal = 3, shift = At.Shift.BEFORE)) + private void preStep(MoverType type, double x, double y, double z, CallbackInfo ci) { + EntityPlayerSP player = Minecraft.getMinecraft().player; + + if (player == null) return; + + if (entityId == player.getEntityId() + && Step.INSTANCE.isEnabled() + && !Step.INSTANCE.pre(boundingBox, player) + ) { + storedStepHeight = player.stepHeight; + player.stepHeight = Step.INSTANCE.getStrict() ? 1.015f : Step.INSTANCE.getUpStep().getValue(); + } + } + + @Inject(method = "move", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.resetPositionToBB ()V", ordinal = 1, shift = At.Shift.BEFORE)) + private void postStep(MoverType type, double x, double y, double z, CallbackInfo ci) { + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.player; + + if (player == null || !Step.INSTANCE.isEnabled()) return; + + if (entityId == player.getEntityId()) { + Step.INSTANCE.post(boundingBox, mc); + } + } + } diff --git a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt index e421a039d..1731c1093 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt @@ -21,8 +21,8 @@ object TimerManager : Manager { init { listener { - if (timer.tick(5L)) { - val removeTime = System.currentTimeMillis() - 250L + if (timer.tick(6L)) { + val removeTime = System.currentTimeMillis() - 600L modifications.values.removeIf { it.second < removeTime } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index f649cf49a..1e874a4e2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -1,150 +1,102 @@ package com.lambda.client.module.modules.movement -import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.listener.listener -import com.lambda.client.manager.managers.PlayerPacketManager -import com.lambda.client.mixin.extension.playerY +import com.lambda.client.manager.managers.TimerManager.modifyTimer +import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.combat.Surround.inHoleCheck -import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.Bind -import com.lambda.client.util.EntityUtils.isInOrAboveLiquid -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener +import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.network.play.client.CPacketPlayer -import net.minecraftforge.fml.common.gameevent.InputEvent -import net.minecraftforge.fml.common.gameevent.TickEvent -import org.lwjgl.input.Keyboard +import net.minecraft.util.math.AxisAlignedBB +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent + /** - * The packet mode code is licensed under MIT and can be found here: - * https://github.com/fr1kin/ForgeHax/blob/2011740/src/main/java/com/matt/forgehax/mods/StepMod.java + * @author Doogie13 + * @since 20/09/2022 */ object Step : Module( name = "Step", - description = "Changes the vanilla behavior for stepping up blocks", category = Category.MOVEMENT, - modulePriority = 200 + description = "Allows you to step up blocks", + modulePriority = 201 ) { - private val mode by setting("Mode", Mode.PACKET) - private val upStep = setting("Up Step", true) - private val downStep = setting("Down Step", false) - private val entityStep by setting("Entities", true) - private val checkHole by setting("Check Hole", false) - private val height by setting("Height", 1.0f, 0.25f..2.0f, 0.25f) - private val downSpeed by setting("Down Speed", 0.2f, 0.0f..1.0f, 0.05f) - private val bindUpStep by setting("Bind Up Step", Bind()) - private val bindDownStep by setting("Bind Down Step", Bind()) - - private const val defaultHeight = 0.6f - - private val ignoredPackets = HashSet() - private var lastCollidedTick = 0 - private var onGroundTick = 0 - - @Suppress("UNUSED") + + private val mode by setting("Mode", Mode.NCP, description = "Anticheat step bypass") + val strict by setting("Strict", false, description = "Bypass the new UpdatedNCP step checks") + val upStep = setting("Step Height", 2.5f, 1f..2.5f, .5f, { !strict }, description = "How high to step") + private enum class Mode { - VANILLA, PACKET + NCP, VANILLA } + private var playerY = 0.0 + private var timing = false + init { + upStep.valueListeners.add { _, _ -> + BaritoneUtils.settings?.assumeStep?.value = isEnabled + } + onDisable { + resetTimer() runSafe { - player.apply { - stepHeight = defaultHeight - ridingEntity?.stepHeight = 1.0f - } + player.stepHeight = .6f } - ignoredPackets.clear() } - onToggle { - BaritoneUtils.settings?.assumeStep?.value = it && upStep.value + safeListener { + if (!timing) resetTimer() + + timing = false } + } - listener { - val key = Keyboard.getEventKey() + fun pre(bb: AxisAlignedBB, player: EntityPlayerSP): Boolean { + player.ridingEntity?.let { + it.stepHeight = if (strict) 1f else upStep.value + } - if (bindUpStep.isDown(key)) { - upStep.value = !upStep.value - MessageSendHelper.sendChatMessage(upStep.toggleMsg()) - } + playerY = bb.minY - if (bindDownStep.isDown(key)) { - downStep.value = !downStep.value - MessageSendHelper.sendChatMessage(downStep.toggleMsg()) - } - } + return player.isInWater + || player.isInLava + || !player.onGround + || player.isOnLadder + || player.movementInput.jump + || player.fallDistance >= 0.1 } - private fun BooleanSetting.toggleMsg() = "$chatName Turned ${this.name} ${if (this.value) "&aon" else "&coff"}&f!" + fun post(bb: AxisAlignedBB, mc: Minecraft) { + if (mode == Mode.VANILLA) return - init { - safeListener { - if (it.phase != TickEvent.Phase.START || !shouldRunStep) return@safeListener - setStepHeight() - if (downStep.value && player.motionY <= 0.0 && player.ticksExisted - onGroundTick <= 3) downStep() - if (player.collidedHorizontally) lastCollidedTick = player.ticksExisted - if (player.onGround) onGroundTick = player.ticksExisted - } - } + val height = bb.minY - playerY - private val SafeClientEvent.shouldRunStep: Boolean - get() = !mc.gameSettings.keyBindSneak.isKeyDown - && !player.isElytraFlying - && !player.capabilities.isFlying - && !player.isOnLadder - && !player.isInOrAboveLiquid - && (!checkHole || !inHoleCheck()) + if (height < .6) + return - private fun SafeClientEvent.setStepHeight() { - player.stepHeight = if (upStep.value && player.onGround && player.collidedHorizontally) height else defaultHeight - player.ridingEntity?.let { - it.stepHeight = if (entityStep && it.collidedHorizontally) height else 1.0f - } - } + val player = mc.player + val connection = mc.connection ?: return - private fun SafeClientEvent.downStep() { - // Down step doesn't work for edge lower than 1 blocks anyways - val belowBB = player.entityBoundingBox.expand(0.0, -1.05, 0.0) - if (world.collidesWithAnyBlock(belowBB)) player.motionY -= downSpeed - } + val values = ArrayList() - init { - safeListener { event -> - if (!upStep.value || mode != Mode.PACKET || !shouldRunStep) return@safeListener - if (event.packet !is CPacketPlayer || event.packet !is CPacketPlayer.Position && event.packet !is CPacketPlayer.PositionRotation) return@safeListener - if (ignoredPackets.remove(event.packet)) return@safeListener - - val prevPos = PlayerPacketManager.prevServerSidePosition - if (player.ticksExisted - lastCollidedTick <= 5) getStepArray(event.packet.playerY - prevPos.y)?.let { - for (posY in it) { - val packet = CPacketPlayer.Position(prevPos.x, prevPos.y + posY, prevPos.z, true) - ignoredPackets.add(packet) - connection.sendPacket(packet) - } - } + when { + height > 2.019 -> values.addAll(listOf(.425, .821, .699, .599, 1.022, 1.372, 1.652, 1.869, 2.019, 1.919)) + height > 1.5 -> values.addAll(listOf(.42, .78, .63, .51, .9, 1.21, 1.45, 1.43)) + height > 1.015 -> values.addAll(listOf(.42, .7532, 1.01, 1.093, 1.015)) + height > .6 -> values.addAll(listOf(.42 * height, .7532 * height)) } - } - - private fun getStepArray(diff: Double) = when { - height >= diff && diff in 0.6..1.0 -> stepOne - height >= diff && diff in 1.0..1.5 -> stepOneHalf - height >= diff && diff in 1.5..2.0 -> stepTwo - else -> null - } - private val stepOne = doubleArrayOf(0.41999, 0.75320) - private val stepOneHalf = doubleArrayOf(0.41999, 0.75320, 1.00133, 1.16611, 1.24919, 1.17079) - private val stepTwo = doubleArrayOf(0.42, 0.78, 0.63, 0.51, 0.90, 1.21, 1.45, 1.43) + if (strict && height > .6) values.add(height) - init { - upStep.valueListeners.add { _, it -> - BaritoneUtils.settings?.assumeStep?.value = isEnabled && it + values.forEach { + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + it, player.posZ, false)) } + + modifyTimer(50f * values.size) + timing = true } } \ No newline at end of file From b0bca0ec6a4ebe17b21e38c213eb3f99b96182c6 Mon Sep 17 00:00:00 2001 From: SEOA7777 Date: Thu, 2 Feb 2023 12:31:09 +0900 Subject: [PATCH 79/85] Fix incorrect Gradle task path (#484) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2519ac38..628252453 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ In this guide we will use [IntelliJ IDEA](https://www.jetbrains.com/idea/) as ou ### Gradle build Test if the environment is set up correctly by building the client and running it inside the IDE using the Gradle tab on the right side of the IDE. -1. Go to `lambda > Tasks > build > runClient` in the Gradle tab and run the client. +1. Go to `lambda > Tasks > forgegradle runs > runClient` in the Gradle tab and run the client. 2. To build the client as a jar run `lambda > Tasks > build > build`. Gradle will create a new directory called `build`. The final built jar will be in `build/libs`. ### Stargazers From 8d37fe6e49bcd7ca5c9b87fd70028c00c25bbe45 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 1 Feb 2023 19:56:16 -0800 Subject: [PATCH 80/85] SafeWalk Compatibility (#480) * SafeWalk Compatibility * Optimized mc code --------- Co-authored-by: Constructor --- .../com/lambda/mixin/entity/MixinEntity.java | 18 ------ .../module/modules/movement/SafeWalk.kt | 61 +++++++++++++------ .../client/module/modules/player/Scaffold.kt | 6 -- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index 06cc5bd0f..1bb391ac2 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -1,6 +1,5 @@ package com.lambda.mixin.entity; -import com.lambda.client.module.modules.movement.SafeWalk; import com.lambda.client.module.modules.movement.Step; import com.lambda.client.module.modules.movement.Velocity; import com.lambda.client.module.modules.player.Freecam; @@ -22,7 +21,6 @@ public abstract class MixinEntity { @Shadow private int entityId; @Shadow private AxisAlignedBB boundingBox; - private boolean modifiedSneaking = false; float storedStepHeight = -1; @Inject(method = "applyEntityCollision", at = @At("HEAD"), cancellable = true) @@ -30,22 +28,6 @@ public void applyEntityCollisionHead(Entity entityIn, CallbackInfo ci) { Velocity.handleApplyEntityCollision((Entity) (Object) this, entityIn, ci); } - @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSneaking()Z", ordinal = 0, shift = At.Shift.BEFORE)) - public void moveInvokeIsSneakingPre(MoverType type, double x, double y, double z, CallbackInfo ci) { - if (SafeWalk.shouldSafewalk(this.entityId)) { - modifiedSneaking = true; - SafeWalk.setSneaking(true); - } - } - - @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSneaking()Z", ordinal = 0, shift = At.Shift.AFTER)) - public void moveInvokeIsSneakingPost(MoverType type, double x, double y, double z, CallbackInfo ci) { - if (modifiedSneaking) { - modifiedSneaking = false; - SafeWalk.setSneaking(false); - } - } - // Makes the camera guy instead of original player turn around when we move mouse @Inject(method = "turn", at = @At("HEAD"), cancellable = true) public void turn(float yaw, float pitch, CallbackInfo ci) { diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt index cfa2226fc..38d68e8da 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt @@ -1,43 +1,66 @@ package com.lambda.client.module.modules.movement +import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.Scaffold import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.EntityUtils.flooredPosition -import com.lambda.client.util.Wrapper import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.threads.runSafeR -import com.lambda.mixin.entity.MixinEntity +import com.lambda.client.util.threads.safeListener -/** - * @see MixinEntity.moveInvokeIsSneakingPre - * @see MixinEntity.moveInvokeIsSneakingPost - */ object SafeWalk : Module( name = "SafeWalk", description = "Keeps you from walking off edges", - category = Category.MOVEMENT + category = Category.MOVEMENT, + alwaysListening = true ) { - private val checkFallDist by setting("Check Fall Distance", true, description = "Check fall distance from edge") + private val checkFallDist by setting("Safe Fall Allowed", false, description = "Check fall distance from edge") init { - onToggle { - BaritoneUtils.settings?.assumeSafeWalk?.value = it + safeListener { event -> + if ((isEnabled || (Scaffold.isEnabled && Scaffold.safeWalk)) + && player.onGround + && !BaritoneUtils.isPathing + && if (checkFallDist) !isEdgeSafe else true) { + /** + * Code here is from net.minecraft.Entity::move + * Cannot do a mixin on this method's sneak section due to mixin compatibility issues with Future (and possibly other clients) + */ + + var x = event.x + var z = event.z + + var boundingBox = player.entityBoundingBox.offset(0.0, (-player.stepHeight).toDouble(), 0.0) + + while (x != 0.0 && world.getCollisionBoxes(player, boundingBox.offset(x, 0.0, 0.0)).isEmpty()) { + x = updateCoordinate(x) + } + + boundingBox = boundingBox.offset(x, 0.0, 0.0) + + while (z != 0.0 && world.getCollisionBoxes(player, boundingBox.offset(0.0, 0.0, z)).isEmpty()) { + z = updateCoordinate(z) + } + + event.x = x + event.z = z + } } } - @JvmStatic - fun shouldSafewalk(entityID: Int) = - (Wrapper.player?.let { !it.isSneaking && it.entityId == entityID } ?: false) - && (isEnabled || Scaffold.isEnabled && Scaffold.safeWalk) - && (!checkFallDist && !BaritoneUtils.isPathing || !isEdgeSafe) - - @JvmStatic - fun setSneaking(state: Boolean) { - Wrapper.player?.movementInput?.sneak = state + private fun updateCoordinate(coordinate: Double): Double { + return if (coordinate < 0.05 && coordinate >= -0.05) { + 0.0 + } else if (coordinate > 0.0) { + coordinate - 0.05 + } else { + coordinate + 0.05 + } } + private val isEdgeSafe: Boolean get() = runSafeR { val pos = player.flooredPosition.toVec3d(0.5, 0.0, 0.5) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index 979610a49..4d4dbab86 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -12,7 +12,6 @@ import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.player.Scaffold.isUsableItem import com.lambda.client.setting.settings.impl.collection.CollectionSetting import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.MovementUtils.speed @@ -27,7 +26,6 @@ import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.isFullBox import com.lambda.client.util.world.placeBlock -import com.lambda.mixin.entity.MixinEntity import net.minecraft.block.Block import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks @@ -42,10 +40,6 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import java.util.concurrent.ConcurrentHashMap -/** - * @see MixinEntity.moveInvokeIsSneakingPre - * @see MixinEntity.moveInvokeIsSneakingPost - */ object Scaffold : Module( name = "Scaffold", description = "Places blocks under you", From b623c11af2624193ade4fb577f4d05c41430d800 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 2 Feb 2023 09:35:41 -0800 Subject: [PATCH 81/85] SafeWalk + Step Compatibility (#485) Step modifies player.stepHeight which messes up safewalk calculations --- .../com/lambda/client/module/modules/movement/SafeWalk.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt index 38d68e8da..95fe68cf0 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt @@ -32,7 +32,7 @@ object SafeWalk : Module( var x = event.x var z = event.z - var boundingBox = player.entityBoundingBox.offset(0.0, (-player.stepHeight).toDouble(), 0.0) + var boundingBox = player.entityBoundingBox.offset(0.0, -.6, 0.0) while (x != 0.0 && world.getCollisionBoxes(player, boundingBox.offset(x, 0.0, 0.0)).isEmpty()) { x = updateCoordinate(x) From 9aebfc006866a5e8352b2b12209d6b94bff69130 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Mon, 6 Feb 2023 00:53:41 -0800 Subject: [PATCH 82/85] FreeLook Module (#489) * FreeLook Module * Decreasing nesting depth --------- Co-authored-by: Constructor --- .../com/lambda/mixin/entity/MixinEntity.java | 2 + .../client/event/ForgeEventProcessor.kt | 5 ++ .../client/module/modules/render/FreeLook.kt | 83 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/render/FreeLook.kt diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index 1bb391ac2..1a5a5c78e 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -4,6 +4,7 @@ import com.lambda.client.module.modules.movement.Velocity; import com.lambda.client.module.modules.player.Freecam; import com.lambda.client.module.modules.player.ViewLock; +import com.lambda.client.module.modules.render.FreeLook; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; @@ -33,6 +34,7 @@ public void applyEntityCollisionHead(Entity entityIn, CallbackInfo ci) { public void turn(float yaw, float pitch, CallbackInfo ci) { Entity casted = (Entity) (Object) this; + if (FreeLook.handleTurn(casted, yaw, pitch, ci)) return; if (Freecam.handleTurn(casted, yaw, pitch, ci)) return; ViewLock.handleTurn(casted, yaw, pitch, ci); } diff --git a/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt b/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt index f98b5f3e8..6c35b11ee 100644 --- a/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt +++ b/src/main/kotlin/com/lambda/client/event/ForgeEventProcessor.kt @@ -165,4 +165,9 @@ internal object ForgeEventProcessor { fun onRenderFogColors(event: EntityViewRenderEvent.FogColors) { LambdaEventBus.post(event) } + + @SubscribeEvent + fun onCameraSetupEvent(event: EntityViewRenderEvent.CameraSetup) { + LambdaEventBus.post(event) + } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/FreeLook.kt b/src/main/kotlin/com/lambda/client/module/modules/render/FreeLook.kt new file mode 100644 index 000000000..0b3b32434 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/render/FreeLook.kt @@ -0,0 +1,83 @@ +package com.lambda.client.module.modules.render + +import com.lambda.client.event.SafeClientEvent +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.threads.runSafe +import com.lambda.client.util.threads.safeListener +import net.minecraft.entity.Entity +import net.minecraft.util.math.MathHelper +import net.minecraftforge.client.event.EntityViewRenderEvent +import net.minecraftforge.client.event.InputUpdateEvent +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +object FreeLook : Module( + name = "FreeLook", + description = "Look Freely", + category = Category.RENDER +) { + private val arrowKeyYawAdjust by setting("Arrow Key Yaw Adjust", false) + private val arrowKeyYawAdjustIncrement by setting("Yaw Adjust Increment", 1.0f, 0.001f..10.0f, 0.001f, + visibility = { arrowKeyYawAdjust }); + + private var cameraYaw: Float = 0f + private var cameraPitch: Float = 0f + private var thirdPersonBefore: Int = 0 + + init { + onEnable { + runSafe { + thirdPersonBefore = mc.gameSettings.thirdPersonView + mc.gameSettings.thirdPersonView = 1; + cameraYaw = player.rotationYaw + 180.0f + cameraPitch = player.rotationPitch + } + } + + onDisable { + mc.gameSettings.thirdPersonView = thirdPersonBefore + } + + safeListener { + if (mc.gameSettings.thirdPersonView <= 0) return@safeListener + + it.yaw = cameraYaw + it.pitch = cameraPitch + } + + safeListener { + if (!arrowKeyYawAdjust) return@safeListener + + if (it.movementInput.leftKeyDown) { + // shift cam and player rot left by x degrees + updateYaw(-arrowKeyYawAdjustIncrement) + it.movementInput.leftKeyDown = false + } + if (it.movementInput.rightKeyDown) { + // shift cam and player rot right by x degrees + updateYaw(arrowKeyYawAdjustIncrement) + it.movementInput.rightKeyDown = false + } + it.movementInput.moveStrafe = 0.0f + } + } + + private fun SafeClientEvent.updateYaw(dYaw: Float) { + cameraYaw += dYaw + player.rotationYaw += dYaw + } + + @JvmStatic + fun handleTurn(entity: Entity, yaw: Float, pitch: Float, ci: CallbackInfo): Boolean { + if (isDisabled || mc.player == null) return false + return if (entity == mc.player) { + this.cameraYaw += yaw * 0.15f + this.cameraPitch -= pitch * 0.15f + this.cameraPitch = MathHelper.clamp(this.cameraPitch, -180.0f, 180.0f) + ci.cancel() + true + } else { + false + } + } +} \ No newline at end of file From b3175e25c498eacf46b97913daff197ab06bf721 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Sat, 18 Feb 2023 19:01:51 +0000 Subject: [PATCH 83/85] Add TimeWarp module (#467) * Add ClientSideTime module This patch adds the ClientSideTime module, which allows the user to change their client-side world time. It currently has two modes; TICKS and REAL_WORLD_TIME. The former allows you to specify the world time as ticks, and the latter uses your current computer time as the world time :) * Rename --------- Co-authored-by: Constructor --- .../com/lambda/mixin/world/MixinWorld.java | 7 ++++ .../client/module/modules/render/TimeWarp.kt | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt diff --git a/src/main/java/com/lambda/mixin/world/MixinWorld.java b/src/main/java/com/lambda/mixin/world/MixinWorld.java index 8889b15e3..1b9c9cafd 100644 --- a/src/main/java/com/lambda/mixin/world/MixinWorld.java +++ b/src/main/java/com/lambda/mixin/world/MixinWorld.java @@ -1,6 +1,7 @@ package com.lambda.mixin.world; import com.lambda.client.module.modules.misc.AntiWeather; +import com.lambda.client.module.modules.render.TimeWarp; import com.lambda.client.module.modules.render.NoRender; import net.minecraft.util.math.BlockPos; import net.minecraft.world.EnumSkyBlock; @@ -32,4 +33,10 @@ private void getRainStrengthHead(float delta, CallbackInfoReturnable cir) cir.setReturnValue(0.0f); } } + + @Inject(method = "getWorldTime", at = @At("HEAD"), cancellable = true) + public void onGetWorldTime(CallbackInfoReturnable cir) { + if (TimeWarp.INSTANCE.isEnabled()) + cir.setReturnValue(TimeWarp.INSTANCE.getUpdatedTime()); + } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt b/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt new file mode 100644 index 000000000..39877b349 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/render/TimeWarp.kt @@ -0,0 +1,39 @@ +package com.lambda.client.module.modules.render + +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.mixin.world.MixinWorld +import java.text.SimpleDateFormat +import java.util.* + +/** + * @see MixinWorld.onGetWorldTime + */ +object TimeWarp : Module( + name = "TimeWarp", + description = "Change the client-side world time", + category = Category.RENDER +) { + private val mode by setting("Mode", TimeWarpMode.TICKS) + private val time by setting("Time", 0, 0..24000, 600, { mode == TimeWarpMode.TICKS }) + + enum class TimeWarpMode { + REAL_WORLD_TIME, TICKS + } + + @JvmStatic + fun getUpdatedTime(): Long { + if (mode == TimeWarpMode.REAL_WORLD_TIME) + return dateToMinecraftTime(Calendar.getInstance()) + return time.toLong() + } + + private fun dateToMinecraftTime(calendar: Calendar): Long { + // We subtract 6 (add 18) to convert the real time to minecraft time :) + calendar.add(Calendar.HOUR, 18) + val time = calendar.time + val minecraftHours = SimpleDateFormat("HH").format(time) + val minecraftMinutes = (SimpleDateFormat("mm").format(time).toLong() * 100) / 60 + return "${minecraftHours}${minecraftMinutes}0".toLong() + } +} \ No newline at end of file From f01422df20a3b5eb4104ea10e6a7e732a28a79e9 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sat, 18 Feb 2023 20:11:54 -0800 Subject: [PATCH 84/85] Freecam: Rusherhack compatibility (#493) * Freecam: Rusherhack compatibility * use our paraphrased pos/rot update methods * Cleanup --------- Co-authored-by: Constructor --- .../mixin/player/MixinEntityPlayerSP.java | 144 +++++++++++------- 1 file changed, 93 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java index 488b10976..a7a8803f0 100644 --- a/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java +++ b/src/main/java/com/lambda/mixin/player/MixinEntityPlayerSP.java @@ -24,6 +24,8 @@ import net.minecraft.inventory.IInventory; import net.minecraft.network.play.client.CPacketEntityAction; import net.minecraft.network.play.client.CPacketPlayer; +import net.minecraft.util.MovementInput; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; @@ -37,9 +39,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Objects; + @Mixin(value = EntityPlayerSP.class, priority = Integer.MAX_VALUE) public abstract class MixinEntityPlayerSP extends EntityPlayer { @Shadow @Final public NetHandlerPlayClient connection; + @Shadow public MovementInput movementInput; + @Shadow public float renderArmYaw; + @Shadow public float renderArmPitch; + @Shadow public float prevRenderArmYaw; + @Shadow public float prevRenderArmPitch; @Shadow protected Minecraft mc; @Shadow private double lastReportedPosX; @Shadow private double lastReportedPosY; @@ -56,9 +65,6 @@ public MixinEntityPlayerSP(World worldIn, GameProfile gameProfileIn) { super(worldIn, gameProfileIn); } - @Shadow - protected abstract boolean isCurrentViewEntity(); - @Shadow protected abstract void updateAutoJump(float p_189810_1_, float p_189810_2_); @@ -89,7 +95,7 @@ private void onPushOutOfBlocks(CallbackInfoReturnable callbackInfoRetur public void onDisplayGUIChest(IInventory chestInventory, CallbackInfo ci) { if (BeaconSelector.INSTANCE.isEnabled()) { if (chestInventory instanceof IInteractionObject && "minecraft:beacon".equals(((IInteractionObject) chestInventory).getGuiID())) { - Minecraft.getMinecraft().displayGuiScreen(new LambdaGuiBeacon(this.inventory, chestInventory)); + Minecraft.getMinecraft().displayGuiScreen(new LambdaGuiBeacon(inventory, chestInventory)); ci.cancel(); } } @@ -104,11 +110,11 @@ public void moveHead(MoverType type, double x, double y, double z, CallbackInfo LambdaEventBus.INSTANCE.post(event); if (event.isModified()) { - double prevX = this.posX; - double prevZ = this.posZ; + double prevX = posX; + double prevZ = posZ; super.move(type, event.getX(), event.getY(), event.getZ()); - this.updateAutoJump((float) (this.posX - prevX), (float) (this.posZ - prevZ)); + updateAutoJump((float) (posX - prevX), (float) (posZ - prevZ)); ci.cancel(); } @@ -123,11 +129,50 @@ public boolean modifySprinting(boolean sprinting) { } } - // We have to return true here so it would still update movement inputs from Baritone and send packets - @Inject(method = "isCurrentViewEntity", at = @At("RETURN"), cancellable = true) - protected void mixinIsCurrentViewEntity(CallbackInfoReturnable cir) { - if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null) { - cir.setReturnValue(mc.getRenderViewEntity() == Freecam.INSTANCE.getCameraGuy()); + // Cannot use an inject in isCurrentViewEntity due to rusherhack redirecting it here + @Inject(method = "onUpdateWalkingPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isCurrentViewEntity()Z"), cancellable = true) + protected void mixinUpdateWalkingPlayerCompat(CallbackInfo ci) { + if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null && Objects.equals(this, mc.player)) { + ci.cancel(); + // we need to perform the same actions as what is in the mc method + ++positionUpdateTicks; + final AxisAlignedBB boundingBox = getEntityBoundingBox(); + final Vec3d pos = new Vec3d(posX, boundingBox.minY, posZ); + final Vec2f rot = new Vec2f(rotationYaw, rotationPitch); + final boolean isMoving = isMoving(pos); + final boolean isRotating = isRotating(rot); + sendPlayerPacket(isMoving, isRotating, pos, rot); + if (isMoving) { + lastReportedPosX = pos.x; + lastReportedPosY = pos.y; + lastReportedPosZ = pos.z; + positionUpdateTicks = 0; + } + + if (isRotating) { + lastReportedYaw = rot.getX(); + lastReportedPitch = rot.getY(); + } + + prevOnGround = onGround; + autoJumpEnabled = mc.gameSettings.autoJump; + } + } + + // Cannot use an inject in isCurrentViewEntity due to rusherhack redirecting it here + @Inject(method = "updateEntityActionState", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isCurrentViewEntity()Z"), cancellable = true) + protected void mixinEntityActionState(CallbackInfo ci) { + if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null && Objects.equals(this, mc.player)) { + ci.cancel(); + + // we need to perform the same actions as what is in the mc method + moveStrafing = movementInput.moveStrafe; + moveForward = movementInput.moveForward; + isJumping = movementInput.jump; + prevRenderArmYaw = renderArmYaw; + prevRenderArmPitch = renderArmPitch; + renderArmPitch = renderArmPitch + (rotationPitch - renderArmPitch) * 0.5f; + renderArmYaw = renderArmYaw + (rotationYaw - renderArmYaw) * 0.5f; } } @@ -141,23 +186,25 @@ private void onUpdateInvokeOnUpdateWalkingPlayer(CallbackInfo ci) { Vec3d serverSidePos = PlayerPacketManager.INSTANCE.getServerSidePosition(); Vec2f serverSideRotation = PlayerPacketManager.INSTANCE.getPrevServerSideRotation(); - this.lastReportedPosX = serverSidePos.x; - this.lastReportedPosY = serverSidePos.y; - this.lastReportedPosZ = serverSidePos.z; + lastReportedPosX = serverSidePos.x; + lastReportedPosY = serverSidePos.y; + lastReportedPosZ = serverSidePos.z; - this.lastReportedYaw = serverSideRotation.getX(); - this.lastReportedPitch = serverSideRotation.getY(); + lastReportedYaw = serverSideRotation.getX(); + lastReportedPitch = serverSideRotation.getY(); } @Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true) private void onUpdateWalkingPlayerHead(CallbackInfo ci) { + if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null + && Objects.equals(this, Freecam.INSTANCE.getCameraGuy())) return; CriticalsUpdateWalkingEvent criticalsEditEvent = new CriticalsUpdateWalkingEvent(); LambdaEventBus.INSTANCE.post(criticalsEditEvent); // Setup flags - Vec3d position = new Vec3d(this.posX, this.getEntityBoundingBox().minY, this.posZ); - Vec2f rotation = new Vec2f(this.rotationYaw, this.rotationPitch); + Vec3d position = new Vec3d(posX, getEntityBoundingBox().minY, posZ); + Vec2f rotation = new Vec2f(rotationYaw, rotationPitch); boolean moving = isMoving(position); boolean rotating = isRotating(rotation); @@ -181,11 +228,11 @@ private void onUpdateWalkingPlayerHead(CallbackInfo ci) { sendSneakPacket(); sendPlayerPacket(moving, rotating, position, rotation); - this.prevOnGround = onGround; + prevOnGround = onGround; } - ++this.positionUpdateTicks; - this.autoJumpEnabled = this.mc.gameSettings.autoJump; + ++positionUpdateTicks; + autoJumpEnabled = mc.gameSettings.autoJump; } event = event.nextPhase(); @@ -193,64 +240,59 @@ private void onUpdateWalkingPlayerHead(CallbackInfo ci) { } private void sendSprintPacket() { - boolean sprinting = this.isSprinting(); + boolean sprinting = isSprinting(); - if (sprinting != this.serverSprintState) { + if (sprinting != serverSprintState) { if (sprinting) { - this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SPRINTING)); + connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SPRINTING)); } else { - this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SPRINTING)); + connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SPRINTING)); } - this.serverSprintState = sprinting; + serverSprintState = sprinting; } } private void sendSneakPacket() { - boolean sneaking = this.isSneaking(); + boolean sneaking = isSneaking(); - if (sneaking != this.serverSneakState) { + if (sneaking != serverSneakState) { if (sneaking) { - this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SNEAKING)); + connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.START_SNEAKING)); } else { - this.connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SNEAKING)); + connection.sendPacket(new CPacketEntityAction(this, CPacketEntityAction.Action.STOP_SNEAKING)); } - this.serverSneakState = sneaking; + serverSneakState = sneaking; } } private void sendPlayerPacket(boolean moving, boolean rotating, Vec3d position, Vec2f rotation) { - if (!this.isCurrentViewEntity()) return; - - if (this.isRiding()) { - this.connection.sendPacket(new CPacketPlayer.PositionRotation(this.motionX, -999.0D, this.motionZ, rotation.getX(), rotation.getY(), onGround)); + if (isRiding()) { + connection.sendPacket(new CPacketPlayer.PositionRotation(motionX, -999.0D, motionZ, rotation.getX(), rotation.getY(), onGround)); moving = false; } else if (moving && rotating) { - this.connection.sendPacket(new CPacketPlayer.PositionRotation(position.x, position.y, position.z, rotation.getX(), rotation.getY(), onGround)); + connection.sendPacket(new CPacketPlayer.PositionRotation(position.x, position.y, position.z, rotation.getX(), rotation.getY(), onGround)); } else if (moving) { - this.connection.sendPacket(new CPacketPlayer.Position(position.x, position.y, position.z, onGround)); + connection.sendPacket(new CPacketPlayer.Position(position.x, position.y, position.z, onGround)); } else if (rotating) { - this.connection.sendPacket(new CPacketPlayer.Rotation(rotation.getX(), rotation.getY(), onGround)); - } else if (this.prevOnGround != onGround) { - this.connection.sendPacket(new CPacketPlayer(onGround)); + connection.sendPacket(new CPacketPlayer.Rotation(rotation.getX(), rotation.getY(), onGround)); + } else if (prevOnGround != onGround) { + connection.sendPacket(new CPacketPlayer(onGround)); } - if (moving) { - this.positionUpdateTicks = 0; - } + if (moving) positionUpdateTicks = 0; } private boolean isMoving(Vec3d position) { - double xDiff = position.x - this.lastReportedPosX; - double yDiff = position.y - this.lastReportedPosY; - double zDiff = position.z - this.lastReportedPosZ; + double xDiff = position.x - lastReportedPosX; + double yDiff = position.y - lastReportedPosY; + double zDiff = position.z - lastReportedPosZ; - return this.positionUpdateTicks >= 20 || xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 9.0E-4D; + return positionUpdateTicks >= 20 || xDiff * xDiff + yDiff * yDiff + zDiff * zDiff > 9.0E-4D; } private boolean isRotating(Vec2f rotation) { - double yawDiff = rotation.getX() - this.lastReportedYaw; - double pitchDiff = rotation.getY() - this.lastReportedPitch; - + double yawDiff = rotation.getX() - lastReportedYaw; + double pitchDiff = rotation.getY() - lastReportedPitch; return yawDiff != 0.0D || pitchDiff != 0.0D; } } From c9d7c411320dd5710d65327d7979f053cc84af24 Mon Sep 17 00:00:00 2001 From: Constructor Date: Sun, 19 Feb 2023 05:31:00 +0100 Subject: [PATCH 85/85] Update 3.2.1 -> 3.3.0 (#494) --- README.md | 2 +- gradle.properties | 4 ++-- src/main/kotlin/com/lambda/client/LambdaMod.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 628252453..86cf65ded 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Customize your experience, and improve your efficiency! Find our plugins [here](https://github.com/lambda-plugins).

- lambda-3.2.1.jar + lambda-3.3.0.jar

diff --git a/gradle.properties b/gradle.properties index f6230a5dd..ce922eaec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ org.gradle.caching=true org.gradle.parallel=true modGroup=com.lambda -modVersion=3.2.1 +modVersion=3.3.0 minecraftVersion=1.12.2 forgeVersion=14.23.5.2860 mappingsChannel=stable mappingsVersion=39-1.12 -kotlinVersion=1.8.0 +kotlinVersion=1.8.10 kotlinxCoroutinesVersion=1.6.4 diff --git a/src/main/kotlin/com/lambda/client/LambdaMod.kt b/src/main/kotlin/com/lambda/client/LambdaMod.kt index 5a3271f4d..489f9baa3 100644 --- a/src/main/kotlin/com/lambda/client/LambdaMod.kt +++ b/src/main/kotlin/com/lambda/client/LambdaMod.kt @@ -29,7 +29,7 @@ class LambdaMod { const val ID = "lambda" const val DIRECTORY = "lambda" - const val VERSION = "3.2.1" + const val VERSION = "3.3.0" const val APP_ID = 835368493150502923 // DiscordIPC const val DEPENDENCIES = "required-after:forge@[14.23.5.2860,);"