Skip to content

Commit 3e43b88

Browse files
committed
Merge branch '1.21.5' into feature/optional-debug
2 parents 8c814c0 + e715dc0 commit 3e43b88

File tree

13 files changed

+241
-124
lines changed

13 files changed

+241
-124
lines changed

src/main/java/com/lambda/mixin/baritone/MixinLookBehavior.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) {
3636
LookBehavior instance = ((LookBehavior) (Object) this);
3737
if (instance.baritone != BaritoneManager.getPrimary()) return;
3838

39-
RotationManager.handleBaritoneRotation(rotation.getYaw());
39+
RotationManager.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch());
4040
ci.cancel();
4141
}
4242

src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.lambda.config.Setting
2626
import com.lambda.config.settings.NumericSetting
2727
import com.lambda.gui.dsl.ImGuiBuilder
2828
import com.lambda.util.extension.CommandBuilder
29+
import com.lambda.util.math.MathUtils.roundToStep
2930
import net.minecraft.command.CommandRegistryAccess
3031
import kotlin.math.roundToInt
3132

@@ -46,7 +47,9 @@ class DoubleSetting(
4647
private var valueIndex: Int
4748
get() = ((value - range.start) / step).roundToInt()
4849
set(index) {
49-
value = (range.start + index * step).coerceIn(range)
50+
value = (range.start + index * step)
51+
.roundToStep(step)
52+
.coerceIn(range)
5053
}
5154

5255
context(setting: Setting<*, Double>)

src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.lambda.config.Setting
2525
import com.lambda.config.settings.NumericSetting
2626
import com.lambda.gui.dsl.ImGuiBuilder
2727
import com.lambda.util.extension.CommandBuilder
28+
import com.lambda.util.math.MathUtils.roundToStep
2829
import net.minecraft.command.CommandRegistryAccess
2930
import kotlin.math.roundToInt
3031

@@ -45,7 +46,9 @@ class FloatSetting(
4546
private var valueIndex: Int
4647
get() = ((value - range.start) / step).roundToInt()
4748
set(index) {
48-
value = (range.start + index * step).coerceIn(range)
49+
value = (range.start + index * step)
50+
.roundToStep(step)
51+
.coerceIn(range)
4952
}
5053

5154
context(setting: Setting<*, Float>)

src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.lambda.context.AutomatedSafeContext
2121
import com.lambda.context.SafeContext
2222
import com.lambda.core.Loadable
2323
import com.lambda.interaction.construction.simulation.SimDsl
24-
import com.lambda.interaction.construction.simulation.processing.PreProcessingInfo.Companion.default
2524
import com.lambda.interaction.construction.verify.TargetState
2625
import com.lambda.util.reflections.getInstances
2726
import net.minecraft.block.BlockState
@@ -134,9 +133,7 @@ object ProcessorRegistry : Loadable {
134133
*/
135134
@SimDsl
136135
fun AutomatedSafeContext.getProcessingInfo(state: BlockState, targetState: TargetState, pos: BlockPos): PreProcessingData? {
137-
val targetBlockState = (targetState as? TargetState.State)?.blockState
138-
?: return PreProcessingData(default(targetState, pos), pos)
139-
136+
val targetBlockState = targetState.getState(pos)
140137
val processorCacheKey = state to targetBlockState
141138
val preProcessingInfo = processorCache.getOrElse(processorCacheKey) {
142139
preProcess(pos, state, targetBlockState, targetState.getStack(pos)).also { info ->

src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ object RotationManager : Manager<RotationRequest>(
174174
}
175175

176176
@JvmStatic
177-
fun handleBaritoneRotation(yaw: Float) {
177+
fun handleBaritoneRotation(yaw: Double, pitch: Double) {
178178
runSafe {
179-
activeRequest = lookAt(Rotation(yaw, player.pitch)).requestBy(BaritoneManager)
180179
usingBaritoneRotation = true
180+
activeRequest = RotationRequest(lookAt(Rotation(yaw, pitch)), BaritoneManager)
181+
updateActiveRotation()
182+
changedThisTick = true
181183
}
182184
}
183185

src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ object AutoTotem : Module(
6464
.filterSlots(player.currentScreenHandler.slots)
6565
.takeIf { it.isNotEmpty() }
6666
?.let { totems ->
67+
val cursor = player.currentScreenHandler.cursorStack
68+
val targetSlot = player.currentScreenHandler.slots
69+
.findLast { !cursor.isEmpty && it.canInsert(cursor) }
70+
6771
inventoryRequest {
72+
targetSlot?.let { pickup(it.id, 0) }
6873
swap(totems.first().id, 40)
6974
}.submit()
7075
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.module.modules.combat
19+
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
21+
import com.lambda.config.applyEdits
22+
import com.lambda.context.SafeContext
23+
import com.lambda.friend.FriendManager.isFriend
24+
import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint
25+
import com.lambda.interaction.construction.verify.TargetState
26+
import com.lambda.interaction.managers.interacting.InteractConfig
27+
import com.lambda.module.Module
28+
import com.lambda.module.tag.ModuleTag
29+
import com.lambda.task.RootTask.run
30+
import com.lambda.task.Task
31+
import com.lambda.task.tasks.BuildTask.Companion.build
32+
import com.lambda.util.BlockUtils.blockState
33+
import com.lambda.util.item.ItemUtils.block
34+
import com.lambda.util.math.flooredBlockPos
35+
import com.lambda.util.player.SlotUtils.hotbarAndStorage
36+
import com.lambda.util.world.entitySearch
37+
import net.minecraft.block.Blocks
38+
import net.minecraft.client.network.OtherClientPlayerEntity
39+
import net.minecraft.entity.player.PlayerEntity
40+
import net.minecraft.item.BlockItem
41+
import net.minecraft.util.math.BlockPos
42+
import kotlin.jvm.optionals.getOrNull
43+
44+
object PlayerTrap : Module(
45+
name = "PlayerTrap",
46+
description = "Surrounds players with any given block",
47+
tag = ModuleTag.COMBAT
48+
) {
49+
private val blocks by setting("Blocks", setOf(Blocks.OBSIDIAN, Blocks.ENDER_CHEST, Blocks.CRYING_OBSIDIAN))
50+
private val friends by setting("Friends", false)
51+
private val self by setting("Self", false)
52+
53+
private var task: Task<*>? = null
54+
55+
init {
56+
setDefaultAutomationConfig {
57+
applyEdits {
58+
buildConfig.apply {
59+
editTyped(
60+
::pathing,
61+
::stayInRange,
62+
::spleefEntities,
63+
::collectDrops
64+
) { defaultValue(false); hide() }
65+
::checkSideVisibility.edit { defaultValue(false) }
66+
}
67+
interactConfig.apply {
68+
::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
69+
}
70+
hideGroup(eatConfig)
71+
}
72+
}
73+
74+
onEnable {
75+
task = tickingBlueprint {
76+
val block = player.hotbarAndStorage.firstOrNull {
77+
it.item is BlockItem && blocks.contains(it.item.block)
78+
}?.item?.block ?: return@tickingBlueprint emptyMap()
79+
val targetPlayer = if (self) player
80+
else entitySearch<OtherClientPlayerEntity>(
81+
buildConfig.interactReach,
82+
player.eyePos.flooredBlockPos
83+
).firstOrNull { friends || !isFriend(it.gameProfile) } ?: return@tickingBlueprint emptyMap()
84+
getTrapPositions(targetPlayer).associateWith { TargetState.Block(block) }
85+
}.build(finishOnDone = false).run()
86+
}
87+
onDisable { task?.cancel(); task = null }
88+
}
89+
90+
fun SafeContext.getTrapPositions(player: PlayerEntity): Set<BlockPos> {
91+
val min = player.boundingBox.minPos.flooredBlockPos.add(-1, -1, -1)
92+
val max = player.boundingBox.maxPos.flooredBlockPos.add(1, 1, 1)
93+
94+
return buildSet {
95+
(min.x + 1..<max.x).forEach { x ->
96+
(min.y + 1..<max.y).forEach { y ->
97+
add(BlockPos(x, y, min.z))
98+
add(BlockPos(x, y, max.z))
99+
}
100+
}
101+
102+
(min.z + 1..<max.z).forEach { z ->
103+
(min.y + 1..<max.y).forEach { y ->
104+
add(BlockPos(min.x, y, z))
105+
add(BlockPos(max.x, y, z))
106+
}
107+
}
108+
109+
(min.x + 1..<max.x).forEach { x ->
110+
(min.z + 1..<max.z).forEach { z ->
111+
BlockPos(x, min.y, z).let { pos ->
112+
if (pos != player.supportingBlockPos.getOrNull() || blockState(pos).isReplaceable) add(pos)
113+
}
114+
add(BlockPos(x, max.y, z))
115+
}
116+
}
117+
}
118+
}
119+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.module.modules.combat
19+
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
21+
import com.lambda.config.applyEdits
22+
import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint
23+
import com.lambda.interaction.construction.verify.TargetState
24+
import com.lambda.interaction.managers.interacting.InteractConfig
25+
import com.lambda.module.Module
26+
import com.lambda.module.modules.combat.PlayerTrap.getTrapPositions
27+
import com.lambda.module.tag.ModuleTag
28+
import com.lambda.task.RootTask.run
29+
import com.lambda.task.Task
30+
import com.lambda.task.tasks.BuildTask.Companion.build
31+
import com.lambda.util.item.ItemUtils.block
32+
import com.lambda.util.player.SlotUtils.hotbarAndStorage
33+
import net.minecraft.block.Blocks
34+
import net.minecraft.item.BlockItem
35+
36+
object Surround : Module(
37+
name = "Surround",
38+
description = "Surrounds your players feet with any given block",
39+
tag = ModuleTag.COMBAT
40+
) {
41+
private val blocks by setting("Blocks", setOf(Blocks.OBSIDIAN, Blocks.ENDER_CHEST, Blocks.CRYING_OBSIDIAN))
42+
43+
private var task: Task<*>? = null
44+
45+
init {
46+
setDefaultAutomationConfig {
47+
applyEdits {
48+
buildConfig.apply {
49+
editTyped(
50+
::pathing,
51+
::stayInRange,
52+
::spleefEntities,
53+
::collectDrops
54+
) { defaultValue(false); hide() }
55+
::checkSideVisibility.edit { defaultValue(false) }
56+
}
57+
interactConfig.apply {
58+
::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.Grim) }
59+
}
60+
hideGroup(eatConfig)
61+
}
62+
}
63+
64+
onEnable {
65+
task = tickingBlueprint {
66+
val block = player.hotbarAndStorage.firstOrNull {
67+
it.item is BlockItem && blocks.contains(it.item.block)
68+
}?.item?.block ?: return@tickingBlueprint emptyMap()
69+
getTrapPositions(player)
70+
.filter { it.y <= player.blockPos.y }
71+
.associateWith { TargetState.Block(block) }
72+
}.build(finishOnDone = false).run()
73+
}
74+
onDisable { task?.cancel(); task = null }
75+
}
76+
}

src/main/kotlin/com/lambda/module/modules/movement/Pitch40.kt

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)