From 996ecb55b71c7b5c0d276a8bc7ed3a8dadbdfdaa Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Sun, 22 Mar 2026 19:31:35 +0100 Subject: [PATCH 1/3] Add AutoLevel module --- .../managers/hotbar/HotbarManager.kt | 4 + .../lambda/module/modules/player/AutoLevel.kt | 83 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index 4bc8bcca9..22e00e5ec 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -28,6 +28,7 @@ import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveRequest import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveSlot +import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.threading.runSafe import net.minecraft.item.ItemStack @@ -54,6 +55,9 @@ object HotbarManager : Manager( val serverSlot get() = runSafe { interaction.lastSelectedSlot } ?: -1 + val currentSlot get() = runSafe { + if (serverSlot != -1) HotbarContainer.slots[serverSlot] else null + } //ToDo: something to manage stacks so the hotbar manager is strictly index based private var previousStack: ItemStack? = null private var swappedTicks = 0 diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt new file mode 100644 index 000000000..381ef7dc2 --- /dev/null +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.module.modules.player + +import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.applyEdits +import com.lambda.context.SafeContext +import com.lambda.event.events.TickEvent +import com.lambda.event.listener.SafeListener.Companion.listen +import com.lambda.interaction.managers.hotbar.HotbarManager +import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.material.StackSelection +import com.lambda.interaction.material.container.containers.HotbarContainer +import com.lambda.module.Module +import com.lambda.module.tag.ModuleTag +import com.lambda.util.Timer +import net.minecraft.item.ExperienceBottleItem +import net.minecraft.item.Items +import net.minecraft.util.Hand +import kotlin.time.Duration.Companion.milliseconds + + +object AutoLevel : Module( + name = "AutoLevel", + description = "Automatically uses xp bottles to level up to a certain level", + tag = ModuleTag.PLAYER +) { + var targetLevel by setting("Target Level", 2, 1..100) + var burstAmount by setting("Burst Amount", 5, 1..100) + var interval by setting("Interval", 5, 0..100, unit = "ticks") + + val timer = Timer() + + init { + setDefaultAutomationConfig { + applyEdits { + hideGroup(eatConfig) + hotbarConfig::tickStageMask.edit { + defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) + } + } + } + listen { + if (player.experienceLevel >= targetLevel) return@listen + + if (timer.timePassed((50 * interval).milliseconds)) { + withXp { + repeat(burstAmount) { + interaction.interactItem(mc.player, Hand.MAIN_HAND) + } + timer.reset() + } + } + } + } + + private fun SafeContext.withXp(block: () -> Unit) { + if (HotbarManager.currentSlot?.stack?.item == Items.EXPERIENCE_BOTTLE) { + block() + return + } + val hotbarSlot = StackSelection.selectStack(count = 1) { isItem() }.filterSlots(HotbarContainer.slots).firstOrNull() ?: return + HotbarRequest( + hotbarSlot.index, + this@AutoLevel + ).submit(queueIfMismatchedStage = false).also { if (it.done) block() } + } +} \ No newline at end of file From 2e6a1e90e3066548c32a3318b4fe1e4de3ec2e98 Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:58:37 +0100 Subject: [PATCH 2/3] Referte HotbarManager changes Add rotate option --- .../managers/hotbar/HotbarManager.kt | 4 --- .../lambda/module/modules/player/AutoLevel.kt | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index 22e00e5ec..4bc8bcca9 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -28,7 +28,6 @@ import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveRequest import com.lambda.interaction.managers.hotbar.HotbarManager.setActiveSlot -import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.threading.runSafe import net.minecraft.item.ItemStack @@ -55,9 +54,6 @@ object HotbarManager : Manager( val serverSlot get() = runSafe { interaction.lastSelectedSlot } ?: -1 - val currentSlot get() = runSafe { - if (serverSlot != -1) HotbarContainer.slots[serverSlot] else null - } //ToDo: something to manage stacks so the hotbar manager is strictly index based private var previousStack: ItemStack? = null private var swappedTicks = 0 diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt index 381ef7dc2..945146a08 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt @@ -22,8 +22,9 @@ import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.managers.hotbar.HotbarManager import com.lambda.interaction.managers.hotbar.HotbarRequest +import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.module.Module @@ -31,6 +32,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.util.Timer import net.minecraft.item.ExperienceBottleItem import net.minecraft.item.Items +import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket import net.minecraft.util.Hand import kotlin.time.Duration.Companion.milliseconds @@ -44,12 +46,15 @@ object AutoLevel : Module( var burstAmount by setting("Burst Amount", 5, 1..100) var interval by setting("Interval", 5, 0..100, unit = "ticks") + var rotate by setting("Rotate", true) + var packetRotate by setting("Packet Rotate", true) + val timer = Timer() init { setDefaultAutomationConfig { applyEdits { - hideGroup(eatConfig) + hideGroups(eatConfig, buildConfig, breakConfig, interactConfig, inventoryConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) } @@ -58,10 +63,18 @@ object AutoLevel : Module( listen { if (player.experienceLevel >= targetLevel) return@listen + if (rotate && !packetRotate) + rotationRequest { + pitch(90f) + }.submit() if (timer.timePassed((50 * interval).milliseconds)) { withXp { + var pitch = if (rotate) 90f else RotationManager.activeRotation.pitch.toFloat() + var yaw = RotationManager.activeRotation.yaw.toFloat() repeat(burstAmount) { - interaction.interactItem(mc.player, Hand.MAIN_HAND) + interaction.sendSequencedPacket(world) { seq -> + PlayerInteractItemC2SPacket(Hand.MAIN_HAND, seq, yaw, pitch) + } } timer.reset() } @@ -70,14 +83,17 @@ object AutoLevel : Module( } private fun SafeContext.withXp(block: () -> Unit) { - if (HotbarManager.currentSlot?.stack?.item == Items.EXPERIENCE_BOTTLE) { + if (player.mainHandStack?.item == Items.EXPERIENCE_BOTTLE) { block() return } - val hotbarSlot = StackSelection.selectStack(count = 1) { isItem() }.filterSlots(HotbarContainer.slots).firstOrNull() ?: return - HotbarRequest( + val hotbarSlot = StackSelection.selectStack(count = 1) { + isItem() + }.filterSlots(HotbarContainer.slots).firstOrNull() ?: return + val done = HotbarRequest( hotbarSlot.index, this@AutoLevel - ).submit(queueIfMismatchedStage = false).also { if (it.done) block() } + ).submit(queueIfMismatchedStage = false).done + if (done) block() } } \ No newline at end of file From 9655e7fbda7e38d3218e685e993134aff2bdf07a Mon Sep 17 00:00:00 2001 From: Ic3Tank <61137113+IceTank@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:01:03 +0100 Subject: [PATCH 3/3] Update default settings --- .../kotlin/com/lambda/module/modules/player/AutoLevel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt index 945146a08..eb689ff5a 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoLevel.kt @@ -42,9 +42,9 @@ object AutoLevel : Module( description = "Automatically uses xp bottles to level up to a certain level", tag = ModuleTag.PLAYER ) { - var targetLevel by setting("Target Level", 2, 1..100) - var burstAmount by setting("Burst Amount", 5, 1..100) - var interval by setting("Interval", 5, 0..100, unit = "ticks") + var targetLevel by setting("Target Level", 2, 1..50, description = "Level to automatically use xp bottles until") + var burstAmount by setting("Burst Amount", 1, 1..10, description = "Amount of xp bottles to use each tick") + var interval by setting("Interval", 5, 0..100, unit = "ticks", description = "Interval between each burst of xp bottles") var rotate by setting("Rotate", true) var packetRotate by setting("Packet Rotate", true)