v1.1.8: 寻路超时自动 /u return 回城自救
寻路超时后发送 /u return 回城,等待 10 秒传送回王城后重新寻路;重试次数耗尽则回城后跳过,避免整个系统因寻路卡死而停止。
这个提交包含在:
@@ -70,6 +70,12 @@ implements SubtitleChatMonitor.Listener {
|
||||
private int retryCount;
|
||||
/** 当前阶段(寻路/等待)的开始时间戳 */
|
||||
private long stageStartedMillis;
|
||||
/** 发送 "/u return" 回城指令的时间戳;0 表示当前未处于回城恢复等待中 */
|
||||
private long returnCommandAtMillis;
|
||||
/** 回城后是否需要跳过当前目标(重试次数已耗尽则为 true) */
|
||||
private boolean skipTargetAfterReturn;
|
||||
/** 回城等待时长:发送 "/u return" 后等待传送回王城的毫秒数 */
|
||||
private static final long RETURN_WAIT_MS = 10_000L;
|
||||
/** 最近一次开垦进度(0-100) */
|
||||
private int lastProgress;
|
||||
/** 当前目标区块的哈希集合,用于去重(防止重复计数) */
|
||||
@@ -168,6 +174,8 @@ implements SubtitleChatMonitor.Listener {
|
||||
this.claimedSet.clear();
|
||||
this.target = null;
|
||||
this.eating = false;
|
||||
this.returnCommandAtMillis = 0L;
|
||||
this.skipTargetAfterReturn = false;
|
||||
this.baritoneBridge.applyConfig(this.config);
|
||||
this.setState(State.PLANNING, "\u6b63\u5728\u751f\u6210\u6269\u5f20\u8ba1\u5212");
|
||||
this.log("\u5f00\u59cb\u81ea\u52a8\u6269\u5730\uff0c\u90a6\u56fd\uff1a" + this.model.selfStateName());
|
||||
@@ -182,6 +190,8 @@ implements SubtitleChatMonitor.Listener {
|
||||
}
|
||||
this.baritoneBridge.cancel();
|
||||
this.eating = false;
|
||||
this.returnCommandAtMillis = 0L;
|
||||
this.skipTargetAfterReturn = false;
|
||||
this.setState(State.STOPPED, "\u5df2\u624b\u52a8\u505c\u6b62");
|
||||
this.log("\u5df2\u624b\u52a8\u505c\u6b62");
|
||||
}
|
||||
@@ -284,6 +294,26 @@ implements SubtitleChatMonitor.Listener {
|
||||
this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a");
|
||||
return;
|
||||
}
|
||||
// 正处于"回城恢复等待"中(已发送 /u return):等待传送回王城,暂不处理超时/到达
|
||||
if (this.returnCommandAtMillis > 0L) {
|
||||
// 等待窗口未结束:静默等待,让 /u return 完成传送
|
||||
if (System.currentTimeMillis() - this.returnCommandAtMillis < RETURN_WAIT_MS) {
|
||||
this.status = "\u5bfb\u8def\u8d85\u65f6\uff0c\u6b63\u5728\u56de\u57ce\uff08/u return\uff09";
|
||||
return;
|
||||
}
|
||||
// 等待窗口结束:取消回城等待;据重试次数决定重寻路或跳过
|
||||
this.returnCommandAtMillis = 0L;
|
||||
if (this.skipTargetAfterReturn) {
|
||||
this.skipTargetAfterReturn = false;
|
||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u56de\u57ce\u540e\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
||||
this.setState(State.FAIL, "\u5bfb\u8def\u8d85\u65f6");
|
||||
this.dataService.refreshAsync();
|
||||
} else {
|
||||
this.log("\u5df2\u56de\u57ce\uff0c\u91cd\u65b0\u5bfb\u8def\u524d\u5f80 " + this.target.x() + "," + this.target.z());
|
||||
this.retrySameTarget("\u5df2\u56de\u57ce\uff0c\u91cd\u65b0\u524d\u5f80 " + this.target.x() + "," + this.target.z());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 目标已被他人占领(地图刷新后发现):立即跳过,避免继续寻路到无效区块
|
||||
if (this.skipIfTargetClaimed("\u76ee\u6807\u5df2\u88ab\u5360\u9886")) {
|
||||
return;
|
||||
@@ -299,13 +329,14 @@ implements SubtitleChatMonitor.Listener {
|
||||
++this.retryCount;
|
||||
// 主动刷新地图,尽快同步"区块已被占领"的最新状态,避免玩家被困
|
||||
this.dataService.refreshAsync();
|
||||
if (this.retryCount >= this.config.retries) {
|
||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
||||
this.setState(State.FAIL, "\u5bfb\u8def\u8d85\u65f6");
|
||||
// 寻路超时:发送 /u return 回城,等待传送回王城后重新寻路;重试次数耗尽则回城后跳过
|
||||
this.skipTargetAfterReturn = this.retryCount >= this.config.retries;
|
||||
if (this.skipTargetAfterReturn) {
|
||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u56de\u57ce\u540e\u8df3\u8fc7 " + this.target.x() + "," + this.target.z());
|
||||
} else {
|
||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u91cd\u8bd5 " + this.retryCount + "/" + this.config.retries);
|
||||
this.retrySameTarget("\u91cd\u8bd5\u524d\u5f80 " + this.target.x() + "," + this.target.z());
|
||||
this.log("\u5bfb\u8def\u8d85\u65f6\uff0c\u56de\u57ce\u91cd\u8bd5 " + this.retryCount + "/" + this.config.retries);
|
||||
}
|
||||
this.issueReturnCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +370,21 @@ implements SubtitleChatMonitor.Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送 "/u return" 回城指令,取消当前寻路,并记录发送时刻以进入回城恢复等待。
|
||||
* 服务器会在约 10 秒后将玩家传送回邦国王城,届时由 tickPathing 重新寻路。
|
||||
*/
|
||||
private void issueReturnCommand() {
|
||||
this.baritoneBridge.cancel();
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
if (client != null && client.player != null && client.player.networkHandler != null) {
|
||||
// sendChatCommand 需传不带斜杠的命令("/u return" -> "u return")
|
||||
client.player.networkHandler.sendChatCommand("u return");
|
||||
}
|
||||
this.returnCommandAtMillis = System.currentTimeMillis();
|
||||
this.status = "\u5bfb\u8def\u8d85\u65f6\uff0c\u5df2\u53d1\u9001 /u return \u56de\u57ce";
|
||||
}
|
||||
|
||||
/** 重试当前目标:取消旧寻路,重新让 Baritone 前往同一目标区块 */
|
||||
private void retrySameTarget(String statusText) {
|
||||
// 目标已被他人占领(地图刷新后发现):不再重试,直接跳过,避免玩家被困在已占领区块
|
||||
|
||||
在新工单中引用
屏蔽一个用户