feat: 自动换备用装备 + 背包满自动丢垃圾 (v2.1.0)
新增 AutoGear 服务: - 护甲/工具耐久过低时自动从背包换上同类备用装备(工具按镐/斧/锹/锄/剑类别, 护甲按头/胸/腿/脚部位匹配),选剩余耐久最高的候选 - 通过 clickSlot 三段点击交换(拿起旧装备->与背包新装备互换->就位), 走正规网络包,客户端/服务端同步,单人/多人均可用 - 控制器改为换装优先:能换就不打断挖矿,无备用才暂停/下界返程 - 装备保护状态下持续尝试换装,换上后自动恢复任务 新增 AutoTrash 服务: - 背包满时自动丢弃 trashItems 清单里的垃圾(默认:圆石/深板岩/凝灰岩/ 泥土/花岗岩/闪长岩/安山岩/下界岩/黑石/玄武岩,GUI 可改) - 方块类垃圾保留 trashReserve 个(默认 64)供 Baritone 搭路垫脚; 满背且无其他垃圾可丢时只丢一组腾位,尽量保住搭路方块 - clickSlot(THROW) 丢整组,每 tick 限 4 组防数据包风暴 配套修复: - NetherMiner: 修复血量低时每帧 cancelAll 导致回程寻路反复被取消卡死的 bug; markGearBroken 现在真正触发 RETURN_PORTAL 阶段;产物计数改用注册表 id + 矿物->掉落物映射 + 任务开始基线(老库存不再被误计为战果) - 两个 Miner 的背包满判定加 20 tick 去抖,给自动丢垃圾留出腾位时间 - GUI 新增两个开关与垃圾清单编辑区,切换任务/开关时保留输入框未应用的编辑 - 装备低耐久检查的手持工具仅限真正的工具,不再误伤钓鱼竿等杂物
这个提交包含在:
@@ -56,6 +56,7 @@ public final class AutoDigGui extends Screen {
|
||||
|
||||
private TextFieldWidget overworldOresField;
|
||||
private TextFieldWidget netherOresField;
|
||||
private TextFieldWidget trashField;
|
||||
|
||||
public AutoDigGui(AutoDigModClient mod) {
|
||||
super(Text.literal("AutoDig"));
|
||||
@@ -72,6 +73,7 @@ public final class AutoDigGui extends Screen {
|
||||
this.scrollOffset = 0;
|
||||
this.overworldOresField = null;
|
||||
this.netherOresField = null;
|
||||
this.trashField = null;
|
||||
|
||||
// 面板宽度自适应窗口,最小 200 保证 +/- 与输入框可用
|
||||
this.panelW = MathHelper.clamp(this.width - 16, 200, 400);
|
||||
@@ -111,6 +113,12 @@ public final class AutoDigGui extends Screen {
|
||||
"下界协同杀戮光环", () -> this.config.killAuraInNether, v -> this.config.killAuraInNether = v);
|
||||
y = this.checkPair(y, "护甲耐久保护", () -> this.config.armorDurabilityProtection, v -> this.config.armorDurabilityProtection = v,
|
||||
"工具耐久保护", () -> this.config.toolDurabilityProtection, v -> this.config.toolDurabilityProtection = v);
|
||||
y = this.checkPair(y, "自动换备用装备", () -> this.config.autoGearSwap, v -> this.config.autoGearSwap = v,
|
||||
"背包满丢垃圾", () -> this.config.autoTrash, v -> {
|
||||
this.syncFields(); // 保留输入框中未应用的编辑
|
||||
this.config.autoTrash = v;
|
||||
this.init(); // 切换后显示/隐藏垃圾设置区
|
||||
});
|
||||
y += 10;
|
||||
|
||||
y = this.header(y, "装备耐久阈值(低于即停,百分比)");
|
||||
@@ -120,6 +128,15 @@ public final class AutoDigGui extends Screen {
|
||||
v -> this.config.toolDurabilityThreshold = v, 1, 100);
|
||||
y += 10;
|
||||
|
||||
if (this.config.autoTrash) {
|
||||
y = this.header(y, "垃圾丢弃设置");
|
||||
y = this.numberRow(y, "方块垃圾保留量", () -> this.config.trashReserve,
|
||||
v -> this.config.trashReserve = v, 0, 2304);
|
||||
y = this.fieldRow(y, "垃圾物品(逗号分隔的物品 id)",
|
||||
this.config.trashItems, tf -> this.trashField = tf);
|
||||
y += 10;
|
||||
}
|
||||
|
||||
if (this.config.task == MineTask.OVERWORLD) {
|
||||
y = this.header(y, "主世界设置");
|
||||
y = this.numberRow(y, "挖掘层 (Y)", () -> this.config.overworldLevel,
|
||||
@@ -226,6 +243,7 @@ public final class AutoDigGui extends Screen {
|
||||
boolean selected = this.config.task == task;
|
||||
String text = selected ? "■ " + label : "□ " + label;
|
||||
return this.addDrawableChild(this.textButton(text, b -> {
|
||||
this.syncFields(); // 保留输入框中未应用的编辑
|
||||
this.config.task = task;
|
||||
this.init(); // 切换任务:重建滚动区,只显示相关设置
|
||||
}, x, y, w));
|
||||
@@ -339,6 +357,9 @@ public final class AutoDigGui extends Screen {
|
||||
if (this.netherOresField != null) {
|
||||
this.config.netherOres = this.netherOresField.getText();
|
||||
}
|
||||
if (this.trashField != null) {
|
||||
this.config.trashItems = this.trashField.getText();
|
||||
}
|
||||
}
|
||||
|
||||
/** 把界面临时配置写回 mod 全局配置并保存(供 controller 实时读取)。 */
|
||||
@@ -364,6 +385,10 @@ public final class AutoDigGui extends Screen {
|
||||
target.armorDurabilityThreshold = this.config.armorDurabilityThreshold;
|
||||
target.toolDurabilityProtection = this.config.toolDurabilityProtection;
|
||||
target.toolDurabilityThreshold = this.config.toolDurabilityThreshold;
|
||||
target.autoGearSwap = this.config.autoGearSwap;
|
||||
target.autoTrash = this.config.autoTrash;
|
||||
target.trashItems = this.config.trashItems;
|
||||
target.trashReserve = this.config.trashReserve;
|
||||
this.mod.saveConfig();
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户