Skip to content

Commit 9b6776f

Browse files
committed
minimum obstacle height setting in ElytraFly obstacle passer settings with default set to carpet height, and fix baritone block breaking. It also now uses packet mine or fast break if you have either enabled.
1 parent e3c9f3d commit 9b6776f

6 files changed

Lines changed: 73 additions & 27 deletions

File tree

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,38 @@
2323
import com.lambda.interaction.BaritoneHandler;
2424
import com.lambda.interaction.managers.rotating.RotationManager;
2525
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
26+
import net.minecraft.client.network.ClientPlayerEntity;
2627
import org.spongepowered.asm.mixin.Final;
2728
import org.spongepowered.asm.mixin.Mixin;
2829
import org.spongepowered.asm.mixin.Shadow;
2930
import org.spongepowered.asm.mixin.injection.At;
3031

32+
import static net.minecraft.util.math.MathHelper.wrapDegrees;
33+
3134
@Mixin(value = BaritonePlayerContext.class, remap = false) // fix compileJava warning
32-
public class BaritonePlayerContextMixin {
35+
public abstract class BaritonePlayerContextMixin {
3336
@Shadow
3437
@Final
3538
private Baritone baritone;
3639

40+
@Shadow
41+
public abstract ClientPlayerEntity player();
42+
3743
// Let baritone know the actual rotation
3844
@ModifyReturnValue(method = "playerRotations", at = @At("RETURN"), remap = false)
3945
Rotation syncRotationWithBaritone(Rotation original) {
40-
if (baritone != BaritoneHandler.getPrimary())
41-
return original;
46+
if (baritone != BaritoneHandler.getPrimary()) return original;
47+
48+
var baritoneRot = baritone.getLookBehavior().getEffectiveRotation();
49+
var lambdaRot = RotationManager.getActiveRotation();
4250

43-
float yaw = (float) RotationManager.getActiveRotation().getYaw();
44-
float pitch = (float) RotationManager.getActiveRotation().getPitch();
51+
float yaw = baritoneRot.map(Rotation::getYaw).orElseGet(lambdaRot::getYawF);
52+
float pitch = baritoneRot.map(Rotation::getPitch).orElseGet(lambdaRot::getPitchF);
4553

4654
if (Float.isNaN(yaw) || Float.isNaN(pitch)) {
4755
return original;
4856
}
4957

50-
return new Rotation(net.minecraft.util.math.MathHelper.wrapDegrees(yaw), pitch);
58+
return new Rotation(wrapDegrees(yaw), pitch);
5159
}
5260
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2026 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.mixin.baritone;
19+
20+
import baritone.utils.player.BaritonePlayerController;
21+
import com.lambda.Lambda;
22+
import com.lambda.module.modules.player.FastBreak;
23+
import com.lambda.module.modules.player.PacketMine;
24+
import net.minecraft.util.math.BlockPos;
25+
import net.minecraft.util.math.Direction;
26+
import org.spongepowered.asm.mixin.Mixin;
27+
import org.spongepowered.asm.mixin.injection.At;
28+
import org.spongepowered.asm.mixin.injection.Inject;
29+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30+
31+
@Mixin(BaritonePlayerController.class)
32+
public class BaritonePlayerControllerMixin {
33+
@Inject(method = "clickBlock", at = @At("HEAD"))
34+
private void injectClickBlock(BlockPos loc, Direction face, CallbackInfoReturnable<Boolean> cir) {
35+
if (PacketMine.INSTANCE.isEnabled() || FastBreak.INSTANCE.isEnabled()) {
36+
var interaction = Lambda.getMc().interactionManager;
37+
if (interaction == null) return;
38+
interaction.updateBlockBreakingProgress(loc, face);
39+
}
40+
}
41+
}

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
package com.lambda.mixin.baritone;
1919

20-
import baritone.api.event.events.PlayerUpdateEvent;
21-
import baritone.api.event.events.RotationMoveEvent;
2220
import baritone.api.utils.Rotation;
2321
import baritone.behavior.LookBehavior;
2422
import com.lambda.interaction.BaritoneHandler;
2523
import com.lambda.interaction.managers.rotating.RotationManager;
24+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
26+
import net.minecraft.client.network.ClientPlayerEntity;
2627
import org.spongepowered.asm.mixin.Mixin;
2728
import org.spongepowered.asm.mixin.Unique;
2829
import org.spongepowered.asm.mixin.injection.At;
@@ -32,28 +33,21 @@
3233
@Mixin(value = LookBehavior.class, remap = false)
3334
public class LookBehaviourMixin {
3435
@Unique
35-
LookBehavior instance = ((LookBehavior) (Object) this);
36+
LookBehavior instance = (LookBehavior) (Object) this;
3637

3738
// Redirect baritone's rotations into our rotation engine
38-
@Inject(method = "updateTarget", at = @At("HEAD"), cancellable = true)
39+
@Inject(method = "updateTarget", at = @At("HEAD"))
3940
void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) {
4041
if (instance.baritone != BaritoneHandler.getPrimary()) return;
41-
4242
RotationManager.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch());
43-
ci.cancel();
4443
}
4544

46-
@Inject(method = "onPlayerUpdate", at = @At("HEAD"), cancellable = true)
47-
void onUpdate(PlayerUpdateEvent event, CallbackInfo ci) {
48-
if (instance.baritone != BaritoneHandler.getPrimary()) return;
49-
50-
ci.cancel();
51-
}
45+
@WrapOperation(method = "onPlayerUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;setYaw(F)V"))
46+
private void wrapSetYaw(ClientPlayerEntity instance, float v, Operation<Void> original) {}
5247

