diff --git a/src/main/java/autodig/client/miner/NetherMiner.java b/src/main/java/autodig/client/miner/NetherMiner.java index af3df09..93c7223 100644 --- a/src/main/java/autodig/client/miner/NetherMiner.java +++ b/src/main/java/autodig/client/miner/NetherMiner.java @@ -118,6 +118,8 @@ public final class NetherMiner { /** 当前巷道方向 */ private int dirX; private int dirZ; + /** 是否已确定过本次任务的巷道方向(首次取玩家朝向,之后沿用旋转方向) */ + private boolean tunnelStarted; /** 上一次打印诊断日志的时间戳(节流) */ private long lastLog; /** 上一次成功下发的目标点(避免同一目标反复重发) */ @@ -163,6 +165,9 @@ public final class NetherMiner { this.fullTicks = 0; this.plan.clear(); this.step = 0; + this.dirX = 0; + this.dirZ = 0; + this.tunnelStarted = false; this.lastIssuedTarget = null; this.lastProgress = System.currentTimeMillis(); this.bestDist = Double.MAX_VALUE; @@ -370,13 +375,18 @@ public final class NetherMiner { } } - /** 建立一条直巷计划:以玩家水平坐标为起点,y = config.netherLevel,沿当前朝向推进。 */ + /** 建立一条直巷计划:以玩家水平坐标为起点,y = config.netherLevel。 + * 方向只在首次建巷道时取玩家朝向;之后(rotateAndRelocate 旋转后)沿用当前方向, + * 保证扫描路径是一条连续折线,不会因玩家朝向变化而重复挖同一片区域。 */ private void initTunnel(DigConfig config, PlayerEntity player) { - Direction facing = player.getHorizontalFacing(); - int axis = facing.getAxis() == Direction.Axis.X ? 0 : 1; - int sign = axis == 0 ? facing.getOffsetX() : facing.getOffsetZ(); - this.dirX = axis == 0 ? sign : 0; - this.dirZ = axis == 0 ? 0 : sign; + if (!this.tunnelStarted) { + Direction facing = player.getHorizontalFacing(); + int axis = facing.getAxis() == Direction.Axis.X ? 0 : 1; + int sign = axis == 0 ? facing.getOffsetX() : facing.getOffsetZ(); + this.dirX = axis == 0 ? sign : 0; + this.dirZ = axis == 0 ? 0 : sign; + this.tunnelStarted = true; + } BlockPos start = new BlockPos(player.getBlockPos().getX(), config.netherLevel, player.getBlockPos().getZ()); this.plan = new ArrayList<>(); for (int t = 0; t <= config.netherTunnelLength; t++) {