比较提交
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
e69a24eb3e | ||
|
|
77c80e5141 | ||
|
|
00414dd14b | ||
|
|
73a11723f4 |
@@ -14,7 +14,7 @@
|
||||
## 安装
|
||||
|
||||
1. 安装 Fabric Loader 0.16.14+ 和 Fabric API
|
||||
2. 将 `autostore-1.0-SNAPSHOT.jar` 放入 `.minecraft/mods/` 目录
|
||||
2. 将 `autostore-1.0.4.jar` 放入 `.minecraft/mods/` 目录
|
||||
3. 启动游戏,按 `Ctrl+R` 打开 GUI
|
||||
|
||||
## 构建
|
||||
@@ -24,4 +24,4 @@
|
||||
./build_mod.sh
|
||||
```
|
||||
|
||||
输出文件:`autostore-1.0-SNAPSHOT.jar`
|
||||
输出文件:`autostore-1.0.4.jar`
|
||||
|
||||
@@ -204,6 +204,7 @@ implements SubtitleChatMonitor.Listener {
|
||||
if (this.tickAutoFood(client)) {
|
||||
return;
|
||||
}
|
||||
this.tickAutoSwim(client);
|
||||
switch (this.state.ordinal()) {
|
||||
case 1: {
|
||||
this.plan();
|
||||
@@ -283,6 +284,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 +297,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 +315,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 +327,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 +341,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"));
|
||||
@@ -469,6 +500,26 @@ implements SubtitleChatMonitor.Listener {
|
||||
return List.of(new ChunkPos(chunk.x() + 1, chunk.z()), new ChunkPos(chunk.x() - 1, chunk.z()), new ChunkPos(chunk.x(), chunk.z() + 1), new ChunkPos(chunk.x(), chunk.z() - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动游泳逻辑(每帧调用):
|
||||
* 玩家处于水中且未站在地面上时自动跳跃(模拟按住空格键),防止溺水。
|
||||
*/
|
||||
private void tickAutoSwim(MinecraftClient client) {
|
||||
if (!this.isRunning()) {
|
||||
return;
|
||||
}
|
||||
PlayerEntity player = client.player;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
// 完全没入水中,或接触水面且未站在地面(深水区漂浮)时都需要游泳
|
||||
boolean inWater = player.isSubmergedInWater()
|
||||
|| (player.isTouchingWater() && !player.isOnGround());
|
||||
if (inWater) {
|
||||
player.jump();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动进食逻辑(每帧调用):
|
||||
* 开启 autoEat 且饥饿值低于阈值时暂停寻路并自动吃背包里的食物,
|
||||
|
||||
@@ -44,13 +44,6 @@ extends Screen {
|
||||
// ---- 输入控件 ----
|
||||
private TextFieldWidget stateField;
|
||||
private TextFieldWidget targetCountField;
|
||||
private TextFieldWidget waitTimeoutField;
|
||||
private TextFieldWidget retriesField;
|
||||
private TextFieldWidget regionXField;
|
||||
private TextFieldWidget regionZField;
|
||||
private TextFieldWidget regionRadiusField;
|
||||
private TextFieldWidget ringsField;
|
||||
private TextFieldWidget refreshIntervalField;
|
||||
private CheckboxWidget sprintBox;
|
||||
private CheckboxWidget jumpBox;
|
||||
private CheckboxWidget avoidBox;
|
||||
@@ -64,7 +57,6 @@ extends Screen {
|
||||
private int rectStartZ;
|
||||
private int rectEndX;
|
||||
private int rectEndZ;
|
||||
private boolean updatingFields;
|
||||
// ---- 布局尺寸 ----
|
||||
private int mapX = 12;
|
||||
private int mapY = 40;
|
||||
@@ -74,7 +66,6 @@ extends Screen {
|
||||
private int advancedY = 208;
|
||||
private int stateFieldY = 84;
|
||||
private int targetFieldY = 116;
|
||||
private int advRowGap = 24;
|
||||
// ---- 地图视图 ----
|
||||
private double scale = 5.0;
|
||||
private int viewCenterX;
|
||||
@@ -104,7 +95,6 @@ extends Screen {
|
||||
// 屏幕较矮时压缩垂直间距,保证右侧面板内容不被截断
|
||||
boolean compact = this.height < 480;
|
||||
int rowGap = compact ? 24 : 28; // 主字段行间距
|
||||
this.advRowGap = compact ? 20 : 24; // 高级面板字段行间距
|
||||
int advCheckGap = compact ? 16 : 18; // 高级面板复选框行间距
|
||||
|
||||
// ===== 顶部控制按钮 =====
|
||||
@@ -140,41 +130,9 @@ extends Screen {
|
||||
this.addDrawableChild(this.strategyButton("\u73a9\u5bb6\u5468\u56f4", 3, left, strategyY + 24, 90));
|
||||
this.addDrawableChild(this.strategyButton("\u7ed5\u56fd\u4e00\u5708", 4, left + 96, strategyY + 24, 90));
|
||||
|
||||
// ===== 高级设置面板:直接显示(无展开/收起按钮),紧贴策略按钮下方 =====
|
||||
this.updateRegionButtons();
|
||||
// 策略按钮第二行底部 + 8px 间距,作为高级面板起始位置
|
||||
this.advancedY = strategyY + 24 + 8;
|
||||
int advFieldX1 = this.panelX + 62;
|
||||
int advFieldX2 = this.panelX + 178;
|
||||
int advFieldWidth = Math.max(46, panelWidth - 184);
|
||||
this.waitTimeoutField = this.numberField(this.config.waitTimeoutSeconds, advFieldX1, this.advancedY, advFieldWidth);
|
||||
this.retriesField = this.numberField(this.config.retries, advFieldX2, this.advancedY, advFieldWidth);
|
||||
this.regionXField = this.numberField(this.config.regionCenterX, advFieldX1, this.advancedY + this.advRowGap, advFieldWidth);
|
||||
this.regionZField = this.numberField(this.config.regionCenterZ, advFieldX2, this.advancedY + this.advRowGap, advFieldWidth);
|
||||
this.regionRadiusField = this.numberField(this.config.regionRadius, advFieldX1, this.advancedY + this.advRowGap * 2, advFieldWidth);
|
||||
this.ringsField = this.numberField(this.config.maxRings, advFieldX2, this.advancedY + this.advRowGap * 2, advFieldWidth);
|
||||
this.refreshIntervalField = this.numberField(this.config.refreshIntervalSeconds, advFieldX1, this.advancedY + this.advRowGap * 3, advFieldWidth);
|
||||
this.addDrawableChild(this.waitTimeoutField);
|
||||
this.addDrawableChild(this.retriesField);
|
||||
this.addDrawableChild(this.regionXField);
|
||||
this.addDrawableChild(this.regionZField);
|
||||
this.addDrawableChild(this.regionRadiusField);
|
||||
this.addDrawableChild(this.ringsField);
|
||||
this.addDrawableChild(this.refreshIntervalField);
|
||||
// 用户手动编辑中心/半径时,清除圈选矩形(避免边界与输入框不一致)
|
||||
Consumer<String> clearRectOnEdit = s -> {
|
||||
if (!this.updatingFields) {
|
||||
this.config.regionMinX = 0;
|
||||
this.config.regionMaxX = -1;
|
||||
this.config.regionMinZ = 0;
|
||||
this.config.regionMaxZ = -1;
|
||||
this.updateRegionButtons();
|
||||
}
|
||||
};
|
||||
this.regionXField.setChangedListener(clearRectOnEdit);
|
||||
this.regionZField.setChangedListener(clearRectOnEdit);
|
||||
this.regionRadiusField.setChangedListener(clearRectOnEdit);
|
||||
int checkY1 = this.advancedY + this.advRowGap * 3 + 20 + 8;
|
||||
this.advancedY = strategyY + 24 + 20 + 8;
|
||||
// ===== 只保留五个权限选择框:疾跑、跳跃、避怪、破坏、放置 =====
|
||||
int checkY1 = this.advancedY + 14;
|
||||
int checkY2 = checkY1 + advCheckGap;
|
||||
int checkX = left;
|
||||
this.sprintBox = this.checkbox("\u75be\u8dd1", checkX, checkY1, this.config.allowSprint, value -> {
|
||||
@@ -260,7 +218,7 @@ extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
/** 将当前拖拽的矩形提交到配置,并更新高级面板的输入框 */
|
||||
/** 将当前拖拽的矩形提交到配置 */
|
||||
private void finalizeRegion() {
|
||||
if (this.rectStartX == this.rectEndX && this.rectStartZ == this.rectEndZ) {
|
||||
// 单点无效,清空
|
||||
@@ -274,18 +232,6 @@ extends Screen {
|
||||
this.selectingRegion = false;
|
||||
this.draggingRect = false;
|
||||
this.updateRegionButtons();
|
||||
// 同步更新中心+半径输入框,使高级面板保持一致
|
||||
int centerX = (this.config.regionMinX + this.config.regionMaxX) / 2;
|
||||
int centerZ = (this.config.regionMinZ + this.config.regionMaxZ) / 2;
|
||||
int radius = Math.max(
|
||||
this.config.regionMaxX - this.config.regionMinX,
|
||||
this.config.regionMaxZ - this.config.regionMinZ
|
||||
) / 2 + 1;
|
||||
this.updatingFields = true;
|
||||
this.regionXField.setText(Integer.toString(centerX));
|
||||
this.regionZField.setText(Integer.toString(centerZ));
|
||||
this.regionRadiusField.setText(Integer.toString(radius));
|
||||
this.updatingFields = false;
|
||||
}
|
||||
|
||||
/** 绘制区域圈选矩形(覆盖层 + 边框);仅区域扩地模式下绘制 */
|
||||
@@ -479,13 +425,7 @@ extends Screen {
|
||||
int shown;
|
||||
context.drawTextWithShadow(this.textRenderer, "\u90a6\u56fd", this.panelX + 4, this.stateFieldY + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u76ee\u6807\u6570\u91cf", this.panelX + 4, this.targetFieldY + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u7b49\u5f85\u8d85\u65f6", this.panelX + 4, this.advancedY + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u91cd\u8bd5\u6b21\u6570", this.panelX + 116, this.advancedY + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u533a\u57df\u4e2d\u5fc3X", this.panelX + 4, this.advancedY + this.advRowGap + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u533a\u57df\u4e2d\u5fc3Z", this.panelX + 116, this.advancedY + this.advRowGap + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u533a\u57df\u534a\u5f84", this.panelX + 4, this.advancedY + this.advRowGap * 2 + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u6269\u5708\u4e0a\u9650", this.panelX + 116, this.advancedY + this.advRowGap * 2 + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u5237\u65b0\u95f4\u9694", this.panelX + 4, this.advancedY + this.advRowGap * 3 + 4, -5592406);
|
||||
context.drawTextWithShadow(this.textRenderer, "\u6743\u9650\u8bbe\u7f6e", this.panelX + 4, this.advancedY, -5592406);
|
||||
int belowY = this.mapY + this.mapH + 12;
|
||||
int logWidth = Math.max(120, (int)(this.mapW * 0.52));
|
||||
int statusX = this.mapX + logWidth + 20;
|
||||
@@ -542,13 +482,6 @@ extends Screen {
|
||||
private void parseToConfig() {
|
||||
this.config.stateName = this.stateField.getText().trim();
|
||||
this.config.targetCount = this.parseInt(this.targetCountField.getText(), 20);
|
||||
this.config.waitTimeoutSeconds = this.parseInt(this.waitTimeoutField.getText(), 60);
|
||||
this.config.retries = this.parseInt(this.retriesField.getText(), 2);
|
||||
this.config.regionCenterX = this.parseInt(this.regionXField.getText(), this.playerChunk().x());
|
||||
this.config.regionCenterZ = this.parseInt(this.regionZField.getText(), this.playerChunk().z());
|
||||
this.config.regionRadius = this.parseInt(this.regionRadiusField.getText(), 5);
|
||||
this.config.maxRings = this.parseInt(this.ringsField.getText(), 0);
|
||||
this.config.refreshIntervalSeconds = this.parseInt(this.refreshIntervalField.getText(), 30);
|
||||
this.config.allowSprint = this.sprintBox.isChecked();
|
||||
this.config.allowJump = this.jumpBox.isChecked();
|
||||
this.config.avoidMobs = this.avoidBox.isChecked();
|
||||
@@ -562,17 +495,6 @@ extends Screen {
|
||||
target.strategy = this.config.strategy;
|
||||
target.stateName = this.config.stateName;
|
||||
target.targetCount = this.config.targetCount;
|
||||
target.waitTimeoutSeconds = this.config.waitTimeoutSeconds;
|
||||
target.retries = this.config.retries;
|
||||
target.regionCenterX = this.config.regionCenterX;
|
||||
target.regionCenterZ = this.config.regionCenterZ;
|
||||
target.regionRadius = this.config.regionRadius;
|
||||
target.regionMinX = this.config.regionMinX;
|
||||
target.regionMaxX = this.config.regionMaxX;
|
||||
target.regionMinZ = this.config.regionMinZ;
|
||||
target.regionMaxZ = this.config.regionMaxZ;
|
||||
target.maxRings = this.config.maxRings;
|
||||
target.refreshIntervalSeconds = this.config.refreshIntervalSeconds;
|
||||
target.allowSprint = this.config.allowSprint;
|
||||
target.allowJump = this.config.allowJump;
|
||||
target.avoidMobs = this.config.avoidMobs;
|
||||
|
||||
@@ -46,7 +46,7 @@ import net.fabricmc.api.Environment;
|
||||
*/
|
||||
public final class TerritoryDataService {
|
||||
/** 动态地图的 markers.json 接口地址(AutoStore 服务器) */
|
||||
private static final String MARKERS_URL = "http://autostore.simpfun.cn/tiles/minecraft_overworld/markers.json";
|
||||
private static final String MARKERS_URL = "http://bgjq.simpfun.cn/tiles/minecraft_overworld/markers.json";
|
||||
/** 从 marker 弹窗文本中提取"疆土归属: xxx"的邦国名 */
|
||||
private static final Pattern CLAIM_PATTERN = Pattern.compile("\u7586\u571f\u5f52\u5c5e:\\s*([^<\\r\\n]+)");
|
||||
/** 从 marker 弹窗文本中提取"「xxx」的王城"的王城名 */
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"schemaVersion":1,"id":"autostore","version":"1.0.0","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"}]}
|
||||
{"schemaVersion":1,"id":"autostore","version":"1.0.4","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"}]}
|
||||
在新工单中引用
屏蔽一个用户