53-
@Inject(method = "onPlayerRotationMove", at = @At("HEAD"), cancellable = true)
54-
void onMovementUpdate(RotationMoveEvent event, CallbackInfo ci) {
55-
if (instance.baritone != BaritoneHandler.getPrimary()) return;
48+
@WrapOperation(method = "onPlayerUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;setPitch(F)V"))
49+
private void wrapSetPitch(ClientPlayerEntity instance, float v, Operation<Void> original) {}
5650

57-
ci.cancel();
58-
}
51+
@WrapOperation(method = "pig", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;setYaw(F)V"))
52+
private void wrapPigSetYaw(ClientPlayerEntity instance, float v, Operation<Void> original) {}
5953
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ object RotationManager : Manager<RotationRequest>(
140140
* @see updateActiveRotation
141141
*/
142142
override fun AutomatedSafeContext.handleRequest(request: RotationRequest) {
143+
if (usingBaritoneRotation) return
143144
if (acceptAndSetRequests(request)) {
144145
updateActiveRotation()
145146
changedThisTick = true

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ object ElytraFly : Module(
9999

100100
private const val OBSTACLE_PASSER_GROUP = "Obstacle Passer"
101101
@Group(OBSTACLE_PASSER_GROUP) private val passObstacles by setting("Pass Obstacles", true, "Automatically paths around obstacles using baritone") { mode == FlyMode.Bounce }
102+
@Group(OBSTACLE_PASSER_GROUP) private val minObstacleHeight by setting("Min Obstacle Height", 0.063, 0.0..1.0, 0.0001, "The minimum height an obstacle must be above the ground to trigger obstacle passer")
102103
@Group(OBSTACLE_PASSER_GROUP) private val applyPauseAfterBaritone by setting("Apply Pause After Baritone", false, "Ticks the flag pause after baritone has finished pathing") { mode == FlyMode.Bounce && passObstacles }
103104
@Group(OBSTACLE_PASSER_GROUP) private val acceptableOffsetRange by setting("Acceptable Offset Range", 2.0, 0.1..5.0, 0.01, "Acceptable offset from the original flight line to allow when starting to fly again after passing obstacles") { mode == FlyMode.Bounce && passObstacles }
104105
@Group(OBSTACLE_PASSER_GROUP) private val obstacleLookAhead by setting("Obstacle Look-Ahead", 15, 0..50, 1, "Looks ahead of the player to see if obstacles are in the way") { mode == FlyMode.Bounce && passObstacles }
@@ -218,6 +219,8 @@ object ElytraFly : Module(
218219
private fun SafeContext.onTickBounce() {
219220
if (!BaritoneHandler.isActive) passingToPos = null
220221

222+
if (autoPitch) rotationRequest { pitch(pitch) }.submit()
223+
221224
val playerPos = player.pos
222225
val validDistanceFromStart = Vec3d(playerPos.x, startPos.y, playerPos.z) dist startPos > 0.1
223226
if (passObstacles && validDistanceFromStart) run obstacleChecks@{
@@ -263,8 +266,6 @@ object ElytraFly : Module(
263266
return
264267
}
265268

266-
if (autoPitch) rotationRequest { pitch(pitch) }.submit()
267-
268269
if (!player.isGliding) {
269270
if (takeoff && player.canTakeoff) {
270271
if (player.canOpenElytra) {
@@ -312,9 +313,9 @@ object ElytraFly : Module(
312313
flooredBlockPos.down().let { downPos ->
313314
!safeContext.blockState(downPos).isSolidBlock(safeContext.world, downPos)
314315
} ||
315-
rayCastObstructed(direction) ||
316+
add(0.0, minObstacleHeight, 0.0).rayCastObstructed(direction) ||
316317
add(0.0, 1.0, 0.0).rayCastObstructed(direction) ||
317-
add(0.0, 2.0, 0.0).rayCastObstructed(direction)
318+
add(0.0, 1.99, 0.0).rayCastObstructed(direction)
318319
}
319320

320321
context(safeContext: SafeContext)

src/main/resources/lambda.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"CrashReportMixin",
88
"MinecraftClientMixin",
99
"baritone.BaritonePlayerContextMixin",
10+
"baritone.BaritonePlayerControllerMixin",
1011
"baritone.ComeCommandMixin",
1112
"baritone.LookBehaviourMixin",
1213
"client.sound.SoundSystemMixin",

0 commit comments

Comments
 (0)