From 209a0dca6a3e222c8e9406b5425b44bf8b473617 Mon Sep 17 00:00:00 2001
From: blocksimus <336769374+blocksimus@users.noreply.github.com>
Date: Wed, 18 Nov 2026 15:08:42 +1100
Subject: [PATCH] fix: replace Baritone mixins with its API
---
.../BaritonePlayerControllerMixin.java | 42 ------------------
.../mixin/baritone/ComeCommandMixin.java | 38 ----------------
.../handler/handlers/BaritoneHandler.kt | 44 +++++++++++++++++++
.../lambda/module/modules/player/FastBreak.kt | 6 ++-
.../module/modules/player/PacketMine.kt | 6 ++-
src/main/resources/lambda.mixins.json | 2 -
6 files changed, 54 insertions(+), 84 deletions(-)
delete mode 100644 src/main/java/com/lambda/mixin/baritone/BaritonePlayerControllerMixin.java
delete mode 100644 src/main/java/com/lambda/mixin/baritone/ComeCommandMixin.java
diff --git a/src/main/java/com/lambda/mixin/baritone/BaritonePlayerControllerMixin.java b/src/main/java/com/lambda/mixin/baritone/BaritonePlayerControllerMixin.java
deleted file mode 100644
index 1747ab94f..000000000
--- a/src/main/java/com/lambda/mixin/baritone/BaritonePlayerControllerMixin.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.mixin.baritone;
-
-import baritone.utils.player.BaritonePlayerController;
-import com.lambda.Lambda;
-import com.lambda.module.modules.player.FastBreak;
-import com.lambda.module.modules.player.PacketMine;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Direction;
-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.CallbackInfoReturnable;
-
-@Mixin(value = BaritonePlayerController.class, remap = false)
-public class BaritonePlayerControllerMixin {
- @Inject(method = "clickBlock", at = @At("HEAD"), cancellable = true)
- private void injectClickBlock(BlockPos loc, Direction face, CallbackInfoReturnable cir) {
- if (PacketMine.INSTANCE.isEnabled() || FastBreak.INSTANCE.isEnabled()) {
- var interaction = Lambda.getMc().interactionManager;
- if (interaction == null) return;
- interaction.updateBlockBreakingProgress(loc, face);
- cir.cancel();
- }
- }
-}
diff --git a/src/main/java/com/lambda/mixin/baritone/ComeCommandMixin.java b/src/main/java/com/lambda/mixin/baritone/ComeCommandMixin.java
deleted file mode 100644
index 95d42644a..000000000
--- a/src/main/java/com/lambda/mixin/baritone/ComeCommandMixin.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.mixin.baritone;
-
-import baritone.api.pathing.goals.GoalBlock;
-import baritone.command.defaults.ComeCommand;
-import com.lambda.Lambda;
-import com.lambda.module.modules.render.Freecam;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.ModifyArgs;
-import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
-
-@Mixin(value = ComeCommand.class, remap = false)
-public class ComeCommandMixin {
- @ModifyArgs(method = "execute", at = @At(value = "INVOKE", target = "Lbaritone/api/process/ICustomGoalProcess;setGoalAndPath(Lbaritone/api/pathing/goals/Goal;)V"))
- private void modifyTarget(Args args) {
- if (Freecam.INSTANCE.isDisabled()) return;
- var camera = Lambda.getMc().gameRenderer.getCamera();
- var pos = camera.getBlockPos();
- args.set(0, new GoalBlock(pos.getX(), pos.getY(), pos.getZ()));
- }
-}
diff --git a/src/main/kotlin/com/lambda/interaction/handler/handlers/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/handler/handlers/BaritoneHandler.kt
index 85fe0978f..4e6a36115 100644
--- a/src/main/kotlin/com/lambda/interaction/handler/handlers/BaritoneHandler.kt
+++ b/src/main/kotlin/com/lambda/interaction/handler/handlers/BaritoneHandler.kt
@@ -20,7 +20,12 @@ package com.lambda.interaction.handler.handlers
import baritone.api.BaritoneAPI
import baritone.api.IBaritone
import baritone.api.Settings
+import baritone.api.command.ICommand
+import baritone.api.command.argument.IArgConsumer
import baritone.api.pathing.goals.Goal
+import baritone.api.pathing.goals.GoalBlock
+import baritone.api.utils.input.Input
+import com.lambda.Lambda.mc
import com.lambda.config.Config
import com.lambda.config.ConfigBlock
import com.lambda.config.Group
@@ -30,9 +35,11 @@ import com.lambda.config.blocks.RotationSettings
import com.lambda.config.categories.LambdaCategory
import com.lambda.config.entries.onValueChange
import com.lambda.context.Automated
+import com.lambda.module.modules.render.Freecam
import com.lambda.util.BlockUtils.blockPos
import net.minecraft.util.BlockMirror
import net.minecraft.util.BlockRotation
+import java.util.stream.Stream
@Suppress("unused")
object BaritoneHandler : Config(
@@ -59,12 +66,26 @@ object BaritoneHandler : Config(
@JvmStatic
val primary: IBaritone? = baritone?.primaryBaritone
+ init {
+ val commands = primary?.commandManager
+ commands?.getCommand("come")?.let { come ->
+ commands.registry.unregister(come)
+ commands.registry.register(FreecamComeCommand(come))
+ }
+ }
+
/**
* Whether Baritone is currently pathing
*/
val isPathing: Boolean
get() = baritoneAvailable && primary?.pathingBehavior?.isPathing == true
+ /**
+ * Whether Baritone is breaking a block
+ */
+ val isBreaking: Boolean
+ get() = baritoneAvailable && primary?.inputOverrideHandler?.isInputForcedDown(Input.CLICK_LEFT) == true
+
/**
* Whether Baritone is active (pathing, calculating goal, etc.)
*/
@@ -105,6 +126,29 @@ object BaritoneHandler : Config(
primary?.elytraProcess?.resetState()
}
+ /**
+ * Baritone's own #come, heading to the Freecam camera instead while Freecam is on
+ */
+ private class FreecamComeCommand(private val come: ICommand) : ICommand {
+ override fun execute(label: String, args: IArgConsumer) {
+ if (Freecam.isEnabled) {
+ args.requireMax(0)
+ setGoalAndPath(GoalBlock(mc.gameRenderer.camera.blockPos))
+ logDirect("Coming")
+ } else {
+ come.execute(label, args)
+ }
+ }
+
+ override fun tabComplete(label: String, args: IArgConsumer): Stream = come.tabComplete(label, args)
+
+ override fun getShortDesc(): String = come.shortDesc
+
+ override fun getLongDesc(): List = come.longDesc
+
+ override fun getNames(): List = come.names
+ }
+
class BaritoneConfigSettings(
override val c: Config,
private val bSettings: Settings
diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt
index 51579821b..8a09ddde8 100644
--- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt
+++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt
@@ -27,6 +27,7 @@ import com.lambda.event.events.PlayerEvent
import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.listen
import com.lambda.interaction.construction.simulation.context.BuildContext
+import com.lambda.interaction.handler.handlers.BaritoneHandler
import com.lambda.interaction.manager.managers.breaking.breakRequest
import com.lambda.module.Module
import com.lambda.module.ModuleTag
@@ -82,7 +83,10 @@ object FastBreak : Module(
hotbarConfig::tickStageMask.editSetting { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() }
}
- listen { it.cancel() }
+ listen { event ->
+ event.cancel()
+ if (BaritoneHandler.isBreaking) interaction.updateBlockBreakingProgress(event.pos, event.side)
+ }
listen { event ->
event.cancel()
withSafeAutomated {
diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt
index 8f1258027..35179db93 100644
--- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt
+++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt
@@ -37,6 +37,7 @@ import com.lambda.interaction.construction.simulation.context.BuildContext
import com.lambda.interaction.construction.simulation.result.results.BreakResult
import com.lambda.interaction.construction.simulation.sim
import com.lambda.interaction.construction.verify.TargetState
+import com.lambda.interaction.handler.handlers.BaritoneHandler
import com.lambda.interaction.manager.managers.breaking.breakRequest
import com.lambda.module.Module
import com.lambda.module.ModuleTag
@@ -136,7 +137,10 @@ object PacketMine : Module(
attackedThisTick = false
}
- listen { it.cancel() }
+ listen { event ->
+ event.cancel()
+ if (BaritoneHandler.isBreaking) interaction.updateBlockBreakingProgress(event.pos, event.side)
+ }
listen { event ->
event.cancel()
if (player.mainHandStack.item in ignoreWhenHolding) return@listen
diff --git a/src/main/resources/lambda.mixins.json b/src/main/resources/lambda.mixins.json
index c6bb57798..eb22aca53 100644
--- a/src/main/resources/lambda.mixins.json
+++ b/src/main/resources/lambda.mixins.json
@@ -7,8 +7,6 @@
"client": [
"CrashReportMixin",
"MinecraftClientMixin",
- "baritone.BaritonePlayerControllerMixin",
- "baritone.ComeCommandMixin",
"client.sound.SoundSystemMixin",
"entity.ClientPlayerEntityMixin",
"entity.ClientPlayInteractionManagerMixin",