v1.1.8: 回退寻路逻辑至 1.1.3 并修复目标区块错位
回退:移除 1.1.4+ 引入的回城自救/接壤校验等寻路改动(导致玩家原地不动),恢复 1.1.3 的寻路行为。 修复错位:Baritone 自带 GoalXZ 容差为 0,精确到区块中心单格,中心不可达时玩家停在相邻区块造成目标错位与反复寻路。新增 ChunkGoal,完成条件改为「玩家脚下方块落在目标区块内」,与 playerChunk.equals(target) 判定一致。
这个提交包含在:
@@ -7,13 +7,10 @@ package autostore.client.bridge;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.IBaritone;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalXZ;
|
||||
import autostore.client.config.ExpansionConfig;
|
||||
import autostore.client.territory.ChunkPos;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
/**
|
||||
* Baritone API 封装(桥接层)。
|
||||
@@ -37,16 +34,10 @@ public final class BaritoneBridge {
|
||||
settings.allowPlace.value = config.allowPlace;
|
||||
settings.allowParkour.value = config.allowJump;
|
||||
settings.avoidance.value = config.avoidMobs;
|
||||
// 减少走入地下矿洞:限制无水源时的下落高度,避免掉进深坑/矿洞。
|
||||
// 放宽到 10 格,仍允许穿越峡谷、下坡等正常地形,同时避免掉入深坑
|
||||
settings.maxFallHeightNoWater.value = 10;
|
||||
// 轻微提高挖掘方块的额外代价,让寻路尽量绕行地面而非挖洞穿山,
|
||||
// 但不会阻止必要挖掘(高山、峡谷等仍可通行)
|
||||
settings.blockBreakAdditionalPenalty.value = 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 让 Baritone 寻路前往指定区块的中心。
|
||||
* 让 Baritone 寻路前往指定区块(以“到达区块内”为完成条件)。
|
||||
*
|
||||
* @param chunk 目标区块
|
||||
*/
|
||||
@@ -55,9 +46,11 @@ public final class BaritoneBridge {
|
||||
if (baritone == null) {
|
||||
return;
|
||||
}
|
||||
// 使用 GoalXZ 前往区块中心:Baritone 的 GoalXZ 自带约 10 格容差,
|
||||
// 只需到达区块中心附近即可,避免中心点不可达导致寻路卡死
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(new GoalXZ(chunk.centerBlockX(), chunk.centerBlockZ()));
|
||||
// 使用自定义 ChunkGoal:完成条件为“玩家脚下方块落在目标区块内”,
|
||||
// 与控制器 playerChunk.equals(target) 的判定一致。避免 Baritone 自带
|
||||
// GoalXZ(容差 0,精确到区块中心单格)在中心不可达时停在相邻区块,
|
||||
// 造成目标区块错位与反复寻路。
|
||||
baritone.getCustomGoalProcess().setGoalAndPath(new ChunkGoal(chunk));
|
||||
}
|
||||
|
||||
/** 强制取消当前寻路任务。 */
|
||||
@@ -69,18 +62,6 @@ public final class BaritoneBridge {
|
||||
baritone.getPathingBehavior().forceCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送服务器聊天命令(如 /u return 回城),command 参数不含前导斜杠。
|
||||
* 用于寻路超时后的回城自救,避免玩家被困在地下矿洞等位置。
|
||||
*/
|
||||
public void sendCommand(String command) {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (client == null || client.player == null || client.getNetworkHandler() == null) {
|
||||
return;
|
||||
}
|
||||
client.getNetworkHandler().sendChatCommand(command);
|
||||
}
|
||||
|
||||
/** @return 当前是否正在寻路 */
|
||||
public boolean isPathing() {
|
||||
IBaritone baritone = this.primary();
|
||||
|
||||
在新工单中引用
屏蔽一个用户