diff --git a/src/main/java/autostore/client/controller/ExpansionController.java b/src/main/java/autostore/client/controller/ExpansionController.java index 2664774..b12f784 100644 --- a/src/main/java/autostore/client/controller/ExpansionController.java +++ b/src/main/java/autostore/client/controller/ExpansionController.java @@ -283,6 +283,10 @@ implements SubtitleChatMonitor.Listener { this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a"); return; } + // 目标已被他人占领(地图刷新后发现):立即跳过,避免继续寻路到无效区块 + if (this.skipIfTargetClaimed("\u76ee\u6807\u5df2\u88ab\u5360\u9886")) { + return; + } if (this.playerChunk.equals(this.target)) { this.baritoneBridge.cancel(); this.stageStartedMillis = System.currentTimeMillis(); @@ -292,6 +296,8 @@ implements SubtitleChatMonitor.Listener { long elapsedSeconds = (System.currentTimeMillis() - this.stageStartedMillis) / 1000L; if (elapsedSeconds >= this.config.waitTimeoutSeconds) { ++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"); @@ -308,6 +314,10 @@ implements SubtitleChatMonitor.Listener { this.setState(State.NEXT, "\u76ee\u6807\u4e3a\u7a7a"); return; } + // 目标已被他人占领(地图刷新后发现):立即跳过,避免被困在已占领区块 + if (this.skipIfTargetClaimed("\u76ee\u6807\u5df2\u88ab\u5360\u9886")) { + return; + } // 玩家离开了目标区块(被击退/寻路偏差),重新寻路回去 if (!this.playerChunk.equals(this.target)) { this.retrySameTarget("\u79bb\u5f00\u76ee\u6807\u533a\u5757\uff0c\u91cd\u65b0\u524d\u5f80 " + this.target.x() + "," + this.target.z()); @@ -316,6 +326,8 @@ implements SubtitleChatMonitor.Listener { long elapsedSeconds = (System.currentTimeMillis() - this.stageStartedMillis) / 1000L; if (elapsedSeconds >= this.config.waitTimeoutSeconds) { ++this.retryCount; + // 主动刷新地图,尽快同步"区块已被占领"的最新状态,避免玩家被困 + this.dataService.refreshAsync(); if (this.retryCount >= this.config.retries) { this.log("\u7b49\u5f85\u8d85\u65f6\uff0c\u8df3\u8fc7 " + this.target.x() + "," + this.target.z()); this.setState(State.FAIL, "\u7b49\u5f85\u9886\u5730\u5f00\u62d3\u8d85\u65f6"); @@ -328,12 +340,30 @@ implements SubtitleChatMonitor.Listener { /** 重试当前目标:取消旧寻路,重新让 Baritone 前往同一目标区块 */ private void retrySameTarget(String statusText) { + // 目标已被他人占领(地图刷新后发现):不再重试,直接跳过,避免玩家被困在已占领区块 + if (this.skipIfTargetClaimed("\u91cd\u8bd5\u65f6\u53d1\u73b0\u76ee\u6807\u5df2\u88ab\u5360\u9886")) { + return; + } this.baritoneBridge.cancel(); this.stageStartedMillis = System.currentTimeMillis(); this.baritoneBridge.pathTo(this.target); this.setState(State.PATHING, statusText); } + /** + * 若当前目标区块已被任何邦国占领(含己方与本次会话), + * 则记录日志、跳过该目标并进入 NEXT 状态,返回 true。 + * 用于在地图数据异步刷新后及时识别"已被占领"的区块,避免死循环。 + */ + private boolean skipIfTargetClaimed(String reason) { + if (this.target != null && this.isClaimedByOthers(this.target)) { + this.log(reason + " " + this.target.x() + "," + this.target.z() + "\uff0c\u8df3\u8fc7"); + this.setState(State.NEXT, "\u8df3\u8fc7\u5df2\u5360\u9886\u533a\u5757"); + return true; + } + return false; + } + /** 成功后的过渡:进入 NEXT 状态,准备处理下一个目标 */ private void tickSuccess() { this.setState(State.NEXT, "\u5df2\u5b8c\u6210 " + this.completedClaims + (this.config.targetCount > 0 ? "/" + this.config.targetCount : "/\u6301\u7eed")); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c6175c0..cd95ebc 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1 +1 @@ -{"schemaVersion":1,"id":"autostore","version":"1.0.2","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]} \ No newline at end of file +{"schemaVersion":1,"id":"autostore","version":"1.0.3","name":"AutoStore","description":"","authors":[],"contact":{},"license":"All-Rights-Reserved","environment":"client","entrypoints":{"fabric-datagen":["autostore.client.AutoStoreModDataGenerator"],"client":["autostore.client.AutoStoreModClient"],"main":["autostore.AutoStoreMod"]},"mixins":["autostore.mixins.json",{"config":"autostore.client.mixins.json","environment":"client"}],"depends":{"fabricloader":">=0.16.14","fabric-api":"*","minecraft":"1.21.4"},"jars":[{"file":"META-INF/jars/baritone-api-fabric-1.13.1.jar"}]} \ No newline at end of file